diff --git a/extend/lbson/src/bson.h b/extend/lbson/src/bson.h index 31f70e1b..21808e64 100644 --- a/extend/lbson/src/bson.h +++ b/extend/lbson/src/bson.h @@ -181,13 +181,13 @@ namespace lbson { return sprintf(str, "%zd", i); } - void write_int64(lua_State* L) { + void pack_int64(lua_State* L) { lua_getfield(L, -1, "value"); m_buffer.write(lua_tointeger(L, -1)); lua_pop(L, 1); } - void write_string(lua_State* L) { + void pack_string(lua_State* L) { size_t data_len; lua_getfield(L, -1, "value"); const char* data = lua_tolstring(L, -1, &data_len); @@ -195,7 +195,7 @@ namespace lbson { lua_pop(L, 1); } - void write_binary(lua_State* L) { + void pack_binary(lua_State* L) { lua_guard g(L); size_t bin_len; lua_getfield(L, -1, "binrary"); @@ -206,7 +206,7 @@ namespace lbson { m_buffer.push_data((uint8_t*)bin, bin_len); } - void write_regex(lua_State* L) { + void pack_regex(lua_State* L) { lua_guard g(L); size_t regex_len; lua_getfield(L, -1, "pattern"); @@ -326,21 +326,21 @@ namespace lbson { case bson_type::BSON_NULL: break; case bson_type::BSON_BINARY: - write_binary(L); + pack_binary(L); break; case bson_type::BSON_DATE: case bson_type::BSON_INT64: case bson_type::BSON_TIMESTAMP: - write_int64(L); + pack_int64(L); break; case bson_type::BSON_ARRAY: case bson_type::BSON_JSCODE: case bson_type::BSON_DOCUMENT: case bson_type::BSON_OBJECTID: - write_string(L); + pack_string(L); break; case bson_type::BSON_REGEX: - write_regex(L); + pack_regex(L); break; default: luaL_error(L, "Invalid value type : %d", (int)type); diff --git a/extend/lbson/src/lbson.cpp b/extend/lbson/src/lbson.cpp index 55c3dfed..efad213e 100644 --- a/extend/lbson/src/lbson.cpp +++ b/extend/lbson/src/lbson.cpp @@ -57,6 +57,30 @@ namespace lbson { llbson.set_function("pairs", pairs); llbson.set_function("regex", regex); llbson.set_function("date", date); + llbson.new_enum("BSON_TYPE", + "BSON_EOO", bson_type::BSON_EOO, + "BSON_REAL", bson_type::BSON_REAL, + "BSON_STRING", bson_type::BSON_STRING, + "BSON_DOCUMENT", bson_type::BSON_DOCUMENT, + "BSON_ARRAY", bson_type::BSON_ARRAY, + "BSON_BINARY", bson_type::BSON_BINARY, + "BSON_UNDEFINED", bson_type::BSON_UNDEFINED, + "BSON_OBJECTID", bson_type::BSON_OBJECTID, + "BSON_BOOLEAN", bson_type::BSON_BOOLEAN, + "BSON_DATE", bson_type::BSON_DATE, + "BSON_NULL", bson_type::BSON_NULL, + "BSON_REGEX", bson_type::BSON_REGEX, + "BSON_DBPOINTER", bson_type::BSON_DBPOINTER, + "BSON_JSCODE", bson_type::BSON_JSCODE, + "BSON_SYMBOL", bson_type::BSON_SYMBOL, + "BSON_CODEWS", bson_type::BSON_CODEWS, + "BSON_INT32", bson_type::BSON_INT32, + "BSON_TIMESTAMP", bson_type::BSON_TIMESTAMP, + "BSON_INT64", bson_type::BSON_INT64, + "BSON_INT128", bson_type::BSON_INT128, + "BSON_MINKEY", bson_type::BSON_MINKEY, + "BSON_MAXKEY", bson_type::BSON_MAXKEY + ); return llbson; } }