|
Post by DJLinux on Apr 11, 2008 23:03:24 GMT -5
Hello Tom is there an "ANY" datatype or how can a plugin get the address of a user defined Type (UDT). (not registered by the plugin) I implemented StrPtr(text$) in the API-Plugin to move the string ptr to any API call but i need StructPtr(NAME_OF_UDT) or AnyPtr(NAME_OF_UDT) thanx Joshy api-plugin: type RECT x as integer Y as integer w as integer h as integer end type hDLL=Import("ANY.DLL") hFunc1=Define(hDLL,API_ANY,"GetRectangle",0) hFunc2=Define(hDLL,API_VOID,"SetRectangle",API_ANY,1)
dim MyRec as RECT Call(hFunc1) MyRec=GetAny() ' return UDT RECT
SetAny(MyRec) Call(hFunc2) ' put address from RECT to the DLL
|
|
|
Post by DJLinux on Apr 13, 2008 13:52:18 GMT -5
Tom are in holydays ?
|
|
|
Post by Empyrion Martyr on Apr 13, 2008 15:33:16 GMT -5
i think the man might be busy. He'll answer when he's got time. Be patient 
|
|
|
Post by DJLinux on Apr 21, 2008 8:06:46 GMT -5
i think the man might be busy. He'll answer when he's got time. Be patient  now i saw he has time for offtopic talk but not for advanced developers it's not the first time. i go and write my own native basic for mac, win and linux thanx all for the nice time
|
|
|
Post by Tom Mulgrew on May 8, 2008 4:19:02 GMT -5
Hello Tom is there an "ANY" datatype or how can a plugin get the address of a user defined Type (UDT). (not registered by the plugin) I implemented StrPtr(text$) in the API-Plugin to move the string ptr to any API call but i need StructPtr(NAME_OF_UDT) or AnyPtr(NAME_OF_UDT) thanx Joshy api-plugin: type RECT x as integer Y as integer w as integer h as integer end type hDLL=Import("ANY.DLL") hFunc1=Define(hDLL,API_ANY,"GetRectangle",0) hFunc2=Define(hDLL,API_VOID,"SetRectangle",API_ANY,1)
dim MyRec as RECT Call(hFunc1) MyRec=GetAny() ' return UDT RECT
SetAny(MyRec) Call(hFunc2) ' put address from RECT to the DLL It's been a while since I've sat down and tried to catch up on the questions and discussions. You can pass pointers back and forth between plugins and BASIC code by casting them to an int. But you already know that (you did it in the ODE plugin  ) The problem is you can't just copy data or pointers into BASIC structures, because Basic4GL stores data in its own format. So it needs to be translated back and forth. You could create some plugin functions to read/write data out of C structures that the BASIC program can call. void DLLFUNC Func_WriteByte(IDLL_Basic4GL_Runtime &basic4gl) { unsigned char *addr = (unsigned char *)basic4gl.GetIntParam(2); unsigned char value = (unsigned char)basic4gl.GetIntParam(1); *addr = byte; }
void DLLFUNC Func_WriteInt(IDLL_Basic4GL_Runtime &basic4gl) { ...
void DLLFUNC Func_ReadByte(IDLL_Basic4GL_Runtime &basic4gl) { unsigned char *addr = (unsigned char *)basic4gl.GetIntParam(1); basic4gl.SetIntResult(*addr); }
... Then instead of: MyRec=GetAny() ' return UDT RECT You would write something like: dim addr addr = GetAnyAddr() MyRec.x = GetInt(addr) MyRec.y = GetInt(addr + 4) MyRec.w = GetInt(addr + 8) MyRec.h = GetInt(addr + 12) Does that help with what you are trying to do, or have I missed the point? Alternatively I could have a think about allowing plugins to copy data to/from C structures without knowing the BASIC data type. It's not completely trivial though, as it would require some way for the BASIC program to tell the plugin what format the data is in and what format it needs to be in, and the compiler would have to know that the function accepts any data type. I'm open to suggestions if you can think of any way to simplify the problem. Cheers, -Tom
|
|