| 117 | } |
| 118 | |
| 119 | GJS_JSAPI_RETURN_CONVENTION |
| 120 | static JSObject* make_rectangle(JSContext* cx, cairo_rectangle_int_t* rect) { |
| 121 | const GjsAtoms& atoms = GjsContextPrivate::atoms(cx); |
| 122 | JS::RootedObject rect_obj{cx, JS_NewPlainObject(cx)}; |
| 123 | if (!rect_obj) |
| 124 | return nullptr; |
| 125 | JS::RootedValue val{cx}; |
| 126 | |
| 127 | val = JS::Int32Value(rect->x); |
| 128 | if (!JS_SetPropertyById(cx, rect_obj, atoms.x(), val)) |
| 129 | return nullptr; |
| 130 | |
| 131 | val = JS::Int32Value(rect->y); |
| 132 | if (!JS_SetPropertyById(cx, rect_obj, atoms.y(), val)) |
| 133 | return nullptr; |
| 134 | |
| 135 | val = JS::Int32Value(rect->width); |
| 136 | if (!JS_SetPropertyById(cx, rect_obj, atoms.width(), val)) |
| 137 | return nullptr; |
| 138 | |
| 139 | val = JS::Int32Value(rect->height); |
| 140 | if (!JS_SetPropertyById(cx, rect_obj, atoms.height(), val)) |
| 141 | return nullptr; |
| 142 | |
| 143 | return rect_obj; |
| 144 | } |
| 145 | |
| 146 | GJS_JSAPI_RETURN_CONVENTION |
| 147 | static bool num_rectangles_func(JSContext* cx, unsigned argc, JS::Value* vp) { |
no outgoing calls
no test coverage detected