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

Function gjs_throw_abstract_constructor_error

gjs/jsapi-util.cpp:183–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183void gjs_throw_abstract_constructor_error(JSContext* cx,
184 const JS::CallArgs& args) {
185 const char* name = "anonymous";
186
187 const GjsAtoms& atoms = GjsContextPrivate::atoms(cx);
188 JS::RootedObject callee{cx, &args.callee()};
189 JS::RootedValue prototype{cx};
190 if (JS_GetPropertyById(cx, callee, atoms.prototype(), &prototype)) {
191 const JSClass* proto_class = JS::GetClass(&prototype.toObject());
192 name = proto_class->name;
193 }
194
195 gjs_throw(cx, "You cannot construct new instances of '%s'", name);
196}
197
198JSObject* gjs_build_string_array(JSContext* cx,
199 const std::vector<std::string>& strings) {

Callers 3

abstract_constructorMethod · 0.85
constructorMethod · 0.85
no_constructFunction · 0.85

Calls 2

gjs_throwFunction · 0.85
prototypeMethod · 0.80

Tested by

no test coverage detected