MCPcopy Create free account
hub / github.com/GNOME/gjs / gjs_enum_value_is_valid

Function gjs_enum_value_is_valid

gi/arg.cpp:110–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110GJS_JSAPI_RETURN_CONVENTION
111static bool gjs_enum_value_is_valid(JSContext* cx, const GI::EnumInfo& info,
112 int64_t value) {
113 GI::EnumInfo::ValuesIterator values = info.values();
114 if (std::none_of(values.begin(), values.end(),
115 [value](const GI::AutoValueInfo& info) {
116 return info.value() == value;
117 })) {
118 gjs_throw(cx, "%" PRId64 " is not a valid value for enumeration %s",
119 value, info.name());
120 return false;
121 }
122
123 return true;
124}
125
126/* Check if an argument of the given type needs to be released if we created it
127 * from a JS value to pass it into a function and aren't transferring ownership.

Calls 6

gjs_throwFunction · 0.85
valuesMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
valueMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected