AP_Scripting: userdata: allow read of enums and userdata
This commit is contained in:
parent
52cb59e61d
commit
8fa2472148
@ -1642,9 +1642,11 @@ void emit_field(const struct userdata_field *field, const char* object_name, con
|
||||
case TYPE_INT32_T:
|
||||
case TYPE_UINT8_T:
|
||||
case TYPE_UINT16_T:
|
||||
case TYPE_ENUM:
|
||||
fprintf(source, "%slua_pushinteger(L, %s%s%s%s);\n", indent, object_name, object_access, field->name, index_string);
|
||||
break;
|
||||
case TYPE_ENUM:
|
||||
fprintf(source, "%slua_pushinteger(L, static_cast<int32_t>(%s%s%s%s));\n", indent, object_name, object_access, field->name, index_string);
|
||||
break;
|
||||
case TYPE_UINT32_T:
|
||||
fprintf(source, "%snew_uint32_t(L);\n", indent);
|
||||
fprintf(source, "%s*static_cast<uint32_t *>(luaL_checkudata(L, -1, \"uint32_t\")) = %s%s%s%s;\n", indent, object_name, object_access, field->name, index_string);
|
||||
@ -1659,7 +1661,9 @@ void emit_field(const struct userdata_field *field, const char* object_name, con
|
||||
fprintf(source, "%slua_pushstring(L, %s%s%s%s);\n", indent, object_name, object_access, field->name, index_string);
|
||||
break;
|
||||
case TYPE_USERDATA:
|
||||
error(ERROR_USERDATA, "Userdata does not currently support access to userdata field's");
|
||||
// userdatas must allocate a new container to return
|
||||
fprintf(source, "%snew_%s(L);\n", indent, field->type.data.ud.sanatized_name);
|
||||
fprintf(source, "%s*check_%s(L, -1) = %s%s%s%s;\n", indent, field->type.data.ud.sanatized_name, object_name, object_access, field->name, index_string);
|
||||
break;
|
||||
case TYPE_AP_OBJECT: // FIXME: collapse the identical cases here, and use the type string function
|
||||
error(ERROR_USERDATA, "AP_Object does not currently support access to userdata field's");
|
||||
|
Loading…
Reference in New Issue
Block a user