I have found that it passing BlitzMax types to and from a BlitzMax dll works perfectly, even with other languages. I would recommend declaring the variables as a byte ptr in the main program, and having the BlitzMax dll return the type.
DLL function:
Main program:
Obviously it is your responsibility to manage the memory, but for types that always get stored in a list and have a Free() command, this approach will work just fine.
The only problem I have found is that the BlitzMax dll does not seem to recognize Null when it is passed. When I pass Null to this DLL function from the main program, the dll always thinks that a valid object was passed:
DLL function:
Function SubmeshSurface_:TSurface(hsubmesh:Int) "win32" GCEnter() Local submesh:TSubmesh submesh=TSubmesh(HandleToObject(hsubmesh)) Return submesh.surface EndFunction Function CountVertices_:Int(surface:TSurface) "win32" GCEnter() Return surface.CountVertices() EndFunction
Main program:
Global SubmeshSurface:Byte Ptr(hsubmesh:Int) "win32" Global CountVertices:Int(surface:Byte Ptr) "win32"
Obviously it is your responsibility to manage the memory, but for types that always get stored in a list and have a Free() command, this approach will work just fine.
The only problem I have found is that the BlitzMax dll does not seem to recognize Null when it is passed. When I pass Null to this DLL function from the main program, the dll always thinks that a valid object was passed:
Function LoadMesh_:Int(cs:Byte Ptr,oparent:TEntity) "win32" GCEnter() Local parent:TEntity Local mesh:TMesh Local path$ If oparent=Null Notify "null parent" Else Notify "Something was passed, muthafucka!" parent=TEntity(oparent) 'parent=TEntity(HandleToObject(hparent)) path=String.fromcstring(cs) mesh=LoadMesh(path,parent) If mesh Return mesh.handle EndFunction