-#ifdef WXMAKINGDLL
- if ( initBlock != NULL ) {
- const CFragInitBlock *theInitBlock = (const CFragInitBlock *)initBlock;
- FSSpec *fileSpec = NULL;
-
- if (theInitBlock->fragLocator.where == kDataForkCFragLocator) {
- fileSpec = theInitBlock->fragLocator.u.onDisk.fileSpec;
- }
- else if (theInitBlock->fragLocator.where == kResourceCFragLocator) {
- fileSpec = theInitBlock->fragLocator.u.inSegs.fileSpec;
- }
-
- if (fileSpec != NULL) {
- gSharedLibraryResource = FSpOpenResFile(fileSpec, fsRdPerm);
- }
- }
- else {
-#ifdef __DARWIN__
- // Open the shared library resource file if it is not yet open
- NSSymbol theSymbol;
- NSModule theModule;
- const char *theLibPath;
-
- gSharedLibraryBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.wxwindows.wxWindows"));
- if (gSharedLibraryBundle != NULL) {
- // wxWindows has been bundled into a framework
- // load the framework resources
-
- gSharedLibraryResource = CFBundleOpenBundleResourceMap(gSharedLibraryBundle);
- }
- else {
- // wxWindows is a simple dynamic shared library
- // load the resources from the data fork of a separate resource file
- char *theResPath;
- char *theName;
- char *theExt;
- FSRef theResRef;
- OSErr theErr = noErr;
-
- // get the library path
- theSymbol = NSLookupAndBindSymbol("_gSharedLibraryResource");
- theModule = NSModuleForSymbol(theSymbol);
- theLibPath = NSLibraryNameForModule(theModule);
-
- // if we call wxLogDebug from here then, as wxTheApp hasn't been
- // created yet when we're called from wxApp::Initialize(), wxLog
- // is going to create a default stderr-based log target instead of
- // the expected normal GUI one -- don't do it, if we really want
- // to see this message just use fprintf() here
-#if 0
- wxLogDebug( wxT("wxMac library installation name is '%s'"),
- theLibPath );
-#endif
-
- // allocate copy to replace .dylib.* extension with .rsrc
- theResPath = strdup(theLibPath);
- if (theResPath != NULL) {
- theName = strrchr(theResPath, '/');
- if (theName == NULL) {
- // no directory elements in path
- theName = theResPath;
- }
- // find ".dylib" shared library extension
- theExt = strstr(theName, ".dylib");
- // overwrite extension with ".rsrc"
- strcpy(theExt, ".rsrc");
-
-#if 0
- wxLogDebug( wxT("wxMac resources file name is '%s'"),
- theResPath );
-#endif
-
- theErr = FSPathMakeRef((UInt8 *) theResPath, &theResRef, false);
- if (theErr != noErr) {
- // try in current directory (using name only)
- theErr = FSPathMakeRef((UInt8 *) theName, &theResRef, false);
- }
-
- // open the resource file
- if (theErr == noErr) {
- theErr = FSOpenResourceFile( &theResRef, 0, NULL, fsRdPerm,
- &gSharedLibraryResource);
- }
- if (theErr != noErr) {
-#ifdef __WXDEBUG__
- fprintf(stderr,
- wxT("unable to open wxMac resource file '%s'\n"),
- theResPath );
-#endif // __WXDEBUG__
- }
-
- // free duplicated resource file path
- free(theResPath);
- }
- }
-#endif /* __DARWIN__ */
- }
-#endif /* WXMAKINGDLL */
-}
-
-void wxStAppResource::CloseSharedLibraryResource()
-{
-#ifdef WXMAKINGDLL
- // Close the shared library resource file
- if (gSharedLibraryResource != kResFileNotOpened) {
-#ifdef __DARWIN__
- if (gSharedLibraryBundle != NULL) {
- CFBundleCloseBundleResourceMap(gSharedLibraryBundle,
- gSharedLibraryResource);
- gSharedLibraryBundle = NULL;
- }
- else
-#endif /* __DARWIN__ */
- {
- CloseResFile(gSharedLibraryResource);
- }
- gSharedLibraryResource = kResFileNotOpened;
- }
-#endif /* WXMAKINGDLL */
-}
-
-#if defined(WXMAKINGDLL) && !defined(__DARWIN__)
-
-// for shared libraries we have to manually get the correct resource
-// ref num upon initializing and releasing when terminating, therefore
-// the __wxinitialize and __wxterminate must be used
-
-extern "C" {
- void __sinit(void); /* (generated by linker) */
- pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
- pascal void __terminate(void);
-}
-
-pascal OSErr __wxinitialize(const CFragInitBlock *theInitBlock)
-{
- wxStAppResource::OpenSharedLibraryResource( theInitBlock ) ;
- return __initialize( theInitBlock ) ;
-}
-
-pascal void __wxterminate(void)
-{
- wxStAppResource::CloseSharedLibraryResource() ;
- __terminate() ;
-}
-
-#endif /* WXMAKINGDLL && !__DARWIN__ */
-
-#if TARGET_CARBON