Пример #1
0
JS_BINDED_FUNC_IMPL(FakeAudio, addEventListener) {
	JS::CallArgs args = CallArgsFromVp(argc, vp);
	if (args.length() >=2) {
		JSStringWrapper wrapper(args[0]);
		string str((const char*)wrapper);
		if (str.compare("ended") == 0) {
			JS::Value jsthis = JS_THIS(cx, vp);
			shared_ptr<OpenALCallback> cb(new OpenALCallback(cx, args[1], jsthis.toObjectOrNull()));
			buffer->registerCallback(AudioEnded, cb);
		}
	}
	return JS_TRUE;
}
Пример #2
0
static bool
context_to_g_argument(JSContext      *context,
                      JS::Value       value,
                      const char     *arg_name,
                      GjsArgumentType argument_type,
                      GITransfer      transfer,
                      bool            may_be_null,
                      GArgument      *arg)
{
    JS::RootedObject obj(context, value.toObjectOrNull());
    cairo_t *cr;

    cr = gjs_cairo_context_get_context(context, obj);
    if (!cr)
        return false;
    if (transfer == GI_TRANSFER_EVERYTHING)
        cairo_reference(cr);

    arg->v_pointer = cr;
    return true;
}