home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / ExampleLibrary / Sources / LibraryManagerTest2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  1.9 KB  |  77 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        LibraryManagerTest2.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Copyright:    © 1991-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #ifndef __EXAMPLECLASS__
  11. #include "ExampleClass.h"
  12. #endif
  13. #ifndef __EVENTS__
  14. #include <Events.h>
  15. #endif
  16. #ifndef __CURSORCTL__
  17. #include <CursorCtl.h>
  18. #endif
  19.  
  20. #ifndef __STDIO__
  21. #include <stdio.h>
  22. #endif
  23.  
  24. static void Idle(RgnHandle);
  25.  
  26. void DoTests(TExampleClass* object1, TExampleClass* object2, int count, Boolean trace, Boolean verbose)
  27. {
  28.     RgnHandle myRgn;
  29.     unsigned long endcount, startcount;
  30.  
  31.     InitGraf(&qd.thePort);            // initialize quickdraw so we can use regions
  32.     myRgn = NewRgn();                    // a region to use for WaitNextEvent
  33.  
  34.     InitCursorCtl(NULL);
  35.  
  36.     if (object1 && object2) {
  37.         startcount = TickCount();
  38.         ExSetObjectName(object1, "object1");
  39.         ExSetObjectName(object2, "object2");
  40.         
  41.         while (count-- > 0) {            // <-- here is the test while loop
  42.             ExDoThisAndThat(object1);        // here we test DoThisAndThat for object1
  43.             ExDoThisAndThat(object2);        // here we test DoThisAndThat for object2
  44.             if (trace) Idle(myRgn);            // if we are tracing we must idle
  45.             if (verbose) SpinCursor(1);        // if we are verbose we will spin the cursor
  46.         }
  47.         
  48.         // test accessing globals
  49.         ExSetGlobalInt(object1, 42);    // set the global using object1
  50.         
  51.         // get the global using object2
  52.         // since object1 and object2 share the same A5 world this will return
  53.         // 42!
  54.         printf("%s ExGetGlobalInt() returns: %d",ExGetObjectName(object2),ExGetGlobalInt(object2));
  55.         printf("\n");    // hack to keep SC 7.0.5 from crashing
  56.         endcount = TickCount();
  57.         printf("Dispatches took %d ticks\n", endcount - startcount);
  58.     }
  59.  
  60.     if (object1) {
  61.         if (verbose) printf("Disposing object1\n");
  62.         ExDestructor(object1);
  63.     }
  64.  
  65.     if (object2) {
  66.         if (verbose) printf("Disposing object2\n");
  67.         ExDestructor(object2);
  68.     }
  69.     
  70.     DisposeRgn(myRgn);
  71. }
  72.  
  73. static void Idle(RgnHandle myRgn)
  74. {
  75.     EventRecord myEvent;
  76.     WaitNextEvent(nullEvent, &myEvent, 0, myRgn);
  77. }