| 108 | } |
| 109 | |
| 110 | GJS_JSAPI_RETURN_CONVENTION |
| 111 | static 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. |
no test coverage detected