MCPcopy Create free account
hub / github.com/defold/defold / DoLuaTableToDDF

Function DoLuaTableToDDF

engine/script/src/script_ddf.cpp:388–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386 }
387
388 static void DoLuaTableToDDF(lua_State* L, const dmDDF::Descriptor* descriptor,
389 char* buffer, char** data_start, char** data_last, int index, char* pointer_base)
390 {
391 luaL_checktype(L, index, LUA_TTABLE);
392
393 for (uint32_t i = 0; i < descriptor->m_FieldCount; ++i)
394 {
395 const dmDDF::FieldDescriptor* f = &descriptor->m_Fields[i];
396
397 lua_pushstring(L, f->m_Name);
398 lua_rawget(L, index);
399 if (lua_isnil(L, -1))
400 {
401 if (f->m_Label == dmDDF::LABEL_OPTIONAL)
402 {
403 if (f->m_DefaultValue)
404 {
405 DefaultLuaValueToDDF(L, f, buffer, data_start, data_last, f->m_DefaultValue, pointer_base);
406 }
407 else if (f->m_Type == dmDDF::TYPE_MESSAGE)
408 {
409 DoDefaultLuaTableToDDF(L, f->m_MessageDescriptor, &buffer[f->m_Offset], data_start, data_last);
410 }
411 else
412 {
413 // No default value specified and the type != MESSAGE
414 // Set appropriate unit value, e.g. 0 and empty string ""
415 UnityValueToDDF(L, f, buffer, data_start, data_last, pointer_base);
416 }
417 }
418 else
419 {
420 luaL_error(L, "Field %s not specified in table", f->m_Name);
421 }
422 }
423 else
424 {
425 LuaValueToDDF(L, f, buffer, data_start, data_last, pointer_base);
426 }
427 lua_pop(L, 1);
428 }
429 }
430
431 uint32_t CheckDDF(lua_State* L, const dmDDF::Descriptor* descriptor, char* buffer, uint32_t buffer_size, int index)
432 {

Callers 2

LuaValueToDDFFunction · 0.85
CheckDDFFunction · 0.85

Calls 8

luaL_checktypeFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawgetFunction · 0.85
DefaultLuaValueToDDFFunction · 0.85
DoDefaultLuaTableToDDFFunction · 0.85
UnityValueToDDFFunction · 0.85
luaL_errorFunction · 0.85
LuaValueToDDFFunction · 0.85

Tested by

no test coverage detected