When getting an object argument the method:
void* playdate->lua->getArgObject(int pos, char* type, LuaUDObject** outud);
takes a char*
for the class name. This unfortunately doesn't vibe with the method used to parse arguments which returns a const char*
:
enum LuaType playdate->lua->getArgType(int pos, const char** outClass);
This prevents parsing code from safely reusing the same string between the two functions.
getArgObject()
's signature should probably be modified like so:
void* playdate->lua->getArgObject(int pos, const char* type, LuaUDObject** outud);
Same deal for void playdate->lua->pushString(char* str);
The get
version:
const char* playdate->lua->getArgString(int pos);
returns a const, which clearly indicates that you're not supposed to mess with the string content.
pushString()
takes a char*
which, since there is no indication of ownership in the documentation, implies that maybe the string content could be modified by the recipient.
I think this needs to be clarified and probably changed to const
too. If the recipient does need to be able to modify this, it should make a copy. It probably already does since nothing indicates that the memory for the string needs to be kept around after calling pushString()
.