static JSBool getSource_func(JSContext *context, uintN argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(context, vp); cairo_t *cr; cairo_pattern_t *pattern; JSObject *pattern_wrapper; if (argc > 0) { gjs_throw(context, "Context.getSource() takes no arguments"); return JS_FALSE; } cr = gjs_cairo_context_get_context(context, obj); pattern = cairo_get_source(cr); if (!gjs_cairo_check_status(context, cairo_status(cr), "context")) return JS_FALSE; /* pattern belongs to the context, so keep the reference */ pattern_wrapper = gjs_cairo_pattern_from_pattern(context, pattern); if (!pattern_wrapper) { gjs_throw(context, "failed to create pattern"); return JS_FALSE; } JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(pattern_wrapper)); return JS_TRUE; }
static JSBool getSource_func(JSContext *context, unsigned argc, jsval *vp) { JS::CallReceiver rec = JS::CallReceiverFromVp(vp); JSObject *obj = JSVAL_TO_OBJECT(rec.thisv()); cairo_t *cr; cairo_pattern_t *pattern; JSObject *pattern_wrapper; if (argc > 0) { gjs_throw(context, "Context.getSource() takes no arguments"); return JS_FALSE; } cr = gjs_cairo_context_get_context(context, obj); pattern = cairo_get_source(cr); if (!gjs_cairo_check_status(context, cairo_status(cr), "context")) return JS_FALSE; /* pattern belongs to the context, so keep the reference */ pattern_wrapper = gjs_cairo_pattern_from_pattern(context, pattern); if (!pattern_wrapper) { gjs_throw(context, "failed to create pattern"); return JS_FALSE; } rec.rval().set(OBJECT_TO_JSVAL(pattern_wrapper)); return JS_TRUE; }
static bool getSource_func(JSContext *context, unsigned argc, JS::Value *vp) { GJS_GET_PRIV(context, argc, vp, rec, obj, GjsCairoContext, priv); cairo_t *cr = priv ? priv->cr : NULL; cairo_pattern_t *pattern; JSObject *pattern_wrapper; if (argc > 0) { gjs_throw(context, "Context.getSource() takes no arguments"); return false; } pattern = cairo_get_source(cr); if (!gjs_cairo_check_status(context, cairo_status(cr), "context")) return false; /* pattern belongs to the context, so keep the reference */ pattern_wrapper = gjs_cairo_pattern_from_pattern(context, pattern); if (!pattern_wrapper) { gjs_throw(context, "failed to create pattern"); return false; } rec.rval().setObject(*pattern_wrapper); return true; }