home *** CD-ROM | disk | FTP | other *** search
- #include "REALplugin.h"
- #ifndef WIN32
- #include <A4Stuff.h>
- #include <SetupA4.h>
- #endif
- #include "rb_plugin.h"
-
- #ifndef WIN32
- #ifndef powerc
- #define USECALLSHELL
- #endif
- #endif
-
- static void *(*gResolver)(const char *entryName);
-
- #ifdef powerc
- static void *(*gResolverPPC)(const char *entryName);
- #endif
-
- // static Ptr *gA4Stack;
- static unsigned long a4stack;
-
- #ifdef powerc
- int __procinfo = kCStackBased | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(4));
- #endif
-
- #ifdef powerc
- //#define CallResolver(a) CallUniversalProc((RoutineDescriptor *) gResolver, kCStackBased | RESULT_SIZE(SIZE_CODE(4)) | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(4)), a)
- //#define Caller(func, upp) CallUniversalProc((RoutineDescriptor *) func, upp,
- #define CallResolver(a) gResolverPPC(a)
- #else
- #define CallResolver(a) gResolver(a)
- #endif
-
- #ifdef USECALLSHELL
- static REALproc buildEnvironmentShell(void *func)
- {
- short *glue;
- REALproc proc;
- unsigned long originalCode;
- unsigned long unglue;
- unsigned long pluginA4 = GetCurrentA4();
-
- static int gRemainAllocCount;
- static Ptr gRemainAllocPtr;
-
- if (!func)
- return nil;
- if (func == REALstandardGetter)
- return REALstandardGetter;
-
- originalCode = (unsigned long) func;
- if (!gRemainAllocCount)
- {
- gRemainAllocCount = 8;
- gRemainAllocPtr = NewPtr(8 * 52);
- }
-
- glue = (short *) gRemainAllocPtr;
- gRemainAllocPtr += 52;
- gRemainAllocCount--;
- proc = (REALproc) glue;
-
- unglue = (unsigned long) (glue + 17);
-
- *glue++ = 0x2079; // movea.l $, A0
- *glue++ = a4stack >> 16;
- *glue++ = a4stack & 0xffff;
- *glue++ = 0x210c; // move.l A4, -(A0)
- *glue++ = 0x211f; // move.l (A7)+, -(A0)
- *glue++ = 0x287c; // move.l #, A4
- *glue++ = pluginA4 >> 16;
- *glue++ = pluginA4 & 0xffff;
- *glue++ = 0x2f3c; // move.l #, -(A7)
- *glue++ = unglue >> 16;
- *glue++ = unglue & 0xffff;
- *glue++ = 0x23c8; // move.l A0, $
- *glue++ = a4stack >> 16;
- *glue++ = a4stack & 0xffff;
- *glue++ = 0x4ef9; // jmp $
- *glue++ = originalCode >> 16;
- *glue++ = originalCode & 0xffff;
-
- *glue++ = 0x2279; // movea.l $, A1
- *glue++ = a4stack >> 16;
- *glue++ = a4stack & 0xffff;
- *glue++ = 0x2f19; // move.l (A1)+,-(A7)
- *glue++ = 0x2859; // movea.l (A1)+, A4
- *glue++ = 0x23c9; // move.l A1, $
- *glue++ = a4stack >> 16;
- *glue++ = a4stack & 0xffff;
- *glue++ = 0x4e75; // rts
-
- return proc;
- }
- #endif
-
- #ifndef WIN32
- QDGlobals *REALQDGlobals(void)
- {
- static QDGlobals *(*pREALQDGlobals)(void);
- if (!pREALQDGlobals)
- pREALQDGlobals = (QDGlobals *(*)(void)) CallResolver("REALQDGlobals");
- return pREALQDGlobals();
- }
-
- int REALallocateMenuID(void)
- {
- static int (*pREALallocateMenuID)(void);
- if (!pREALallocateMenuID)
- pREALallocateMenuID = (int (*)(void)) CallResolver("allocateMenuID");
- return pREALallocateMenuID();
- }
-
- void REALreleaseMenuID(int id)
- {
- static int (*pREALreleaseMenuID)(int);
- if (!pREALreleaseMenuID)
- pREALreleaseMenuID = (int (*)(int)) CallResolver("releaseMenuID");
- pREALreleaseMenuID(id);
- }
- #endif
-
- void GraphicsDrawLine(Ptr graphicsObject, int x1, int y1, int x2, int y2)
- {
- static void (*pDrawLine)(Ptr graphicsObject, int x1, int y1, int x2, int y2);
- if (!pDrawLine)
- pDrawLine = (void (*)(Ptr graphicsObject, int x1, int y1, int x2, int y2)) CallResolver("RuntimeGraphicsDrawLine");
- pDrawLine(graphicsObject, x1, y1, x2, y2);
- }
-
- void REALRegisterMethod(REALmethodDefinition *defn)
- {
- static void (*pRuntimeRegisterMethod)(REALmethodDefinition *defn);
- if (!pRuntimeRegisterMethod)
- pRuntimeRegisterMethod = (void (*)(REALmethodDefinition *)) CallResolver("PluginRegisterMethod");
-
- #ifdef USECALLSHELL
- defn->function = buildEnvironmentShell(defn->function);
- defn->setterFunction = buildEnvironmentShell(defn->setterFunction);
- #endif
-
- pRuntimeRegisterMethod(defn);
- }
-
- void REALRegisterControl(REALcontrol *defn)
- {
- static void (*pRuntimeRegisterControl)(REALcontrol *defn);
- if (!pRuntimeRegisterControl)
- pRuntimeRegisterControl = (void (*)(REALcontrol *)) CallResolver("PluginRegisterControl");
-
- #ifdef USECALLSHELL
- int i;
- for (i = 0; i < defn->propertyCount; i++)
- {
- defn->properties[i].getter = buildEnvironmentShell(defn->properties[i].getter);
- defn->properties[i].setter = buildEnvironmentShell(defn->properties[i].setter);
- }
- for (i = 0; i < defn->methodCount; i++)
- {
- defn->methods[i].function = buildEnvironmentShell(defn->methods[i].function);
- defn->methods[i].setterFunction = buildEnvironmentShell(defn->methods[i].setterFunction);
- }
- defn->behaviour->constructorFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->constructorFunction);
- defn->behaviour->destructorFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->destructorFunction);
- defn->behaviour->redrawFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->redrawFunction);
- defn->behaviour->clickFunction = (Boolean (*)(REALcontrolInstance, int, int, int)) buildEnvironmentShell(defn->behaviour->clickFunction);
- defn->behaviour->mouseDragFunction = (void (*)(REALcontrolInstance, int, int)) buildEnvironmentShell(defn->behaviour->mouseDragFunction);
- defn->behaviour->mouseUpFunction = (void (*)(REALcontrolInstance, int, int)) buildEnvironmentShell(defn->behaviour->mouseUpFunction);
- defn->behaviour->gainedFocusFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->gainedFocusFunction);
- defn->behaviour->lostFocusFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->lostFocusFunction);
- defn->behaviour->keyDownFunction = buildEnvironmentShell(defn->behaviour->keyDownFunction);
- defn->behaviour->openFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->openFunction);
- defn->behaviour->closeFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->closeFunction);
- defn->behaviour->backgroundIdleFunction = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->backgroundIdleFunction);
- defn->behaviour->drawOffscreenFunction = (void (*)(REALcontrolInstance, REALgraphics)) buildEnvironmentShell(defn->behaviour->drawOffscreenFunction);
- defn->behaviour->setSpecialBackground = (void (*)(REALcontrolInstance)) buildEnvironmentShell(defn->behaviour->setSpecialBackground);
- #endif
-
- pRuntimeRegisterControl(defn);
- }
-
- void REALRegisterClassExtension(REALclassDefinition *defn)
- {
- static void (*pRegisterClassExtension)(REALclassDefinition *defn);
- if (!pRegisterClassExtension)
- pRegisterClassExtension = (void (*)(REALclassDefinition *)) CallResolver("PluginRegisterClassExtension");
-
- #ifdef USECALLSHELL
- int i;
- for (i = 0; i < defn->propertyCount; i++)
- {
- defn->properties[i].getter = buildEnvironmentShell(defn->properties[i].getter);
- defn->properties[i].setter = buildEnvironmentShell(defn->properties[i].setter);
- }
- for (i = 0; i < defn->methodCount; i++)
- {
- defn->methods[i].function = buildEnvironmentShell(defn->methods[i].function);
- defn->methods[i].setterFunction = buildEnvironmentShell(defn->methods[i].setterFunction);
- }
- #endif
-
- if (pRegisterClassExtension)
- pRegisterClassExtension(defn);
- }
-
- void REALRegisterDBEngine(REALdbEngineDefinition *defn)
- {
- static void (*pRegisterDatabaseEngine)(REALdbEngineDefinition *defn);
- if (!pRegisterDatabaseEngine)
- pRegisterDatabaseEngine = (void (*)(REALdbEngineDefinition *)) CallResolver("PluginRegisterDBEngine");
-
- #ifdef USECALLSHELL
- defn->closeDatabase = (void (*)(dbDatabase *)) buildEnvironmentShell(defn->closeDatabase);
- defn->getTableSchemaCursor = (REALdbCursor (*)(dbDatabase *)) buildEnvironmentShell(defn->getTableSchemaCursor);
- defn->getFieldSchemaCursor = (REALdbCursor (*)(dbDatabase *, REALstring)) buildEnvironmentShell(defn->getFieldSchemaCursor);
- defn->directSQLSelect = (REALdbCursor (*)(dbDatabase *, REALstring)) buildEnvironmentShell(defn->directSQLSelect);
- defn->directSQLExecute = (void (*)(dbDatabase *, REALstring)) buildEnvironmentShell(defn->directSQLExecute);
- defn->createTable = (void (*)(dbDatabase *, REALstring, REALnewColumn *, unsigned char *, int)) buildEnvironmentShell(defn->createTable);
- defn->addTableRecord = (void (*)(dbDatabase *, REALstring, REALcolumnValue *)) buildEnvironmentShell(defn->addTableRecord);
- defn->getTableCursor = (REALdbCursor (*)(dbDatabase *, REALstring, REALgetColumn *, REALcolumnConstraints *)) buildEnvironmentShell(defn->getTableCursor);
- #endif
-
- if (pRegisterDatabaseEngine)
- pRegisterDatabaseEngine(defn);
- }
-
- void REALRegisterDBTable(REALdbTableDefinition *defn)
- {
- static void (*pRegisterDBTable)(REALdbTableDefinition *defn);
- if (!pRegisterDBTable)
- pRegisterDBTable = (void (*)(REALdbTableDefinition *)) CallResolver("PluginRegisterDBTable");
- if (pRegisterDBTable)
- pRegisterDBTable(defn);
- }
-
- void REALRegisterDBCursor(REALdbCursorDefinition *defn)
- {
- static void (*pRegisterDBCursor)(REALdbCursorDefinition *defn);
- if (!pRegisterDBCursor)
- pRegisterDBCursor = (void (*)(REALdbCursorDefinition *)) CallResolver("PluginRegisterDBCursor");
-
- #ifdef USECALLSHELL
- defn->closeCursor = (void (*)(dbCursor *)) buildEnvironmentShell(defn->closeCursor);
- defn->cursorColumnCount = (int (*)(dbCursor *)) buildEnvironmentShell(defn->cursorColumnCount);
- defn->cursorColumnName = (REALstring (*)(dbCursor *, int column)) buildEnvironmentShell(defn->cursorColumnName);
- defn->cursorRowCount = (int (*)(dbCursor *)) buildEnvironmentShell(defn->cursorRowCount);
- defn->cursorColumnValue = (void (*)(dbCursor *, int, Ptr *, dbFieldType *, int *)) buildEnvironmentShell(defn->cursorColumnValue);
- defn->cursorReleaseValue = (void (*)(dbCursor *)) buildEnvironmentShell(defn->cursorReleaseValue);
- defn->cursorNextRow = (Boolean (*)(dbCursor *)) buildEnvironmentShell(defn->cursorNextRow);
- defn->cursorDelete = (void (*)(dbCursor *)) buildEnvironmentShell(defn->cursorDelete);
- defn->cursorDeleteAll = (void (*)(dbCursor *)) buildEnvironmentShell(defn->cursorDeleteAll);
- #endif
-
- if (pRegisterDBCursor)
- pRegisterDBCursor(defn);
- }
-
- void REALRegisterClass(REALclassDefinition *defn)
- {
- static void (*pRegisterClass)(REALclassDefinition *defn);
- if (!pRegisterClass)
- pRegisterClass = (void (*)(REALclassDefinition *)) CallResolver("PluginRegisterClass");
-
- #ifdef USECALLSHELL
- int i;
- defn->constructor = buildEnvironmentShell(defn->constructor);
- defn->destructor = buildEnvironmentShell(defn->destructor);
- for (i = 0; i < defn->propertyCount; i++)
- {
- defn->properties[i].getter = buildEnvironmentShell(defn->properties[i].getter);
- defn->properties[i].setter = buildEnvironmentShell(defn->properties[i].setter);
- }
- for (i = 0; i < defn->methodCount; i++)
- {
- defn->methods[i].function = buildEnvironmentShell(defn->methods[i].function);
- defn->methods[i].setterFunction = buildEnvironmentShell(defn->methods[i].setterFunction);
- }
- for (i = 0; i < defn->eventInstanceCount; i++)
- defn->eventInstances[i].implementation = buildEnvironmentShell(defn->eventInstances[i].implementation);
- #endif
-
- if (pRegisterClass)
- pRegisterClass(defn);
- }
-
- const char *REALCString(REALstring str)
- {
- static const char *(*pStringGetCString)(REALstring str);
- if (!pStringGetCString)
- pStringGetCString = (const char *(*)(REALstring)) CallResolver("StringGetCString");
- return (const char *) pStringGetCString(str);
- }
-
- const unsigned char *REALPString(REALstring str)
- {
- static const unsigned char *(*pStringGetPString)(REALstring str);
- if (!pStringGetPString)
- pStringGetPString = (const unsigned char *(*)(REALstring)) CallResolver("StringGetPString");
- return (const unsigned char *) pStringGetPString(str);
- }
-
- REALstring REALBuildString(const char *contents, int length)
- {
- static REALstring (*pREALBuildString)(const char *contents, int length);
- if (!pREALBuildString)
- pREALBuildString = (REALstring (*)(const char *, int)) CallResolver("REALBuildString");
- return pREALBuildString(contents, length);
- }
-
- void REALLockObject(REALobject obj)
- {
- static void (*pREALLockObject)(REALobject);
- if (!pREALLockObject)
- pREALLockObject = (void (*)(REALobject)) CallResolver("REALLockObject");
- pREALLockObject(obj);
- }
-
- void REALUnlockObject(REALobject obj)
- {
- static void (*pREALUnlockObject)(REALobject);
- if (!pREALUnlockObject)
- pREALUnlockObject = (void (*)(REALobject)) CallResolver("REALUnlockObject");
- pREALUnlockObject(obj);
- }
-
- void REALLockString(REALstring str)
- {
- static void (*pREALLockString)(REALstring);
- if (!pREALLockString)
- pREALLockString = (void (*)(REALstring)) CallResolver("REALLockString");
- pREALLockString(str);
- }
-
- void REALUnlockString(REALstring str)
- {
- static void (*pREALUnlockString)(REALstring);
- if (!pREALUnlockString)
- pREALUnlockString = (void (*)(REALstring)) CallResolver("REALUnlockString");
- pREALUnlockString(str);
- }
-
- REALproc REALInterfaceRoutine(REALobject obj, const char *interfaceName, const char *methodName)
- {
- static REALproc (*pInterfaceRoutine)(REALobject, const char *, const char *);
- if (!pInterfaceRoutine)
- pInterfaceRoutine = (REALproc (*)(REALobject, const char *, const char *)) CallResolver("GetInterfaceRoutine");
- return pInterfaceRoutine(obj, interfaceName, methodName);
- }
- #ifndef WIN32
- REALpicture REALBuildPictureFromPicHandle(PicHandle pic, Boolean bPassOwnership)
- {
- static REALpicture (*pREALBuildPictureFromPicHandle)(PicHandle, Boolean);
- if (!pREALBuildPictureFromPicHandle)
- pREALBuildPictureFromPicHandle = (REALpicture (*)(PicHandle, Boolean)) CallResolver("REALBuildPictureFromPicHandle");
- return pREALBuildPictureFromPicHandle(pic, bPassOwnership);
- }
-
- REALpicture REALBuildPictureFromGWorld(GWorldPtr world, Boolean bPassOwnership)
- {
- static REALpicture (*pREALBuildPictureFromGWorld)(GWorldPtr, Boolean);
- if (!pREALBuildPictureFromGWorld)
- pREALBuildPictureFromGWorld = (REALpicture (*)(GWorldPtr, Boolean)) CallResolver("REALBuildPictureFromGWorld");
- return pREALBuildPictureFromGWorld(world, bPassOwnership);
- }
- #endif
-
- REALpicture REALBuildPictureFromPictureDescription(REALpictureDescription *description, Boolean bPassOwnership)
- {
- static REALpicture (*pREALBuildPictureFromPictureDescription)(REALpictureDescription *, Boolean);
- if (!pREALBuildPictureFromPictureDescription)
- pREALBuildPictureFromPictureDescription = (REALpicture (*)(REALpictureDescription *, Boolean)) CallResolver("REALBuildPictureFromPictureDescription");
- return pREALBuildPictureFromPictureDescription(description, bPassOwnership);
- }
-
- void REALLockPictureDescription(REALpicture pic, REALpictureDescription *description)
- {
- static void (*pLockPictureDescription)(REALpicture, REALpictureDescription *);
- if (!pLockPictureDescription)
- pLockPictureDescription = (void (*)(REALpicture, REALpictureDescription *)) CallResolver("lockPictureDescription");
- pLockPictureDescription(pic, description);
- }
-
- void REALUnlockPictureDescription(REALpicture pic)
- {
- static void (*pUnlockPictureDescription)(REALpicture);
- if (!pUnlockPictureDescription)
- pUnlockPictureDescription = (void (*)(REALpicture)) CallResolver("unlockPictureDescription");
- pUnlockPictureDescription(pic);
- }
-
- void REALPictureClearCache(REALpicture pic)
- {
- static void (*pPictureClearCache)(REALpicture);
- if (!pPictureClearCache)
- pPictureClearCache = (void (*)(REALpicture)) CallResolver("REALPictureClearCache");
- pPictureClearCache(pic);
- }
-
- #ifdef WIN32
- void REALDrawPicturePrimitive(HDC hDC, REALpicture pic, const Rect *rBounds, int bTransparent)
- {
- static void (*pDrawPicturePrimitive)(HDC, REALpicture, const Rect *, int);
- if (!pDrawPicturePrimitive)
- pDrawPicturePrimitive = (void (*)(HDC, REALpicture, const Rect *, int)) CallResolver("drawPicturePrimitive");
- pDrawPicturePrimitive(hDC, pic, rBounds, bTransparent);
- }
- #else
- void REALDrawPicturePrimitive(REALpicture pic, const Rect *rBounds, int bTransparent)
- {
- static void (*pDrawPicturePrimitive)(REALpicture, const Rect *, int);
- if (!pDrawPicturePrimitive)
- pDrawPicturePrimitive = (void (*)(REALpicture, const Rect *, int)) CallResolver("drawPicturePrimitive");
- pDrawPicturePrimitive(pic, rBounds, bTransparent);
- }
- #endif
-
- REALdbCursor REALdbCursorFromDBCursor(dbCursor *cursor, REALdbCursorDefinition *defn)
- {
- static REALdbCursor (*pREALdbCursorFromDBCursor)(dbCursor *, REALdbCursorDefinition *);
- if (!pREALdbCursorFromDBCursor)
- pREALdbCursorFromDBCursor = (REALdbCursor (*)(dbCursor *, REALdbCursorDefinition *)) CallResolver("REALdbCursorFromDBCursor");
- return pREALdbCursorFromDBCursor(cursor, defn);
- }
-
- REALdbDatabase REALdbDatabaseFromDBDatabase(dbDatabase *database, REALdbEngineDefinition *defn)
- {
- static REALdbDatabase (*pREALdbDatabaseFromDBDatabase)(dbDatabase *, REALdbEngineDefinition *);
- if (!pREALdbDatabaseFromDBDatabase)
- pREALdbDatabaseFromDBDatabase = (REALdbDatabase (*)(dbDatabase *, REALdbEngineDefinition *)) CallResolver("REALdbDatabaseFromDBDatabase");
- return pREALdbDatabaseFromDBDatabase(database, defn);
- }
-
- void *REALGetEventInstance(REALcontrolInstance instance, REALevent *event)
- {
- static void *(*pGetEventInstance)(REALcontrolInstance instance, int builtHook);
- #ifdef powerc
- if (!pGetEventInstance)
- pGetEventInstance = (void *(*)(REALcontrolInstance,int)) CallResolver("GetEventInstancePPC");
- return (void *) pGetEventInstance(instance, event->forSystemUse);
- #else
- if (!pGetEventInstance)
- pGetEventInstance = (void *(*)(REALcontrolInstance,int)) CallResolver("GetEventInstance");
- return (void *) pGetEventInstance(instance, event->forSystemUse);
- #endif
- }
-
- #ifndef WIN32
- void REALRegisterEventFilter(void (*callback)(EventRecord *event, long param), long param)
- {
- static void (*pRegisterEventFilter)(void (*callback)(EventRecord *, long), long param);
- #ifdef powerc
- if (!pRegisterEventFilter)
- pRegisterEventFilter = (void (*)(void (*)(EventRecord *, long), long)) CallResolver("PluginRegisterEventFilterPPC");
- #else
- if (!pRegisterEventFilter)
- pRegisterEventFilter = (void (*)(void (*)(EventRecord *, long), long)) CallResolver("PluginRegisterEventFilter");
- #endif
- pRegisterEventFilter(callback, param);
- }
- #endif
-
- void *REALGetControlData(REALcontrolInstance instance, REALcontrol *defn)
- {
- return ((Ptr) instance) + defn->forSystemUse;
- }
-
- void *REALGetClassData(REALobject instance, REALclassDefinition *defn)
- {
- return ((Ptr) instance) + defn->forSystemUse;
- }
-
- void REALGetControlBounds(REALcontrolInstance instance, Rect *rBounds)
- {
- static void (*pGetControlBounds)(REALcontrolInstance, Rect *);
- if (!pGetControlBounds)
- pGetControlBounds = (void (*)(REALcontrolInstance, Rect *)) CallResolver("GetControlBounds");
- pGetControlBounds(instance, rBounds);
- }
-
- Boolean REALGetControlVisible(REALcontrolInstance instance)
- {
- static int (*pGetControlVisible)(REALcontrolInstance);
- if (!pGetControlVisible)
- pGetControlVisible = (int (*)(REALcontrolInstance)) CallResolver("GetControlVisible");
- return pGetControlVisible(instance);
- }
-
- Boolean REALGetControlEnabled(REALcontrolInstance instance)
- {
- static int (*pGetControlEnabled)(REALcontrolInstance, long);
- if (!pGetControlEnabled)
- pGetControlEnabled = (int (*)(REALcontrolInstance, long)) CallResolver("controlEnabledGetter");
- return pGetControlEnabled(instance, 0);
- }
-
- void REALSetControlVisible(REALcontrolInstance instance, Boolean visible)
- {
- static void (*pSetControlVisible)(REALcontrolInstance, int);
- if (!pSetControlVisible)
- pSetControlVisible = (void (*)(REALcontrolInstance, int)) CallResolver("SetControlVisible");
- pSetControlVisible(instance, visible);
- }
-
- REALgraphics REALGetControlGraphics(REALcontrolInstance instance)
- {
- static REALgraphics (*pREALGetControlGraphics)(REALcontrolInstance);
- if (!pREALGetControlGraphics)
- pREALGetControlGraphics = (REALgraphics (*)(REALcontrolInstance)) CallResolver("REALGetControlGraphics");
- return pREALGetControlGraphics(instance);
- }
-
- #ifdef WIN32
- REALfolderItem REALFolderItemFromPath(const char *path)
- {
- static REALfolderItem (*pFolderItemFromPath)(const char *);
- if (!pFolderItemFromPath)
- pFolderItemFromPath = (REALfolderItem (*)(const char *)) CallResolver("FolderItemFromPath");
- return pFolderItemFromPath(path);
- }
- #else
- REALfolderItem REALFolderItemFromFSSpec(const FSSpec *spec)
- {
- static REALfolderItem (*pFolderItemFromFSSpec)(const FSSpec *);
- if (!pFolderItemFromFSSpec)
- pFolderItemFromFSSpec = (REALfolderItem (*)(const FSSpec *)) CallResolver("FolderItemFromFSSpec");
- return pFolderItemFromFSSpec(spec);
- }
-
- Boolean REALFSSpecFromFolderItem(FSSpec *spec, REALfolderItem item)
- {
- static Boolean (*pREALFSSpecFromFolderItem)(FSSpec *, REALfolderItem);
- if (!pREALFSSpecFromFolderItem)
- pREALFSSpecFromFolderItem = (Boolean (*)(FSSpec *, REALfolderItem)) CallResolver("REALFSSpecFromFolderItem");
- return pREALFSSpecFromFolderItem(spec, item);
- }
- #endif
-
- REALstring REALpathFromFolderItem(REALfolderItem item)
- {
- static REALstring (*pREALpathFromFolderItem)(REALfolderItem);
- if (!pREALpathFromFolderItem)
- pREALpathFromFolderItem = (REALstring (*)(REALfolderItem)) CallResolver("REALpathFromFolderItem");
- return pREALpathFromFolderItem(item);
- }
-
- #ifdef WIN32
- HDC REALGraphicsDC(REALgraphics context)
- {
- static HDC (*pREALGraphicsDC)(REALgraphics);
- if (!pREALGraphicsDC)
- pREALGraphicsDC = (HDC (*)(REALgraphics)) CallResolver("REALGraphicsDC");
- return pREALGraphicsDC(context);
- }
- #else
- void REALSelectGraphics(REALgraphics context)
- {
- static void (*pSelectGraphics)(REALgraphics);
- if (!pSelectGraphics)
- pSelectGraphics = (void (*)(REALgraphics)) CallResolver("SelectGraphics");
- pSelectGraphics(context);
- }
-
- void REALGraphicsDrawOffscreenMacControl(REALgraphics context, ControlHandle mh)
- {
- static void (*pDrawOffscreenMacControl)(REALgraphics, ControlHandle);
- if (!pDrawOffscreenMacControl)
- pDrawOffscreenMacControl = (void (*)(REALgraphics, ControlHandle)) CallResolver("DrawOffscreenMacControl");
- pDrawOffscreenMacControl(context, mh);
- }
- #endif
- void REALInvalidateControl(REALcontrolInstance instance)
- {
- static void (*pInvalidateControl)(REALcontrolInstance);
- if (!pInvalidateControl)
- pInvalidateControl = (void (*)(REALcontrolInstance)) CallResolver("REALInvalidateControl");
- pInvalidateControl(instance);
- }
-
- void REALInvalidateControlRect(REALcontrolInstance instance, int left, int top, int right, int bottom)
- {
- static void (*pInvalidateControlRect)(REALcontrolInstance, int, int ,int, int);
- if (!pInvalidateControlRect)
- pInvalidateControlRect = (void (*)(REALcontrolInstance, int, int ,int, int)) CallResolver("REALInvalidateControlRect");
- pInvalidateControlRect(instance, left, top, right, bottom);
- }
-
- void REALSetSpecialBackground(REALcontrolInstance instance)
- {
- static void (*pREALSetSpecialBackground)(REALcontrolInstance);
- if (!pREALSetSpecialBackground)
- pREALSetSpecialBackground = (void (*)(REALcontrolInstance)) CallResolver("REALSetSpecialBackground");
- pREALSetSpecialBackground(instance);
- }
-
- REALwindow REALGetControlWindow(REALcontrolInstance instance)
- {
- static REALwindow (*pGetControlWindow)(REALcontrolInstance);
- if (!pGetControlWindow)
- pGetControlWindow = (REALwindow (*)(REALcontrolInstance)) CallResolver("getControlWindow");
- return pGetControlWindow(instance);
- }
- #ifndef WIN32
- REALsound REALBuildSoundFromHandle(Handle sound, Boolean bPassOwnership)
- {
- static REALsound (*pREALBuildSoundFromHandle)(Handle, Boolean);
- if (!pREALBuildSoundFromHandle)
- pREALBuildSoundFromHandle = (REALsound (*)(Handle, Boolean)) CallResolver("REALBuildSoundFromHandle");
- return pREALBuildSoundFromHandle(sound, bPassOwnership);
- }
-
- REALappleEvent REALBuildAppleEvent(const AppleEvent *event, Boolean bPassOwnership)
- {
- static REALappleEvent (*pREALBuildAppleEvent)(const AppleEvent *);
- if (!pREALBuildAppleEvent)
- pREALBuildAppleEvent = (REALappleEvent (*)(const AppleEvent *)) CallResolver("REALBuildAppleEvent");
- return pREALBuildAppleEvent(event);
- }
-
- REALappleEvent REALBuildAEDescList(const AppleEvent *event, Boolean bPassOwnership)
- {
- static REALappleEvent (*pREALBuildAEDescList)(const AppleEvent *);
- if (!pREALBuildAEDescList)
- pREALBuildAEDescList = (REALappleEvent (*)(const AppleEvent *)) CallResolver("REALBuildAEDescList");
- return pREALBuildAEDescList(event);
- }
-
- REALappleEvent REALBuildAEObjSpecifier(const AppleEvent *event, Boolean bPassOwnership)
- {
- static REALappleEvent (*pREALBuildAEObjSpecifier)(const AppleEvent *);
- if (!pREALBuildAEObjSpecifier)
- pREALBuildAEObjSpecifier = (REALappleEvent (*)(const AppleEvent *)) CallResolver("REALBuildAEObjSpecifier");
- return pREALBuildAEObjSpecifier(event);
- }
-
- AppleEvent *REALAccessAppleEvent(REALappleEvent event)
- {
- static AppleEvent *(*pREALAccessAppleEvent)(REALappleEvent);
- if (!pREALAccessAppleEvent)
- pREALAccessAppleEvent = (AppleEvent *(*)(REALappleEvent)) CallResolver("REALAccessAppleEvent");
- return pREALAccessAppleEvent(event);
- }
-
- AppleEvent *REALAccessAppleEventReply(REALappleEvent event)
- {
- static AppleEvent *(*pREALAccessAppleEventReply)(REALappleEvent);
- if (!pREALAccessAppleEventReply)
- pREALAccessAppleEventReply = (AppleEvent *(*)(REALappleEvent)) CallResolver("REALAccessAppleEventReply");
- return pREALAccessAppleEventReply(event);
- }
-
- WindowPtr REALGetWindowHandle(REALwindow window)
- {
- static WindowPtr (*pREALGetWindowHandle)(REALwindow);
- if (!pREALGetWindowHandle)
- pREALGetWindowHandle = (WindowPtr (*)(REALwindow)) CallResolver("REALGetWindowHandle");
- return pREALGetWindowHandle(window);
- }
-
- ControlHandle REALGetControlHandle(REALcontrolInstance control)
- {
- static ControlHandle (*pREALGetControlHandle)(REALcontrolInstance);
- if (!pREALGetControlHandle)
- pREALGetControlHandle = (ControlHandle (*)(REALcontrolInstance)) CallResolver("REALGetControlHandle");
- return pREALGetControlHandle(control);
- }
-
- MenuHandle REALGetPopupMenuHandle(REALpopupMenu popup)
- {
- static MenuHandle (*pREALGetPopupMenuHandle)(REALpopupMenu);
- if (!pREALGetPopupMenuHandle)
- pREALGetPopupMenuHandle = (MenuHandle (*)(REALpopupMenu)) CallResolver("REALGetPopupMenuHandle");
- return pREALGetPopupMenuHandle(popup);
- }
-
- MovieController REALgetMoviePlayerController(REALmoviePlayer instance)
- {
- static MovieController (*pREALgetMoviePlayerController)(REALmoviePlayer);
- if (!pREALgetMoviePlayerController)
- pREALgetMoviePlayerController = (MovieController (*)(REALmoviePlayer)) CallResolver("getMoviePlayerController");
- return pREALgetMoviePlayerController(instance);
- }
-
- Movie REALgetMovieMovie(REALmovie instance)
- {
- static Movie (*pREALgetMovieMovie)(REALmovie);
- if (!pREALgetMovieMovie)
- pREALgetMovieMovie = (Movie (*)(REALmovie)) CallResolver("getMovieMovie");
- return pREALgetMovieMovie(instance);
- }
-
- REALmovie REALbuildMovie(Movie movie, short resRefNum, Boolean bNew)
- {
- static REALmovie (*pREALbuildMovie)(Movie, int, int);
- if (!pREALbuildMovie)
- pREALbuildMovie = (REALmovie (*)(Movie, int, int)) CallResolver("buildMovie");
- return pREALbuildMovie(movie, resRefNum, bNew);
- }
-
- void REALmarkMovieDirty(REALmovie movie)
- {
- static void (*pREALmarkMovieDirty)(REALmovie);
- if (!pREALmarkMovieDirty)
- pREALmarkMovieDirty = (void (*)(REALmovie)) CallResolver("markMovieDirty");
- pREALmarkMovieDirty(movie);
- }
-
- int REALenterMovies(void)
- {
- static int (*pREALenterMovies)(void);
- if (!pREALenterMovies)
- pREALenterMovies = (int (*)(void)) CallResolver("REALenterMovies");
- return pREALenterMovies();
- }
- #endif
-
- REALobject REALnewInstance(const char *className)
- {
- static REALobject (*pREALnewInstance)(const char *);
- if (!pREALnewInstance)
- pREALnewInstance = (REALobject (*)(const char *)) CallResolver("PluginNewInstance");
- return pREALnewInstance(className);
- }
-
- void REALSocketConnect(REALsocket socket, REALstring address, int port)
- {
- static void (*pSocketConnect)(REALsocket, REALstring, int);
- if (!pSocketConnect)
- pSocketConnect = (void (*)(REALsocket, REALstring, int)) CallResolver("SocketDirectConnect");
- pSocketConnect(socket, address, port);
- }
-
- void REALSocketClose(REALsocket socket)
- {
- static void (*pSocketClose)(REALsocket socket);
- if (!pSocketClose)
- pSocketClose = (void (*)(REALsocket)) CallResolver("socketClose");
- pSocketClose(socket);
- }
-
- REALstring REALSocketReadAll(REALsocket socket)
- {
- static REALstring (*pSocketReadAll)(REALsocket);
- if (!pSocketReadAll)
- pSocketReadAll = (REALstring (*)(REALsocket)) CallResolver("SocketReadAll");
- return pSocketReadAll(socket);
- }
-
- REALstring REALSocketRead(REALsocket socket, int count)
- {
- static REALstring (*pSocketRead)(REALsocket, int);
- if (!pSocketRead)
- pSocketRead = (REALstring (*)(REALsocket, int)) CallResolver("socketRead");
- return pSocketRead(socket, count);
- }
-
- void REALSocketWrite(REALsocket socket, REALstring data)
- {
- static void (*pSocketClose)(REALsocket, REALstring);
- if (!pSocketClose)
- pSocketClose = (void (*)(REALsocket, REALstring)) CallResolver("SocketWrite");
- pSocketClose(socket, data);
- }
-
- int REALSocketLastErrorCode(REALsocket socket)
- {
- static int (*pSocketLastErrorCode)(REALsocket, int);
- if (!pSocketLastErrorCode)
- pSocketLastErrorCode = (int (*)(REALsocket, int)) CallResolver("socketLastErrorCode");
- return pSocketLastErrorCode(socket, 0);
- }
-
- REALstring REALSocketLookahead(REALsocket socket)
- {
- static REALstring (*pSocketLookahead)(REALsocket, int);
- if (!pSocketLookahead)
- pSocketLookahead = (REALstring (*)(REALsocket, int)) CallResolver("socketLookahead");
- return pSocketLookahead(socket, 0);
- }
-
- REALstring REALSocketLocalAddressGetter(REALsocket socket)
- {
- static REALstring (*pSocketLocalAddressGetter)(REALsocket, int);
- if (!pSocketLocalAddressGetter)
- pSocketLocalAddressGetter = (REALstring (*)(REALsocket, int)) CallResolver("socketLookahead");
- return pSocketLocalAddressGetter(socket, 0);
- }
-
- void REALSocketPoll(REALsocket socket)
- {
- static void (*pSocketPoll)(REALsocket);
- if (!pSocketPoll)
- pSocketPoll = (void (*)(REALsocket)) CallResolver("socketPoll");
- pSocketPoll(socket);
- }
-
- int REALSocketGetEvents(REALsocket socket)
- {
- static int (*pSocketGetEvents)(REALsocket, int);
- if (!pSocketGetEvents)
- pSocketGetEvents = (int (*)(REALsocket, int)) CallResolver("socketGetEvents");
- return pSocketGetEvents(socket, 0);
- }
-
- void REALRegisterDataSourceInterface(const char *szMenuName, void (*proc)(void))
- {
- static void (*pRegisterDataSourceInterface)(const char *, void (*proc)(void));
- if (!pRegisterDataSourceInterface)
- pRegisterDataSourceInterface = (void (*)(const char *, void (*proc)(void))) CallResolver("RegisterDataSourceInterface");
- if (pRegisterDataSourceInterface)
- pRegisterDataSourceInterface(szMenuName, proc);
- }
-
- void REALRegisterDataSource(const char *szDatasourceName, REALdbDatabase (*proc)(Ptr data, int dataLen))
- {
- static void (*pRegisterDataSource)(const char *, REALdbDatabase (*)(Ptr data, int dataLen));
- if (!pRegisterDataSource)
- pRegisterDataSource = (void (*)(const char *, REALdbDatabase (*)(Ptr data, int dataLen))) CallResolver("RegisterDataSource");
- pRegisterDataSource(szDatasourceName, proc);
- }
-
- void REALDesignAddDataSource(const char *baseName, const char *szDataSourceName, Ptr data, int dataLen)
- {
- static void (*pDesignAddDataSource)(const char *, const char *, Ptr, int);
- if (!pDesignAddDataSource)
- pDesignAddDataSource = (void (*)(const char *, const char *, Ptr, int)) CallResolver("DesignAddDataSource");
- if (pDesignAddDataSource)
- pDesignAddDataSource(baseName, szDataSourceName, data, dataLen);
- }
-
- #ifdef WIN32
-
- extern "C" {
- void __declspec(dllexport) REALPluginMain(void *(*resolver)(const char *entryName));
- }
-
- void __declspec(dllexport) REALPluginMain(void *(*resolver)(const char *entryName))
- #else
- void main(void *(*resolver)(const char *entryName))
- #endif
- {
- // short *glue;
- // int i;
- // void (*pRegisterPluginExports)(REALexport *table);
- void (*pRegisterPluginVersion)(int version);
-
- #ifndef WIN32
- EnterCodeResource();
- #endif
- gResolver = resolver;
-
- #ifdef USECALLSHELL
- unsigned long (*getA4stack)(void);
-
- getA4stack = (unsigned long(*)(void)) resolver("getA4stackReference");
- a4stack = getA4stack();
- #else
- #ifndef WIN32
- gResolverPPC = (void *(*)(const char *)) CallUniversalProc((RoutineDescriptor *) gResolver, kCStackBased | RESULT_SIZE(SIZE_CODE(4)) | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(4)), "ResolverPPC");
- #endif
- #endif
-
- // pRegisterPluginExports = (void (*)(REALexport *)) CallResolver("RegisterPluginExports");
- // pRegisterPluginExports(pluginExports);
-
- pRegisterPluginVersion = (void (*)(int)) CallResolver("RegisterPluginVersion");
- pRegisterPluginVersion(kCurrentREALControlVersion);
-
- PluginEntry();
-
- #ifndef WIN32
- ExitCodeResource();
- #endif
- }
-
- long REALstringStruct::Length(void)
- {
- if (this)
- return mPrivateLength;
- else
- return 0;
- }
-
- const char *REALstringStruct::CString()
- {
- if (this)
- return (const char *) (mPrivateStringData + 1);
- else
- return "";
- }
-
- const unsigned char *REALstringStruct::PString()
- {
- if (this)
- return mPrivateStringData;
- else
- return "\p";
- }
-