Example #1
0
static JSBool
getGroupTarget_func(JSContext *context,
                    unsigned   argc,
                    jsval     *vp)
{
    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    JSObject *obj = JSVAL_TO_OBJECT(rec.thisv());

    cairo_t *cr;
    cairo_surface_t *surface;
    JSObject *surface_wrapper;

    if (argc > 0) {
        gjs_throw(context, "Context.getGroupTarget() takes no arguments");
        return JS_FALSE;
    }

    cr = gjs_cairo_context_get_context(context, obj);
    surface = cairo_get_group_target(cr);
    if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
        return JS_FALSE;

    /* surface belongs to the context, so keep the reference */
    surface_wrapper = gjs_cairo_surface_from_surface(context, surface);
    if (!surface_wrapper) {
        /* exception already set */
        return JS_FALSE;
    }

    rec.rval().set(OBJECT_TO_JSVAL(surface_wrapper));

    return JS_TRUE;
}
Example #2
0
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;
}
Example #3
0
static JSBool
AfxGlobal_maybeGc(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	JS_MaybeGC(cx);

	rec.rval().set(JSVAL_VOID);
    return JS_TRUE;
}
Example #4
0
static JSBool
AfxGlobal_additionalUnkDrawHud(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	Additional_UnkDrawHud();

	rec.rval().set(JSVAL_VOID);
    return JS_TRUE;
}
Example #5
0
static JSBool
AfxGlobal_getZNear(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	double value = g_Filming.GetZNear();

	rec.rval().set(JS_NumberValue(value));

	return JS_TRUE;
}
Example #6
0
static JSBool
AfxGlobal_glGetDepthWriteMask(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	boolean oldDepthWriteMask;
	
	glGetBooleanv(GL_DEPTH_WRITEMASK, &oldDepthWriteMask);

	rec.rval().set(BOOLEAN_TO_JSVAL(oldDepthWriteMask));

	return JS_TRUE;
}
Example #7
0
static JSBool
AfxGlobal_afxFilmingStop(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	if (g_pSupportRender)
		g_pSupportRender->hlaeOnFilmingStop();

	if(g_AfxSettings.OptimizeCaptureVis_get())
		RedockGameWindow();

	rec.rval().set(JSVAL_VOID);
    return JS_TRUE;
}
Example #8
0
static JSBool
dispose_func(JSContext *context,
             unsigned   argc,
             jsval     *vp)
{
    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    JSObject *obj = JSVAL_TO_OBJECT(rec.thisv());

    GjsCairoContext *priv;

    priv = priv_from_js(context, obj);
    if (priv->cr != NULL) {
        cairo_destroy(priv->cr);
        priv->cr = NULL;
    }
    rec.rval().set(JSVAL_VOID);
    return JS_TRUE;
}
Example #9
0
static JSBool
AfxGlobal_glGetCurrentColor(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	double oldColor[4];
	
	glGetDoublev(GL_CURRENT_COLOR, oldColor);
	
	jsval jsOldColor[4] = { JS_NumberValue(oldColor[0]), JS_NumberValue(oldColor[1]), JS_NumberValue(oldColor[2]), JS_NumberValue(oldColor[3]) };

	JSObject * retObj = JS_NewArrayObject(cx, 4, jsOldColor);

	if(!retObj)
		return JS_FALSE;

	rec.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
Example #10
0
static JSBool
AfxGlobal_glGetColorWriteMask(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	boolean oldColorWriteMask[4];
	
	glGetBooleanv(GL_COLOR_WRITEMASK, oldColorWriteMask);
	
	jsval jsOldColorWriteMask[4] = { BOOLEAN_TO_JSVAL(oldColorWriteMask[0]), BOOLEAN_TO_JSVAL(oldColorWriteMask[1]), BOOLEAN_TO_JSVAL(oldColorWriteMask[2]), BOOLEAN_TO_JSVAL(oldColorWriteMask[3]) };

	JSObject * retObj = JS_NewArrayObject(cx, 4, jsOldColorWriteMask);

	if(!retObj)
		return JS_FALSE;

	rec.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
Example #11
0
static JSBool
AfxGlobal_glGetBlendFunc(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	GLint sfactor, dfactor;
	
	glGetIntegerv(GL_BLEND_SRC, &sfactor);
	glGetIntegerv(GL_BLEND_DST, &dfactor);
	
	jsval jsVals[2] = { JS_NumberValue(sfactor), JS_NumberValue(dfactor) };

	JSObject * retObj = JS_NewArrayObject(cx, 2, jsVals);

	if(!retObj)
		return JS_FALSE;

	rec.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
Example #12
0
static JSBool
to_string_func(JSContext *context,
               unsigned   argc,
               jsval     *vp)
{
    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    JSObject *obj = JSVAL_TO_OBJECT(rec.thisv());

    FundamentalInstance *priv;
    JSBool ret = JS_FALSE;
    jsval retval;

    if (!priv_from_js_with_typecheck(context, obj, &priv))
        goto out;

    if (!priv->prototype) {
        Fundamental *proto_priv = (Fundamental *) priv;

        if (!_gjs_proxy_to_string_func(context, obj, "fundamental",
                                       (GIBaseInfo *) proto_priv->info,
                                       proto_priv->gtype,
                                       proto_priv->gfundamental,
                                       &retval))
            goto out;
    } else {
        if (!_gjs_proxy_to_string_func(context, obj, "fundamental",
                                       (GIBaseInfo *) priv->prototype->info,
                                       priv->prototype->gtype,
                                       priv->gfundamental,
                                       &retval))
            goto out;
    }

    ret = JS_TRUE;
    rec.rval().set(retval);
 out:
    return ret;
}
Example #13
0
static JSBool
to_gbytes_func(JSContext *context,
               unsigned   argc,
               jsval     *vp)
{
    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    JSObject *object = JSVAL_TO_OBJECT(rec.thisv());
    ByteArrayInstance *priv;
    JSObject *ret_bytes_obj;
    GIBaseInfo *gbytes_info;

    priv = priv_from_js(context, object);
    if (priv == NULL)
        return JS_TRUE; /* prototype, not instance */
    
    byte_array_ensure_gbytes(priv);

    gbytes_info = g_irepository_find_by_gtype(NULL, G_TYPE_BYTES);
    ret_bytes_obj = gjs_boxed_from_c_struct(context, (GIStructInfo*)gbytes_info,
                                            priv->bytes, GJS_BOXED_CREATION_NONE);

    rec.rval().set(OBJECT_TO_JSVAL(ret_bytes_obj));
    return JS_TRUE;
}