Just another update...
I'm taking the time to address another long-standing the torquescript interop has... namely with strings. Usually Con::getData, Con::getVariable and such return "const char*" pointers, sometimes to temporary strings and sometimes to dynamic strings. The problem however is there are no guarantees placed on if this pointer remains valid, especially if you call another console-related function. This leads to all sorts of weird hacks in various places in the engine in order to account for parameter values being clobbered.
Basically instead of this...
Code: Select all
const char* myStringValue = Con::getVariable("$whatever");
// Do something with myStringValue, assuming it wont ever change (it *might*)
You do something like this...
Code: Select all
ConsoleStringValuePtr value = Con::getVariable("$whatever");
const char* myStringValue = result.c_str();
// myStringValue remains constant as long as value still exists on stack
In some ways this is similar to the String type in T3D (or your classic std::string), though I am aiming to wrap in support for static unallocated strings, as well as a sensible allocator for small strings into this too.