home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ExampleClass.h
-
- Contains: Declarations for the TExampleClass
-
- Copyright: © 1991-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #ifndef __EXAMPLECLASS__
- #define __EXAMPLECLASS__
-
-
- // the functionset ID for the example library
- #define kExampleFunctionSet "appl:exam$ExampleFSet,1.2"
-
- #ifndef __LIBRARYMANAGER__
- #include <LibraryManager.h>
- #endif
-
- #ifdef __cplusplus
-
- #ifndef __LIBRARYMANAGERCLASSES__
- #include <LibraryManagerClasses.h>
- #endif
-
- typedef unsigned long ulong;
- typedef char* (* _CDECL HelloCPtr)(ulong*);
- typedef pascal Ptr (*HelloPPtr)(ulong&);
-
- //
- // If __SCLIBRARY__ is defined then that means not only are we compiling with
- // SCpp, but we also want to use Symantec calling conventions. In this case
- // undefine _CDECL so that Symantec C++ calling conventions will be used. The
- // library will not be usable from the CPlus version of LibraryManagerTest1
- // tool in this case.
- //
- // Note that the destructor still uses _cdecl calling conventions if
- // __SCLIBRARY__ is defined because the destructor had already been
- // declared as _cdecl in TSCDynamic.
- //
- #if __SCLIBRARY__
- #define _CDECL2
- #else
- #define _CDECL2 _CDECL
- #endif
-
- /**********************************************************************
- ** class TExampleClass
- ***********************************************************************/
-
- #define kTExampleClassID "appl:exam$TExampleClass,1.2"
-
- #if __SCLIBRARY__
- class TExampleClass : public TSCDynamic
- #else
- class TExampleClass : public TDynamic
- #endif
- {
- public:
- _CDECL2 TExampleClass();
- virtual ~ _CDECL TExampleClass();
-
- // New Methods
-
- virtual char* _CDECL2 GetObjectName() const;
- virtual void _CDECL2 SetObjectName(char *theName);
-
- virtual void _CDECL2 DoThisAndThat();
- virtual void _CDECL2 DoThat();
-
- virtual void _CDECL2 SetGlobalInt(long theValue);
- virtual long _CDECL2 GetGlobalInt();
-
- // Public non-virtual function
- // Dynamically exported by using ExportFunction
- void _CDECL2 GetGlobalRef(long*&);
-
- // Public static function
- // Dynamically exported by the ExportFunction
- static Boolean _CDECL2 Test(ulong test);
- static Boolean _CDECL2 Test(char* test);
-
- private:
- char *fName;
-
- // static gExampleClassCount counts the number of instances
- static long gExampleClassCount;
- };
-
-
- extern "C" char* HelloC(ulong*);
- ulong _CDECL Goodbye();
-
- //
- // The THINK C++ compiler does not automically upper case pascal function
- // names so we need to declare them as upper case.
- //
- #if defined(THINK_CPLUS)
- pascal Ptr HELLOPASCAL(ulong& theHelloTicks);
- pascal ulong GOODBYEPASCAL();
- #else
- pascal Ptr HelloPascal(ulong& theHelloTicks);
- pascal ulong GoodbyePascal();
- #endif
-
- //
- // Unfortunately, Symantec C++ does not handle overloaded _cdecl functions,
- // even though it handles overloaded _cdecl methods, so we resort to a hack
- // here. If we're compiling with Symantec - we use the mangled names of the
- // "C" Functions to allow the link to work. Of course, if we compile
- // ExampleClass with Symantec C++, and link it with Symantec C++ this problem
- // doesn't exist.
- //
- #if (defined(THINK_CPLUS) || defined(__SC__)) && !__SCLIBRARY__
- #define kHelloRef Hello__FRUl
- #define kHelloPtr Hello__FPUl
-
- char* _CDECL kHelloRef(ulong&);
- char* _CDECL kHelloPtr(ulong*);
- #else
- #define kHelloRef Hello
- #define kHelloPtr Hello
-
- char* Hello(ulong&);
- char* Hello(ulong*);
- #endif
-
- #else
-
- typedef void TExampleClass;
-
- /* Inline message dispatching code */
- #define JSRA1 0x4e91
- #define dispatchMessage(routineID) \
- {0x2057,0x2050,0x2268,4*##routineID,JSRA1}
-
- void ExDestructor(TExampleClass* this) = dispatchMessage(1);
- char* ExGetObjectName(TExampleClass* this) = dispatchMessage(9);
- void ExSetObjectName(TExampleClass* this, char *theName) = dispatchMessage(10);
- void ExDoThisAndThat(TExampleClass* this) = dispatchMessage(11);
- void ExDoThat(TExampleClass* this) = dispatchMessage(12);
- void ExSetGlobalInt(TExampleClass* this, long theValue) = dispatchMessage(13);
- long ExGetGlobalInt(TExampleClass* this) = dispatchMessage(14);
-
- char* Hello();
-
- #endif
- #endif
-