MCPcopy Create free account
hub / github.com/OpenMW/openmw / getMap

Function getMap

components/lua/yamlloader.cpp:103–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 }
102
103 sol::table getMap(const YAML::Node& node, const sol::state_view& lua, uint64_t depth)
104 {
105 sol::table childTable(lua, sol::create);
106
107 for (const auto& pair : node)
108 {
109 if (pair.first.IsMap())
110 nodeError(pair.first, "Only scalar nodes can be used as keys, encountered map instead");
111 if (pair.first.IsSequence())
112 nodeError(pair.first, "Only scalar nodes can be used as keys, encountered array instead");
113 if (pair.first.IsNull())
114 nodeError(pair.first, "Only scalar nodes can be used as keys, encountered null instead");
115
116 auto key = getNode(pair.first, lua, depth);
117 if (key.get_type() == sol::type::number && std::isnan(key.as<double>()))
118 nodeError(pair.first, "Only scalar nodes can be used as keys, encountered nan instead");
119
120 childTable[key] = getNode(pair.second, lua, depth);
121 }
122
123 return childTable;
124 }
125
126 sol::table getArray(const YAML::Node& node, const sol::state_view& lua, uint64_t depth)
127 {

Callers 1

getNodeFunction · 0.85

Calls 3

nodeErrorFunction · 0.85
getNodeFunction · 0.85
get_typeMethod · 0.45

Tested by

no test coverage detected