Beispiel #1
0
void findfield2(LuaThread* L, LuaTable* table1, LuaValue goal, int depth, std::string& result) {

  LuaValue key = table1->findKeyString(goal);

  if(!key.isNone()) {
    result = key.getString()->c_str();
    return;
  }

  if(depth == 0) return;

  int size1 = table1->getTableIndexSize();
  
  for(int i = 0; i < size1; i++) {
    LuaValue key1, val1;
    table1->tableIndexToKeyVal(i, key1, val1);
    if(!key1.isString()) continue;
    if(!val1.isTable()) continue;

    findfield2(L, val1.getTable(), goal, depth-1, result);

    if(result.size()) {
      std::string prefix = key1.getString()->c_str();
      result = prefix + "." + result;
      return;
    }
  }
}
Beispiel #2
0
LuaValue luaL_getmetatable2(LuaThread* L, const char* tname) {
  LuaTable* registry = L->l_G->getRegistry();

  LuaValue v = registry->get(tname);
  if(v.isNone()) v = LuaValue::Nil();

  return v;
}