PDA

View Full Version : Mach-O plugin development?



LSlugger
05-27-2005, 11:46 PM
It's clear that the path of least resistance for plugin development on the Mac is CodeWarrior-compiled CFM, although I've compiled some trivial examples with MPW. I'm curious to know whether anyone has attempted to call Mach-O code from a CFM plugin. Google leads me to believe that this is possible with the CFBundleGetFunctionPointerForName() function.

In general, I'm much more comfortable with the GCC tool chain than with MPW, and I think it would be easier to build supporting libraries with GCC. For instance, the Accelerate framework in OS X 10.4 adds support for OpenEXR. It might be easier to bridge to Mach-O than to build a CFM version of the reference implementation.

LSlugger
05-31-2005, 11:00 PM
I'm happy to report that I've gotten a trivial example to work: I called the log() function in the System framework. Not terribly useful, but it's a start. The next step is to figure out the best way to pass data across the CFM - Mach-O boundary. It would be kind of nice to pass SDK structures back and forth (e.g., write a Mach-O pointScan() callback), but I don't know whether that will work.

LSlugger
06-09-2005, 11:35 AM
A Mach-O version of LightWave (which is inevitable, given Apple's move to Intel) pretty much renders this moot, but I can report that I have been able to call back and forth from a CFM wrapper to a Mach-O plugin. Specifically, I used Marvin Landis's InventorSave (http://amber.rc.arizona.edu/lw/invsave.html) plugin to save an object to an Open Inventor file.

The approach I took was to compile the plugin, with minimal changes, as Mach-O (using GCC). Then, I wrote a CFM wrapper (using MPW) that converts the SDK function pointers and passes them to the Mach-O code.

There are still some unresolved problems. The most serious is that I can only call the plugin once; a subsequent call crashes LightWave. I suspect that the function pointers are either not munged on the second call, for some reason, or that I'm double munging them.

Another problem is that LightWave's file requester returns an old-style path (with colons separating directory names), whereas Open Inventor expects new-style paths (with slashes). The file ends up in the root directory with a name like "Macintosh HD:Users:..."

A problem that may not have anything to do with the Mach-O bridging is that the controls on the plugin's dialog boxes are disabled. The plugin was written for LW 5.6, so this may be a backwards compatibility bug. It shouldn't be too hard to port to a newer SDK.

LSlugger
06-10-2005, 11:23 AM
The most serious [problem] is that I can only call the plugin once; a subsequent call crashes LightWave. I suspect that the function pointers are either not munged on the second call, for some reason, or that I'm double munging them.

I was, in fact, double munging the function pointers. I intended to declare the wrapper copies static, but I missed one.