Hi Maxim,
I think for what you need, you would need to create compiled module first, where:
- you would create internal COM wrapper for each of the Irrlicht classes with all functions (phew, lot of them!)
So for example for IrrlichtDevice, you would need to do (in PowerBasic):
CLASS CIrrlichtDevice
INSTANCE pDevice AS DWORD
INTERFACE IIrrlichtDevice
INHERIT IUnknown
METHOD CreateDevice(BYVAL deviceType AS LONG, BYVAL windowSize AS DWORD, BYVAL BITS AS WORD, BYVAL fullscreen AS BYTE, BYVAL stencilbuffer AS BYTE, BYVAL vsync AS BYTE, BYVAL receiver AS DWORD)
pDevice = IrrlichtDevice_createDevice(deviceType, windowSize, bits, fullscreen, stencilbuffer, vsync, receiver)
END METHOD
METHOD Run()
IrrlichtDevice_run(pDevice) ' -- This we have stored thanks to previous CreateDevice method call
END METHOD
' .. and so on, wrapper for everything
END INTERFACE
END CLASS
Then you would need to create the ThinBASIC wrappers for methods:
' -- pClass identifies the class as such in later code (when adding methods)
LOCAL pClass AS LONG
pClass = thinBasic_Class_Add("IrrlichtDevice", 0)
' -- If the creation of class succeeded, we can proceed adding methods
IF pClass THEN
' -- _Create method is used for constructor
thinBasic_Class_AddMethod(pClass, "_Create" , %thinBasic_ReturnNone , CODEPTR(keyword_IrrlichtDevice_Create))
' -- _Destroy method is used for destructor
thinBasic_Class_AddMethod(pClass, "_Destroy" , %thinBasic_ReturnNone , CODEPTR(keyword_IrrlichtDevice_Destroy))
' -- CreateDevice method
thinBasic_Class_AddMethod(pClass, "CreateDevice" , %thinBasic_ReturnNone , CODEPTR(keyword_IrrlichtDevice_CreateDevice))
' -- Run method
thinBasic_Class_AddMethod(pClass, "Run" , %thinBasic_ReturnNone , CODEPTR(keyword_IrrlichtDevice_Run))
' -- and so on for others
END IF
- and of course create the wrapper functions which interact with parser
SUB keyword_IrrlichtDevice_Create(BYVAL pInstance AS LONG)
' -- Instantiate object
REDIM obj(1 to 1) AS IIrrlichtDevice AT pInstance
obj(1) = CLASS "CIrrlichtDevice"
END SUB
SUB keyword_IrrlichtDevice_CreateDevice(BYVAL pInstance AS LONG)
LOCAL deviceType, windowSize, bits, fullscreen, stencilbuffer, vsync, receiver AS EXT
' -- Get reference to object
REDIM obj(1 to 1) AS IIrrlichtDevice AT pInstance
' -- Get params for it from parser
thinBasic_Parse7Numbers(deviceType, windowSize, bits, fullscreen, stencilbuffer, vsync, receiver)
' -- Call the method
obj(1).CreateDevice(deviceType, windowSize, bits, fullscreen, stencilbuffer, vsync, receiver)
END SUB
... and so on
Petr
Bookmarks