Wow, you really are lost aren't you? It is not only speed efficient, it is memory efficient. This is what GM does:It's also a Delphi thing, they aren't reconstructing the string each time. Maybe when GM9 comes YYG will take control over your pointers like you'd like. I'm looking forward to the day when returning a pointer means I have to make myself a copy since GM needs it.
//str = external_call(ec); where ec is an external_define returning a 'char*'
char* (*ftn)(void) = external_defines->item[ec];
if(ftn == NULL)
report("Error with the 'ec' not being a properly defined item");
char* ret = (*ftn)();
int retlen = strlen(ret);
string* rtn = new string();
rtn->expand(retlen);
memcpy(rtn->data, ret, retlen);
return rtn; //at which point 'ret' is lostThis is what I propose GM to do:
//str = external_call(ec);
char* (*ftn)(void) = external_defines->item[ec];
if(ftn == NULL)
report("Error with the 'ec' not being a properly defined item");
char* ret = (*ftn)();
int retlen = strlen(ret);
string* rtn = new string();
rtn->size = retlen;
rtn->data = ret;
return rtn; //which contains 'ret' so it is not lostBut then I proposed by-reference, which would be like this:
//str = external_call(ec);
string* arg0 = strings->item[argument0];
if(arg0 == NULL)
report("Error with the 'argument0' not being a string");
double (*ftn)(string*) = external_defines->item[ec];
if(ftn == NULL)
report("Error with the 'ec' not being a properly defined item");
return (*ftn)(arg0);This would force DLL writers to need to know the "string" structure, which can easily be made and distributed with GM-Pro. Although this 'might' make it more strict, at least there would efficiency and proper communication between GM and links.
Although the above is pseudo-C and doesn't allow multiple arguments, it was only an example. I don't have time right now to show the assembly of what I really want to implement, which allows ANY argument types and return ANY argument type without limitation (including by-reference)...and yes, it can be done without bloating the runner.



This topic is locked






