예제 #1
0
int name_value_collection___index(lua_State *L) {
  NameValueCollection *collection = GetCollection(L, 1);
  const char *name = luaL_checkstring(L, 2);
  if (strcmp(name, "Count") == 0) {
    lua_pushunsigned(L, collection->GetCount());
  } else if (strcmp(name, "AllKeys") == 0) {
    StringVectorToLuaArray(L, collection->AllKeys());
  } else if (strcmp(name, "Add") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Add, 1);
  } else if (strcmp(name, "Get") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Get, 1);
  } else if (strcmp(name, "GetKey") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_GetKey, 1);
  } else if (strcmp(name, "GetValues") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_GetValues, 1);
  } else if (strcmp(name, "Clear") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Clear, 1);
  } else if (strcmp(name, "Set") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Set, 1);
  } else if (strcmp(name, "Remove") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Remove, 1);
  } else {
    lua_pushstring(L, "Unknown property or method.");
    lua_error(L);
  }

  return 1;
}
예제 #2
0
int name_value_collection_AllKeys(lua_State *L) {
  NameValueCollection *collection = GetCollection(L, lua_upvalueindex(1));
  StringVectorToLuaArray(L, collection->AllKeys());
  return 1;
}