MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / tokens_to_lua_value

Function tokens_to_lua_value

src/Chain/libraries/glua/ljsonlib.cpp:32–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32static GluaStorageValue tokens_to_lua_value(lua_State *L, GluaTokenParser *token_parser, bool *result)
33{
34 if (token_parser->eof())
35 {
36 if (nullptr != result)
37 {
38 *result = false;
39 }
40 return nil_storage_value();
41 }
42 auto cur_token = token_parser->current();
43 if (token_parser->current_position() == token_parser->size() - 1 || (cur_token.type != '{' && cur_token.type != '['))
44 {
45 auto token = token_parser->current();
46 token_parser->next();
47 switch (token.type)
48 {
49 case TOKEN_RESERVED::LTK_INT:
50 {
51 auto token_str = token.token;
52 std::stringstream ss;
53 ss << token_str;
54 lua_Integer token_int = 0;
55 ss >> token_int;
56 GluaStorageValue value;
57 value.type = thinkyoung::blockchain::StorageValueTypes::storage_value_int;
58 value.value.int_value = token_int;
59 if (nullptr != result)
60 *result = true;
61 return value;
62 } break;
63 case TOKEN_RESERVED::LTK_FLT:
64 {
65 auto token_str = token.token;
66 std::stringstream ss;
67 ss << token_str;
68 lua_Number token_num = 0;
69 ss >> token_num;
70 GluaStorageValue value;
71 value.type = thinkyoung::blockchain::StorageValueTypes::storage_value_number;
72 value.value.number_value = token_num;
73 if (nullptr != result)
74 *result = true;
75 return value;
76 } break;
77 case TOKEN_RESERVED::LTK_TRUE:
78 case TOKEN_RESERVED::LTK_FALSE:
79 case TOKEN_RESERVED::LTK_NAME:
80 {
81 auto token_str = token.token;
82 if (token_str == "true")
83 {
84 GluaStorageValue value;
85 value.type = thinkyoung::blockchain::StorageValueTypes::storage_value_bool;
86 value.value.bool_value = true;
87 if (nullptr != result)
88 *result = true;
89 return value;

Callers 1

json_to_luaFunction · 0.85

Calls 14

nil_storage_valueFunction · 0.85
malloc_managed_stringFunction · 0.85
assertClass · 0.85
current_positionMethod · 0.80
to_stringFunction · 0.50
eofMethod · 0.45
currentMethod · 0.45
sizeMethod · 0.45
nextMethod · 0.45
throw_exceptionMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected