FFI on macintosh

John M McIntosh johnmci at smalltalkconsulting.com
Mon Aug 14 06:56:43 UTC 2000


on 8/13/00 10:29 PM, John M McIntosh at johnmci at smalltalkconsulting.com
wrote:

Alright I couldn't resist. The following fixes FFI on the macintosh. After
looking for the module in the Plugins directory and the main directory, we
then should look for our shared import libraries IE InterfaceLib


int ioLoadModule(char *pluginName) {
    char pluginDirPath[1000];
    CFragConnectionID libHandle;
    Ptr mainAddr;
    Str255 errorMsg,tempPluginName;
    OSErr err;
    
    /* first, look in the "<Squeak VM directory>Plugins" directory for the
library */
    strcpy(pluginDirPath, vmPath);
    strcat(pluginDirPath, "Plugins");
    libHandle = LoadLibViaPath(pluginName, pluginDirPath);
    if (libHandle != nil) return (int) libHandle;

    /* second, look directly in Squeak VM directory for the library */
    libHandle = LoadLibViaPath(pluginName, vmPath);
    if (libHandle != nil) return (int) libHandle;
    
    /* Lastly look for it as a shared import library */
    
    CopyCStringToPascal(pluginName,tempPluginName);
    err = GetSharedLibrary(tempPluginName, kAnyCFragArch, kLoadCFrag,
&libHandle, &mainAddr, errorMsg);
    if (err == noErr)
        err = GetSharedLibrary(tempPluginName, kAnyCFragArch, kFindCFrag,
&libHandle, &mainAddr, errorMsg);
    if (libHandle != nil) return (int) libHandle;
    
    return nil;
}
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================
Custom Macintosh programming & various Smalltalk dialects
PGP Key: DSS/Diff/46FC3BE6
Fingerprint=B22F 7D67 92B7 5D52 72D7  E94A EE69 2D21 46FC 3BE6
===========================================================================





More information about the Squeak-dev mailing list