Accessing a third party Mac API through Firemonkey

  

I have an SDK from a hardware manufacturer which provides Windows and Mac APIs. In Windows this is a standard COM DLL. On the Mac, it’s in a bundle in the Library. Can someone give me a starting point on how to access the functions from a Firemonkey app please?
The Plist file mentions
<key>CFBundleExecutable</key>

and
<key>CFBundlePackageType</key>
<string>BNDL</string>

and the bundle contains a file with no file extension but a ‘kind’ of ‘Unix executable’
The include file contains the following (abridged) code to gain access to the API from C++ in XCode :
typedef IDiscovery* (*CreateDiscoveryFunc)(void);

static pthread_once_t gOnceControl = PTHREAD_ONCE_INIT;
static CreateDiscoveryFunc gCreateDiscoveryFunc = NULL;

static void InitAPI (void)
{
bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kAPI_BundlePath), kCFURLPOSIXPathStyle, true);
if (bundleURL != NULL)
{
gBundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL);
if (gBundleRef != NULL)
{
gCreateDiscoveryFunc = (CreateDiscoveryFunc)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("GetDiscoveryInstance"));
}
CFRelease(bundleURL);
}
}

IDiscovery* CreateDiscoveryInstance (void)
{
pthread_once(&gOnceControl, InitAPI);

if (gCreateDiscoveryFunc == NULL)
return NULL;

return gCreateDiscoveryFunc();
}

– (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
mDiscovery = NULL;
mDevice = NULL;

mDiscovery = CreateDiscoveryInstance();
if (! mDiscovery)
{
/* Show an alert to say the API may not be installed, and quit program */
}

NSString* address = [mAddressTextField stringValue];
ConnectToFailure failReason;

HRESULT hr = mDiscovery->ConnectTo((CFStringRef)address, &mDevice, &failReason);

}

If I can get the mDevice object, then I should be able to get all the other objects I need to use the API.
Could this ‘Unix executable’ just be a DYLIB?

Comments are closed.