MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / ToAny

Method ToAny

Code/CryEngine/CryScriptSystem/ScriptSystem.cpp:1503–1651  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

1501
1502//////////////////////////////////////////////////////////////////////////
1503bool CScriptSystem::ToAny(ScriptAnyValue& var, int index)
1504{
1505 if (!lua_gettop(L))
1506 return false;
1507
1508 CHECK_STACK(L);
1509
1510 if (var.type == ANY_ANY)
1511 {
1512 switch (lua_type(L, index))
1513 {
1514 case LUA_TNIL:
1515 var.type = ANY_TNIL;
1516 break;
1517 case LUA_TBOOLEAN:
1518 var.b = lua_toboolean(L, index) != 0;
1519 var.type = ANY_TBOOLEAN;
1520 break;
1521 case LUA_TLIGHTUSERDATA:
1522 var.ptr = lua_topointer(L, index);
1523 var.type = ANY_THANDLE;
1524 break;
1525 case LUA_TNUMBER:
1526 var.number = (float)lua_tonumber(L, index);
1527 var.type = ANY_TNUMBER;
1528 break;
1529 case LUA_TSTRING:
1530 var.str = lua_tostring(L, index);
1531 var.type = ANY_TSTRING;
1532 break;
1533 case LUA_TTABLE:
1534 case LUA_TUSERDATA:
1535 if (!var.table)
1536 {
1537 var.table = AllocTable();
1538 var.table->AddRef();
1539 }
1540 lua_pushvalue(L, index);
1541 AttachTable(var.table);
1542 var.type = ANY_TTABLE;
1543 break;
1544 case LUA_TFUNCTION:
1545 {
1546 var.type = ANY_TFUNCTION;
1547 // Make reference to function.
1548 lua_pushvalue(L, index);
1549 var.function = (HSCRIPTFUNCTION)(INT_PTR)lua_ref(L, 1);
1550 }
1551 break;
1552 case LUA_TTHREAD:
1553 default:
1554 return false;
1555 }
1556 return true;
1557 }
1558 else
1559 {
1560 bool res = false;

Callers 4

RecursiveTableDumpFunction · 0.80
MoveNextMethod · 0.80
GetSelfAnyMethod · 0.80
GetParamAnyMethod · 0.80

Calls 3

AllocTableFunction · 0.85
ToVec3Function · 0.85
AddRefMethod · 0.45

Tested by

no test coverage detected