Perhaps :
And have your c / C++ glue create an instance of the struct, that you will have to clean up yourself.
The following is how I tend to go about it. Whether or not this is a GOOD way, I wouldn't know. It's the way it works for me - and I'm not a C/C++ programmer...
example c++ glue :
In your bmx code...
You can then call create_a_new_struct to get yourself a pointer to some memory representing your datastruct.
If the data is intended to only last as long as the Type it belongs to, you can have it free nicely by doing this in a Delete() method - which is called when GC decides the instance of your Type can be cleaned...
I'll leave the rest up to you... ;-)
Disclaimer : None of the above code has been tested / typed into an IDE... use your imagination :-p
Type temp_typ Field x:int,y:int Field data:byte ptr end type
And have your c / C++ glue create an instance of the struct, that you will have to clean up yourself.
The following is how I tend to go about it. Whether or not this is a GOOD way, I wouldn't know. It's the way it works for me - and I'm not a C/C++ programmer...
example c++ glue :
extern "C" { datastruct * create_a_new_struct(); void free_struct(datastruct * d); } datastruct * create_a_new_struct() { return new datastruct; } void free_struct(datastruct * d) { delete d; }
In your bmx code...
Extern Function create_a_new_struct:Byte Ptr() Function free_struct(data:Byte ptr) End Extern
You can then call create_a_new_struct to get yourself a pointer to some memory representing your datastruct.
If the data is intended to only last as long as the Type it belongs to, you can have it free nicely by doing this in a Delete() method - which is called when GC decides the instance of your Type can be cleaned...
Type temp_typ Field x:int,y:int Field data:byte ptr Method Delete() If data Then free_struct(data) data = Null End If End Method end type
I'll leave the rest up to you... ;-)
Disclaimer : None of the above code has been tested / typed into an IDE... use your imagination :-p