diff --git a/src/types.cc b/src/types.cc index 5b8ad9b..0089ddb 100644 --- a/src/types.cc +++ b/src/types.cc @@ -951,8 +951,22 @@ namespace ConfigValueReg { // an make(){ // return New(); // }; - an make(string s){ - return New(s); + + int raw_make(lua_State *L) { + an t = New(); + if (lua_gettop(L) > 0 && !lua_isnil(L, 1)) { + if (lua_isstring(L, 1)) { + t->SetString(lua_tostring(L, 1)); + } + else if(lua_isboolean(L, 1)){ + t->SetBool(lua_toboolean(L, 1)); + } + else { + LOG(WARNING) << "args #1 type error: " << luaL_typename(L, 1); + } + } + LuaType>::pushdata(L, t); + return 1; }; optional get_bool(T &t) { @@ -1006,7 +1020,7 @@ namespace ConfigValueReg { } static const luaL_Reg funcs[] = { - {"ConfigValue", WRAP(make)}, + {"ConfigValue",(raw_make)}, { NULL, NULL }, };