1 #ifdef SWELL_PROVIDED_BY_APP
3 #import <Cocoa/Cocoa.h>
4 #import <objc/objc-runtime.h>
5 #define SWELL_API_DEFPARM(x)
6 #define SWELL_API_DEFINE(ret,func,parms) ret (*func) parms ;
9 // only include this file in projects that are linked to swell.dylib
11 struct SWELL_CursorResourceIndex *SWELL_curmodule_cursorresource_head;
12 struct SWELL_DialogResourceIndex *SWELL_curmodule_dialogresource_head;
13 struct SWELL_MenuResourceIndex *SWELL_curmodule_menuresource_head;
15 // define the functions
23 #undef _WDL_SWELL_H_API_DEFINED_
24 #undef SWELL_API_DEFINE
25 #define SWELL_API_DEFINE(ret, func, parms) {#func, (void **)&func },
27 #include "swell-functions.h"
31 static int dummyFunc() { return 0; }
33 class SwellAPPInitializer
38 void *(*SWELLAPI_GetFunc)(const char *name)=NULL;
40 id del = [NSApp delegate];
41 if (del && [del respondsToSelector:@selector(swellGetAPPAPIFunc)])
42 *(void **)&SWELLAPI_GetFunc = (void *)objc_msgSend(del,@selector(swellGetAPPAPIFunc));
44 if (SWELLAPI_GetFunc && SWELLAPI_GetFunc(NULL)!=(void*)0x100) SWELLAPI_GetFunc=0;
47 for (x = 0; x < sizeof(api_tab)/sizeof(api_tab[0]); x ++)
49 *api_tab[x].func=SWELLAPI_GetFunc?SWELLAPI_GetFunc(api_tab[x].name):0;
50 if (!*api_tab[x].func)
52 printf("SWELL API not found: %s\n",api_tab[x].name);
53 *api_tab[x].func = (void*)&dummyFunc;
57 ~SwellAPPInitializer()
62 SwellAPPInitializer m_swell_appAPIinit;
64 extern "C" __attribute__ ((visibility ("default"))) int SWELL_dllMain(HINSTANCE hInst, DWORD callMode, LPVOID _GetFunc)
66 // this returning 1 allows DllMain to be called, if available