Objects in DLLs

BlitzMax Forums/BlitzMax Programming/Objects in DLLs

JoshK(Posted 2007) [#1]
It would be a lot easier if I could pass objects directly to and from a DLL, instead of their integer handle. I know objects still have to be kept track of internally, and I don't expect a dll to recognize objects created by the main program, but has anyone tried compiling a dll and passing objects to and from the main program?

C++ App     BlitzMax DLL
       obj <--CreateThing:Object()
       obj -->DoSomething(obj:Object)



DStastny(Posted 2007) [#2]
Yes it can be done with some creative headers and having a bogus reference back to itself to keep GC from cleaning it up.

Much faster than TMap. Handle stuff. Although, I am not keen on the GCEnter GCExit coding reguired to use Max in a DLL


Doug


JoshK(Posted 2007) [#3]
Any object that gets created has a million links attached to it. GCC is not a problem. And I don't need C to actually access anything in the object, it's just a handle.

As far as I know you only need GCEnter, not GCExit.

You can have a constant COMPILE_DLL and put this at the start of each exposed function:

If COMPILE_DLL GCEnter()

The if statement would be skipped if COMPILE_DLL is set to 0.