void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JSObject *global) {
	jsb_spine_SkeletonAnimation_class = (JSClass *)calloc(1, sizeof(JSClass));
	jsb_spine_SkeletonAnimation_class->name = "SkeletonAnimation";
	jsb_spine_SkeletonAnimation_class->addProperty = JS_PropertyStub;
	jsb_spine_SkeletonAnimation_class->delProperty = JS_DeletePropertyStub;
	jsb_spine_SkeletonAnimation_class->getProperty = JS_PropertyStub;
	jsb_spine_SkeletonAnimation_class->setProperty = JS_StrictPropertyStub;
	jsb_spine_SkeletonAnimation_class->enumerate = JS_EnumerateStub;
	jsb_spine_SkeletonAnimation_class->resolve = JS_ResolveStub;
	jsb_spine_SkeletonAnimation_class->convert = JS_ConvertStub;
	jsb_spine_SkeletonAnimation_class->finalize = js_spine_SkeletonAnimation_finalize;
	jsb_spine_SkeletonAnimation_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

	static JSPropertySpec properties[] = {
		{"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
		{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
	};

	static JSFunctionSpec funcs[] = {
		JS_FN("update", js_cocos2dx_spine_SkeletonAnimation_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("setMix", js_cocos2dx_spine_SkeletonAnimation_setMix, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("clearTracks", js_cocos2dx_spine_SkeletonAnimation_clearTracks, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("clearTrack", js_cocos2dx_spine_SkeletonAnimation_clearTrack, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("onAnimationStateEvent", js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
	};

	static JSFunctionSpec st_funcs[] = {
		JS_FN("create", js_cocos2dx_spine_SkeletonAnimation_createWithFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FS_END
	};

	jsb_spine_SkeletonAnimation_prototype = JS_InitClass(
		cx, global,
		jsb_spine_Skeleton_prototype,
		jsb_spine_SkeletonAnimation_class,
		js_cocos2dx_spine_SkeletonAnimation_constructor, 0, // constructor
		properties,
		funcs,
		NULL, // no static properties
		st_funcs);
	// make the class enumerable in the registered namespace
//	bool found;
//FIXME: Removed in Firefox v27	
//	JS_SetPropertyAttributes(cx, global, "SkeletonAnimation", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

	// add the proto and JSClass to the type->js info hash table
	TypeTest<spine::SkeletonAnimation> t;
	js_type_class_t *p;
	std::string typeName = t.s_name();
	if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
	{
		p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
		p->jsclass = jsb_spine_SkeletonAnimation_class;
		p->proto = jsb_spine_SkeletonAnimation_prototype;
		p->parentProto = jsb_spine_Skeleton_prototype;
		_js_global_type_map.insert(std::make_pair(typeName, p));
	}
}
void js_register_PluginIAPJS_IAP(JSContext *cx, JSObject *global) {
    jsb_sdkbox_IAP_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_IAP_class->name = "IAP";
    jsb_sdkbox_IAP_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_IAP_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_IAP_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_IAP_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_IAP_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_IAP_class->resolve = JS_ResolveStub;
    jsb_sdkbox_IAP_class->convert = JS_ConvertStub;
    jsb_sdkbox_IAP_class->finalize = js_PluginIAPJS_IAP_finalize;
    jsb_sdkbox_IAP_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
        {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FN("purchase", js_PluginIAPJS_IAP_purchase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("restore", js_PluginIAPJS_IAP_restore, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("refresh", js_PluginIAPJS_IAP_refresh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginIAPJS_IAP_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setDebug", js_PluginIAPJS_IAP_setDebug, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("removeListener", js_PluginIAPJS_IAP_removeListener, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_IAP_prototype = JS_InitClass(
        cx, global,
        NULL, // parent proto
        jsb_sdkbox_IAP_class,
        dummy_constructor<sdkbox::IAP>, 0, // no constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);
    // make the class enumerable in the registered namespace
//  bool found;
//FIXME: Removed in Firefox v27 
//  JS_SetPropertyAttributes(cx, global, "IAP", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::IAP> t;
    js_type_class_t *p;
    std::string typeName = t.s_name();
    if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
    {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->jsclass = jsb_sdkbox_IAP_class;
        p->proto = jsb_sdkbox_IAP_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
void js_register_controls_Button(JSContext *cx, JSObject *global) {
	jsb_es_Button_class = (JSClass *)calloc(1, sizeof(JSClass));
	jsb_es_Button_class->name = "Button";
	jsb_es_Button_class->addProperty = JS_PropertyStub;
	jsb_es_Button_class->delProperty = JS_DeletePropertyStub;
	jsb_es_Button_class->getProperty = JS_PropertyStub;
	jsb_es_Button_class->setProperty = JS_StrictPropertyStub;
	jsb_es_Button_class->enumerate = JS_EnumerateStub;
	jsb_es_Button_class->resolve = JS_ResolveStub;
	jsb_es_Button_class->convert = JS_ConvertStub;
	jsb_es_Button_class->finalize = js_es_Button_finalize;
	jsb_es_Button_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

	static JSPropertySpec properties[] = {
		{"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
		{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
	};

	static JSFunctionSpec funcs[] = {
		JS_FN("getNormalTextureScaleInSize", js_controls_Button_getNormalTextureScaleInSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("ctor", js_es_Button_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
	};

	static JSFunctionSpec st_funcs[] = {
		JS_FN("create", js_controls_Button_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("createInstance", js_controls_Button_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FS_END
	};

	jsb_es_Button_prototype = JS_InitClass(
		cx, global,
		jsb_cocos2d_ui_Button_prototype,
		jsb_es_Button_class,
		dummy_constructor<es::Button>, 0, // no constructor
		properties,
		funcs,
		NULL, // no static properties
		st_funcs);
	// make the class enumerable in the registered namespace
//	bool found;
//FIXME: Removed in Firefox v27	
//	JS_SetPropertyAttributes(cx, global, "Button", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

	// add the proto and JSClass to the type->js info hash table
	TypeTest<es::Button> t;
	js_type_class_t *p;
	std::string typeName = t.s_name();
	if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
	{
		p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
		p->jsclass = jsb_es_Button_class;
		p->proto = jsb_es_Button_prototype;
		p->parentProto = jsb_cocos2d_ui_Button_prototype;
		_js_global_type_map.insert(std::make_pair(typeName, p));
	}
}
Beispiel #4
0
void register_jsb_websocket(JSContext *cx, JSObject *global) {
    
    js_cocos2dx_websocket_class = (JSClass *)calloc(1, sizeof(JSClass));
    js_cocos2dx_websocket_class->name = "WebSocket";
    js_cocos2dx_websocket_class->addProperty = JS_PropertyStub;
    js_cocos2dx_websocket_class->delProperty = JS_PropertyStub;
    js_cocos2dx_websocket_class->getProperty = JS_PropertyStub;
    js_cocos2dx_websocket_class->setProperty = JS_StrictPropertyStub;
    js_cocos2dx_websocket_class->enumerate = JS_EnumerateStub;
    js_cocos2dx_websocket_class->resolve = JS_ResolveStub;
    js_cocos2dx_websocket_class->convert = JS_ConvertStub;
    js_cocos2dx_websocket_class->finalize = js_cocos2dx_WebSocket_finalize;
    js_cocos2dx_websocket_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
    
    static JSPropertySpec properties[] = {
        {"readyState", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_cocos2dx_extension_WebSocket_get_readyState), NULL},
        {0, 0, 0, 0, 0}
    };
    
    static JSFunctionSpec funcs[] = {
        JS_FN("send",js_cocos2dx_extension_WebSocket_send, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("close",js_cocos2dx_extension_WebSocket_close, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };
    
    static JSFunctionSpec st_funcs[] = {
        JS_FS_END
    };
    
    js_cocos2dx_websocket_prototype = JS_InitClass(
                                                cx, global,
                                                NULL,
                                                js_cocos2dx_websocket_class,
                                                js_cocos2dx_extension_WebSocket_constructor, 0, // constructor
                                                properties,
                                                funcs,
                                                NULL, // no static properties
                                                st_funcs);
    
    JSObject* jsclassObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return WebSocket; })()"));

    JS_DefineProperty(cx, jsclassObj, "CONNECTING", INT_TO_JSVAL((int)WebSocket::kStateConnecting)
                      , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
	JS_DefineProperty(cx, jsclassObj, "OPEN", INT_TO_JSVAL((int)WebSocket::kStateOpen)
                      , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
	JS_DefineProperty(cx, jsclassObj, "CLOSING", INT_TO_JSVAL((int)WebSocket::kStateClosing)
                      , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
	JS_DefineProperty(cx, jsclassObj, "CLOSED", INT_TO_JSVAL((int)WebSocket::kStateClosed)
                      , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
    
    // make the class enumerable in the registered namespace
    JSBool found;
    JS_SetPropertyAttributes(cx, global, "WebSocket", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
}
Beispiel #5
0
static JSBool
gjs_exit(JSContext *context,
         unsigned   argc,
         jsval     *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    gint32 ecode;
    if (!gjs_parse_args(context, "exit", "i", argc, argv, "ecode", &ecode))
        return JS_FALSE;
    exit(ecode);
    return JS_TRUE;
}

static JSFunctionSpec module_funcs[] = {
    { "addressOf", JSOP_WRAPPER (gjs_address_of), 1, GJS_MODULE_PROP_FLAGS },
    { "refcount", JSOP_WRAPPER (gjs_refcount), 1, GJS_MODULE_PROP_FLAGS },
    { "breakpoint", JSOP_WRAPPER (gjs_breakpoint), 0, GJS_MODULE_PROP_FLAGS },
    { "gc", JSOP_WRAPPER (gjs_gc), 0, GJS_MODULE_PROP_FLAGS },
    { "exit", JSOP_WRAPPER (gjs_exit), 0, GJS_MODULE_PROP_FLAGS },
    { NULL },
};

JSBool
gjs_js_define_system_stuff(JSContext  *context,
                           JSObject  **module_out)
{
    GjsContext *gjs_context;
    char *program_name;
    jsval value;
    JSBool retval;
void js_register_autogentestbindings_SimpleNativeClass(JSContext *cx, JSObject *global) {
	jsb_SimpleNativeClass_class = (JSClass *)calloc(1, sizeof(JSClass));
	jsb_SimpleNativeClass_class->name = "SimpleNativeClass";
	jsb_SimpleNativeClass_class->addProperty = JS_PropertyStub;
	jsb_SimpleNativeClass_class->delProperty = JS_DeletePropertyStub;
	jsb_SimpleNativeClass_class->getProperty = JS_PropertyStub;
	jsb_SimpleNativeClass_class->setProperty = JS_StrictPropertyStub;
	jsb_SimpleNativeClass_class->enumerate = JS_EnumerateStub;
	jsb_SimpleNativeClass_class->resolve = JS_ResolveStub;
	jsb_SimpleNativeClass_class->convert = JS_ConvertStub;
	jsb_SimpleNativeClass_class->finalize = js_SimpleNativeClass_finalize;
	jsb_SimpleNativeClass_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

	static JSPropertySpec properties[] = {
		{"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
		{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
	};

	static JSFunctionSpec funcs[] = {
		JS_FN("getAnotherMoreComplexField", js_autogentestbindings_SimpleNativeClass_getAnotherMoreComplexField, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("setSomeField", js_autogentestbindings_SimpleNativeClass_setSomeField, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("receivesLongLong", js_autogentestbindings_SimpleNativeClass_receivesLongLong, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("thisReturnsALongLong", js_autogentestbindings_SimpleNativeClass_thisReturnsALongLong, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("getObjectType", js_autogentestbindings_SimpleNativeClass_getObjectType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("setAnotherMoreComplexField", js_autogentestbindings_SimpleNativeClass_setAnotherMoreComplexField, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("setSomeOtherField", js_autogentestbindings_SimpleNativeClass_setSomeOtherField, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("getSomeOtherField", js_autogentestbindings_SimpleNativeClass_getSomeOtherField, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("returnsACString", js_autogentestbindings_SimpleNativeClass_returnsACString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("doSomeProcessing", js_autogentestbindings_SimpleNativeClass_doSomeProcessing, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("getSomeField", js_autogentestbindings_SimpleNativeClass_getSomeField, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("returnsAString", js_autogentestbindings_SimpleNativeClass_returnsAString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
	};

	static JSFunctionSpec st_funcs[] = {
		JS_FN("func", js_autogentestbindings_SimpleNativeClass_func, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FS_END
	};

	jsb_SimpleNativeClass_prototype = JS_InitClass(
		cx, global,
		NULL, // parent proto
		jsb_SimpleNativeClass_class,
		js_autogentestbindings_SimpleNativeClass_constructor, 0, // constructor
		properties,
		funcs,
		NULL, // no static properties
		st_funcs);
	// make the class enumerable in the registered namespace
//	bool found;
//FIXME: Removed in Firefox v27	
//	JS_SetPropertyAttributes(cx, global, "SimpleNativeClass", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

	// add the proto and JSClass to the type->js info hash table
	TypeTest<SimpleNativeClass> t;
	js_type_class_t *p;
	std::string typeName = t.s_name();
	if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
	{
		p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
		p->jsclass = jsb_SimpleNativeClass_class;
		p->proto = jsb_SimpleNativeClass_prototype;
		p->parentProto = NULL;
		_js_global_type_map.insert(std::make_pair(typeName, p));
	}
}
		JS_FN("wrapRender", def_timestep_view_wrapRender, 2, FUNCTION_FLAGS),
	
		JS_FN("wrapTick", def_timestep_view_wrapTick, 1, FUNCTION_FLAGS),
	
		JS_FN("localizePoint", def_timestep_view_localizePoint, 1, FUNCTION_FLAGS),
	
		JS_FS_END
};



#define BAR_PROPERTY_FLAGS (JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED)

static const JSPropertySpec properties[] = {
	{ "width", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_width), JSOP_WRAPPER(def_timestep_view_set_width) },
	{ "height", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_height), JSOP_WRAPPER(def_timestep_view_set_height) },
	{ "x", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_x), JSOP_WRAPPER(def_timestep_view_set_x) },
	{ "y", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_y), JSOP_WRAPPER(def_timestep_view_set_y) },
	{ "offsetX", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_offsetX), JSOP_WRAPPER(def_timestep_view_set_offsetX) },
	{ "offsetY", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_offsetY), JSOP_WRAPPER(def_timestep_view_set_offsetY) },
	{ "widthPercent", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_widthPercent), JSOP_WRAPPER(def_timestep_view_set_widthPercent) },
	{ "heightPercent", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_view_get_heightPercent), JSOP_WRAPPER(def_timestep_view_set_heightPercent) },
	{ "r", 0, BAR_PROPERTY_FLAGS,
Beispiel #8
0
        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;
}

JSFunctionSpec gjs_cairo_context_proto_funcs[] = {
    { "$dispose", JSOP_WRAPPER((JSNative)dispose_func), 0, 0 },
    { "appendPath", JSOP_WRAPPER((JSNative)appendPath_func), 0, 0},
    { "arc", JSOP_WRAPPER((JSNative)arc_func), 0, 0 },
    { "arcNegative", JSOP_WRAPPER((JSNative)arcNegative_func), 0, 0 },
    { "clip", JSOP_WRAPPER((JSNative)clip_func), 0, 0 },
    { "clipExtents", JSOP_WRAPPER((JSNative)clipExtents_func), 0, 0 },
    { "clipPreserve", JSOP_WRAPPER((JSNative)clipPreserve_func), 0, 0 },
    { "closePath", JSOP_WRAPPER((JSNative)closePath_func), 0, 0 },
    { "copyPage", JSOP_WRAPPER((JSNative)copyPage_func), 0, 0 },
    { "copyPath", JSOP_WRAPPER((JSNative)copyPath_func), 0, 0 },
    { "copyPathFlat", JSOP_WRAPPER((JSNative)copyPathFlat_func), 0, 0 },
    { "curveTo", JSOP_WRAPPER((JSNative)curveTo_func), 0, 0 },
    { "deviceToUser", JSOP_WRAPPER((JSNative)deviceToUser_func), 0, 0 },
    { "deviceToUserDistance",JSOP_WRAPPER((JSNative)deviceToUserDistance_func), 0, 0 },
    { "fill", JSOP_WRAPPER((JSNative)fill_func), 0, 0 },
    { "fillPreserve", JSOP_WRAPPER((JSNative)fillPreserve_func), 0, 0 },
Beispiel #9
0
static JSBool
JsTestObject_value_set(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp)
{
	JsTestObject *p = (JsTestObject *)JS_GetPrivate(obj);

	int32_t value;

	JS::ToInt32(cx, vp.get(), &value);

	p->SetValue(value);

	return JS_TRUE;
}

static JSPropertySpec  JsTestObject_properties[] = {
	{"value", 0, JSPROP_ENUMERATE|JSPROP_PERMANENT|JSPROP_SHARED, JSOP_WRAPPER(JsTestObject_value_get), JSOP_WRAPPER(JsTestObject_value_set)},
	{0, 0, 0, 0, 0}
};

// AfxGlImage //////////////////////////////////////////////////////////////////

void AfxGlImage_finalize(JSFreeOp *fop, JSObject *obj)
{
	AfxGlImage *p = (AfxGlImage *)JS_GetPrivate(obj);
	delete p;
}

static JSClass AfxGlImage_class = {
	"AfxGlImage", JSCLASS_HAS_PRIVATE,
	JS_PropertyStub,
	JS_DeletePropertyStub,
Beispiel #10
0
    (JSResolveOp) fundamental_instance_new_resolve, /* needs cast since it's the new resolve signature */
    JS_ConvertStub,
    fundamental_finalize,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
};

static JSPropertySpec gjs_fundamental_instance_proto_props[] = {
    { NULL }
};

static JSFunctionSpec gjs_fundamental_instance_proto_funcs[] = {
    { "toString", JSOP_WRAPPER((JSNative)to_string_func), 0, 0 },
    { NULL }
};

static JSObject *
gjs_lookup_fundamental_prototype(JSContext    *context,
                                 GIObjectInfo *info,
                                 GType         gtype)
{
    JSObject *in_object;
    JSObject *constructor;
    const char *constructor_name;
    jsval value;

    if (info) {
        in_object = gjs_lookup_namespace_object(context, (GIBaseInfo*) info);
Beispiel #11
0
	"location",
	JSCLASS_HAS_PRIVATE,
	JS_PropertyStub, JS_PropertyStub,
	JS_PropertyStub, JS_StrictPropertyStub,
	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL
};

/* Tinyids of properties.  Use negative values to distinguish these
 * from array indexes (even though this object has no array elements).
 * ECMAScript code should not use these directly as in location[-1];
 * future versions of ELinks may change the numbers.  */
enum location_prop {
	JSP_LOC_HREF = -1,
};
JSPropertySpec location_props[] = {
	{ "href",	0,	JSPROP_ENUMERATE|JSPROP_SHARED, JSOP_WRAPPER(location_get_property_href), JSOP_WRAPPER(location_set_property_href) },
	{ NULL }
};


static JSBool
location_get_property_href(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutableHandleValue hvp)
{
	ELINKS_CAST_PROP_PARAMS

	JSObject *parent_win;	/* instance of @window_class */
	struct view_state *vs;

	/* This can be called if @obj if not itself an instance of the
	 * appropriate class but has one in its prototype chain.  Fail
	 * such calls.  */
void js_register_PluginAdColonyJS_PluginAdColony(JSContext *cx, JSObject *global) {
    jsb_sdkbox_PluginAdColony_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_PluginAdColony_class->name = "PluginAdColony";
    jsb_sdkbox_PluginAdColony_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_PluginAdColony_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_PluginAdColony_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_PluginAdColony_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_PluginAdColony_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_PluginAdColony_class->resolve = JS_ResolveStub;
    jsb_sdkbox_PluginAdColony_class->convert = JS_ConvertStub;
    jsb_sdkbox_PluginAdColony_class->finalize = js_PluginAdColonyJS_PluginAdColony_finalize;
    jsb_sdkbox_PluginAdColony_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
        {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FN("getVideosPerReward", js_PluginAdColonyJS_PluginAdColony_getVideosPerReward, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getCustomID", js_PluginAdColonyJS_PluginAdColony_getCustomID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("zoneStatusForZone", js_PluginAdColonyJS_PluginAdColony_zoneStatusForZone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("show", js_PluginAdColonyJS_PluginAdColony_show, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getStatus", js_PluginAdColonyJS_PluginAdColony_getStatus, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("videoAdCurrentlyRunning", js_PluginAdColonyJS_PluginAdColony_videoAdCurrentlyRunning, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("turnAllAdsOff", js_PluginAdColonyJS_PluginAdColony_turnAllAdsOff, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getVendorIdentifier", js_PluginAdColonyJS_PluginAdColony_getVendorIdentifier, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserMetadata", js_PluginAdColonyJS_PluginAdColony_setUserMetadata, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginAdColonyJS_PluginAdColony_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getUniqueDeviceID", js_PluginAdColonyJS_PluginAdColony_getUniqueDeviceID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getAdvertisingIdentifier", js_PluginAdColonyJS_PluginAdColony_getAdvertisingIdentifier, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("userInterestedIn", js_PluginAdColonyJS_PluginAdColony_userInterestedIn, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setCustomID", js_PluginAdColonyJS_PluginAdColony_setCustomID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("notifyIAPComplete", js_PluginAdColonyJS_PluginAdColony_notifyIAPComplete, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getVideoCreditBalance", js_PluginAdColonyJS_PluginAdColony_getVideoCreditBalance, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("cancelAd", js_PluginAdColonyJS_PluginAdColony_cancelAd, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_PluginAdColony_prototype = JS_InitClass(
        cx, global,
        NULL, // parent proto
        jsb_sdkbox_PluginAdColony_class,
        dummy_constructor<sdkbox::PluginAdColony>, 0, // no constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);
    // make the class enumerable in the registered namespace
//  bool found;
//FIXME: Removed in Firefox v27 
//  JS_SetPropertyAttributes(cx, global, "PluginAdColony", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::PluginAdColony> t;
    js_type_class_t *p;
    std::string typeName = t.s_name();
    if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
    {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->jsclass = jsb_sdkbox_PluginAdColony_class;
        p->proto = jsb_sdkbox_PluginAdColony_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
Beispiel #13
0
    } else {
        g_assert_not_reached();
    }
}

/* no idea what this is used for. examples in
 * spidermonkey use -1, -2, -3, etc. for tinyids.
 */
enum ByteArrayTinyId {
    BYTE_ARRAY_TINY_ID_LENGTH = -1
};

JSPropertySpec gjs_byte_array_proto_props[] = {
    { "length", BYTE_ARRAY_TINY_ID_LENGTH,
      JSPROP_PERMANENT,
      JSOP_WRAPPER ((JSPropertyOp) byte_array_length_getter),
      JSOP_WRAPPER ((JSStrictPropertyOp) byte_array_length_setter),
    },
    { NULL }
};

JSFunctionSpec gjs_byte_array_proto_funcs[] = {
    { "toString", JSOP_WRAPPER ((JSNative) to_string_func), 0, 0 },
    { "toGBytes", JSOP_WRAPPER ((JSNative) to_gbytes_func), 0, 0 },
    { NULL }
};

static JSFunctionSpec gjs_byte_array_module_funcs[] = {
    { "fromString", JSOP_WRAPPER (from_string_func), 1, 0 },
    { "fromArray", JSOP_WRAPPER (from_array_func), 1, 0 },
    { "fromGBytes", JSOP_WRAPPER (from_gbytes_func), 1, 0 },
        return JS_FALSE;
    }

    pattern = gjs_cairo_pattern_get_pattern(context, obj);
    filter = cairo_pattern_get_filter(pattern);

    if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
        return JS_FALSE;

    JS_SET_RVAL(context, vp, INT_TO_JSVAL(filter));

    return JS_TRUE;
}

JSFunctionSpec gjs_cairo_surface_pattern_proto_funcs[] = {
    { "setExtend", JSOP_WRAPPER((JSNative)setExtend_func), 0, 0 },
    { "getExtend", JSOP_WRAPPER((JSNative)getExtend_func), 0, 0 },
    { "setFilter", JSOP_WRAPPER((JSNative)setFilter_func), 0, 0 },
    { "getFilter", JSOP_WRAPPER((JSNative)getFilter_func), 0, 0 },
    { NULL }
};

JSObject *
gjs_cairo_surface_pattern_from_pattern(JSContext       *context,
                                       cairo_pattern_t *pattern)
{
    JSObject *object;

    g_return_val_if_fail(context != NULL, NULL);
    g_return_val_if_fail(pattern != NULL, NULL);
    g_return_val_if_fail(cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_SURFACE, NULL);
void js_register_PluginAppodealJS_PluginAppodeal(JSContext *cx, JSObject *global) {
    jsb_sdkbox_PluginAppodeal_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_PluginAppodeal_class->name = "PluginAppodeal";
    jsb_sdkbox_PluginAppodeal_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_PluginAppodeal_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_PluginAppodeal_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_PluginAppodeal_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_PluginAppodeal_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_PluginAppodeal_class->resolve = JS_ResolveStub;
    jsb_sdkbox_PluginAppodeal_class->convert = JS_ConvertStub;
    jsb_sdkbox_PluginAppodeal_class->finalize = js_PluginAppodealJS_PluginAppodeal_finalize;
    jsb_sdkbox_PluginAppodeal_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
        {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FN("isAutocacheEnabled", js_PluginAppodealJS_PluginAppodeal_isAutocacheEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("hideBanner", js_PluginAppodealJS_PluginAppodeal_hideBanner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserGender", js_PluginAppodealJS_PluginAppodeal_setUserGender, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getSDKVersion", js_PluginAppodealJS_PluginAppodeal_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("disableNetworkForAdType", js_PluginAppodealJS_PluginAppodeal_disableNetworkForAdType, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserSmokingAttitude", js_PluginAppodealJS_PluginAppodeal_setUserSmokingAttitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserInterests", js_PluginAppodealJS_PluginAppodeal_setUserInterests, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserBirthday", js_PluginAppodealJS_PluginAppodeal_setUserBirthday, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginAppodealJS_PluginAppodeal_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("disableLocationPermissionCheck", js_PluginAppodealJS_PluginAppodeal_disableLocationPermissionCheck, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserAlcoholAttitude", js_PluginAppodealJS_PluginAppodeal_setUserAlcoholAttitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserOccupation", js_PluginAppodealJS_PluginAppodeal_setUserOccupation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("isReadyForShowWithStyle", js_PluginAppodealJS_PluginAppodeal_isReadyForShowWithStyle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserVkId", js_PluginAppodealJS_PluginAppodeal_setUserVkId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("cacheAd", js_PluginAppodealJS_PluginAppodeal_cacheAd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setAutocache", js_PluginAppodealJS_PluginAppodeal_setAutocache, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setDebugEnabled", js_PluginAppodealJS_PluginAppodeal_setDebugEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserAge", js_PluginAppodealJS_PluginAppodeal_setUserAge, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserEmail", js_PluginAppodealJS_PluginAppodeal_setUserEmail, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("confirmUsage", js_PluginAppodealJS_PluginAppodeal_confirmUsage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserFacebookId", js_PluginAppodealJS_PluginAppodeal_setUserFacebookId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUserRelationship", js_PluginAppodealJS_PluginAppodeal_setUserRelationship, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("showAd", js_PluginAppodealJS_PluginAppodeal_showAd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_PluginAppodeal_prototype = JS_InitClass(
        cx, global,
        NULL, // parent proto
        jsb_sdkbox_PluginAppodeal_class,
        dummy_constructor<sdkbox::PluginAppodeal>, 0, // no constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);
    // make the class enumerable in the registered namespace
//  bool found;
//FIXME: Removed in Firefox v27
//  JS_SetPropertyAttributes(cx, global, "PluginAppodeal", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::PluginAppodeal> t;
    js_type_class_t *p;
    std::string typeName = t.s_name();
    if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
    {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->jsclass = jsb_sdkbox_PluginAppodeal_class;
        p->proto = jsb_sdkbox_PluginAppodeal_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
Beispiel #16
0
    param_finalize,
    NULL,
    NULL,
    NULL, NULL, NULL
};

static JSPropertySpec gjs_param_proto_props[] = {
    { NULL }
};

static JSFunctionSpec gjs_param_proto_funcs[] = {
    { NULL }
};

static JSFunctionSpec gjs_param_constructor_funcs[] = {
    { "_new_internal", JSOP_WRAPPER((JSNative)param_new_internal), 0, 0 },
    { NULL }
};

static JSObject*
gjs_lookup_param_prototype(JSContext    *context)
{
    JSObject *in_object;
    JSObject *constructor;
    jsid gobject_name;
    jsval value;

    gobject_name = gjs_intern_string_to_id(context, "GObject");
    in_object = gjs_lookup_namespace_object_by_name(context, gobject_name);

    if (G_UNLIKELY (!in_object))
void js_register_PluginChartboostJS_PluginChartboost(JSContext *cx, JSObject *global) {
    jsb_sdkbox_PluginChartboost_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_PluginChartboost_class->name = "PluginChartboost";
    jsb_sdkbox_PluginChartboost_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_PluginChartboost_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_PluginChartboost_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_PluginChartboost_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_PluginChartboost_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_PluginChartboost_class->resolve = JS_ResolveStub;
    jsb_sdkbox_PluginChartboost_class->convert = JS_ConvertStub;
    jsb_sdkbox_PluginChartboost_class->finalize = js_PluginChartboostJS_PluginChartboost_finalize;
    jsb_sdkbox_PluginChartboost_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
        {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FN("handleOpenURL", js_PluginChartboostJS_PluginChartboost_handleOpenURL, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setAutoCacheAds", js_PluginChartboostJS_PluginChartboost_setAutoCacheAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setStatusBarBehavior", js_PluginChartboostJS_PluginChartboost_setStatusBarBehavior, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("isAnyViewVisible", js_PluginChartboostJS_PluginChartboost_isAnyViewVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getCustomID", js_PluginChartboostJS_PluginChartboost_getCustomID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("show", js_PluginChartboostJS_PluginChartboost_show, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("cache", js_PluginChartboostJS_PluginChartboost_cache, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setShouldDisplayLoadingViewForMoreApps", js_PluginChartboostJS_PluginChartboost_setShouldDisplayLoadingViewForMoreApps, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setShouldRequestInterstitialsInFirstSession", js_PluginChartboostJS_PluginChartboost_setShouldRequestInterstitialsInFirstSession, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("didPassAgeGate", js_PluginChartboostJS_PluginChartboost_didPassAgeGate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setShouldPrefetchVideoContent", js_PluginChartboostJS_PluginChartboost_setShouldPrefetchVideoContent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginChartboostJS_PluginChartboost_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getAutoCacheAds", js_PluginChartboostJS_PluginChartboost_getAutoCacheAds, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("closeImpression", js_PluginChartboostJS_PluginChartboost_closeImpression, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setCustomID", js_PluginChartboostJS_PluginChartboost_setCustomID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("isAvailable", js_PluginChartboostJS_PluginChartboost_isAvailable, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setShouldPauseClickForConfirmation", js_PluginChartboostJS_PluginChartboost_setShouldPauseClickForConfirmation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_PluginChartboost_prototype = JS_InitClass(
            cx, global,
            NULL, // parent proto
            jsb_sdkbox_PluginChartboost_class,
            dummy_constructor<sdkbox::PluginChartboost>, 0, // no constructor
            properties,
            funcs,
            NULL, // no static properties
            st_funcs);
    // make the class enumerable in the registered namespace
//  bool found;
//FIXME: Removed in Firefox v27
//  JS_SetPropertyAttributes(cx, global, "PluginChartboost", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::PluginChartboost> t;
    js_type_class_t *p;
    std::string typeName = t.s_name();
    if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
    {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->jsclass = jsb_sdkbox_PluginChartboost_class;
        p->proto = jsb_sdkbox_PluginChartboost_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
void js_register_PluginFacebookJS_PluginFacebook(JSContext *cx, JSObject *global) {
    jsb_sdkbox_PluginFacebook_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_PluginFacebook_class->name = "PluginFacebook";
    jsb_sdkbox_PluginFacebook_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_PluginFacebook_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_PluginFacebook_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_PluginFacebook_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_PluginFacebook_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_PluginFacebook_class->resolve = JS_ResolveStub;
    jsb_sdkbox_PluginFacebook_class->convert = JS_ConvertStub;
    jsb_sdkbox_PluginFacebook_class->finalize = js_PluginFacebookJS_PluginFacebook_finalize;
    jsb_sdkbox_PluginFacebook_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
        {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FN("fetchFriends", js_PluginFacebookJS_PluginFacebook_fetchFriends, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getAccessToken", js_PluginFacebookJS_PluginFacebook_getAccessToken, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getUserID", js_PluginFacebookJS_PluginFacebook_getUserID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginFacebookJS_PluginFacebook_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("logout", js_PluginFacebookJS_PluginFacebook_logout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("isLoggedIn", js_PluginFacebookJS_PluginFacebook_isLoggedIn, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("login", js_PluginFacebookJS_PluginFacebook_login, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("getSDKVersion", js_PluginFacebookJS_PluginFacebook_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_PluginFacebook_prototype = JS_InitClass(
        cx, global,
        NULL, // parent proto
        jsb_sdkbox_PluginFacebook_class,
        dummy_constructor<sdkbox::PluginFacebook>, 0, // no constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);
    // make the class enumerable in the registered namespace
//  bool found;
//FIXME: Removed in Firefox v27 
//  JS_SetPropertyAttributes(cx, global, "PluginFacebook", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::PluginFacebook> t;
    js_type_class_t *p;
    std::string typeName = t.s_name();
    if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
    {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->jsclass = jsb_sdkbox_PluginFacebook_class;
        p->proto = jsb_sdkbox_PluginFacebook_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
Beispiel #19
0
        return JS_FALSE;
    }

    pattern = gjs_cairo_pattern_get_pattern(context, obj);
    type = cairo_pattern_get_type(pattern);

    if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
        return JS_FALSE;

    JS_SET_RVAL(context, vp, INT_TO_JSVAL(type));
    return JS_TRUE;
}

JSFunctionSpec gjs_cairo_pattern_proto_funcs[] = {
    // getMatrix
    { "getType", JSOP_WRAPPER((JSNative)getType_func), 0, 0 },
    // setMatrix
    { NULL }
};

/* Public API */

/**
 * gjs_cairo_pattern_construct:
 * @context: the context
 * @object: object to construct
 * @pattern: cairo_pattern to attach to the object
 *
 * Constructs a pattern wrapper giving an empty JSObject and a
 * cairo pattern. A reference to @pattern will be taken.
 *



static const JSFunctionSpec functions[] = {
	
		JS_FS_END
};



#define BAR_PROPERTY_FLAGS (JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED)

static const JSPropertySpec properties[] = {
	{ "x", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_x), JSOP_WRAPPER(def_timestep_image_map_set_x) },
	{ "y", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_y), JSOP_WRAPPER(def_timestep_image_map_set_y) },
	{ "width", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_width), JSOP_WRAPPER(def_timestep_image_map_set_width) },
	{ "height", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_height), JSOP_WRAPPER(def_timestep_image_map_set_height) },
	{ "marginTop", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_marginTop), JSOP_WRAPPER(def_timestep_image_map_set_marginTop) },
	{ "marginRight", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_marginRight), JSOP_WRAPPER(def_timestep_image_map_set_marginRight) },
	{ "marginBottom", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_marginBottom), JSOP_WRAPPER(def_timestep_image_map_set_marginBottom) },
	{ "marginLeft", 0, BAR_PROPERTY_FLAGS,
		JSOP_WRAPPER(def_timestep_image_map_get_marginLeft), JSOP_WRAPPER(def_timestep_image_map_set_marginLeft) },
	{ "url", 0, BAR_PROPERTY_FLAGS,
Beispiel #21
0
    (JSResolveOp) importer_new_resolve, /* needs cast since it's the new resolve signature */
    JS_ConvertStub,
    importer_finalize,
    JSCLASS_NO_OPTIONAL_MEMBERS
};

JSPropertySpec gjs_importer_proto_props[] = {
    { NULL }
};

JSFunctionSpec gjs_importer_proto_funcs[] = {
    { NULL }
};

JSFunctionSpec gjs_global_importer_funcs[] = {
    { "addSubImporter", JSOP_WRAPPER(gjs_importer_add_subimporter), 0, 0 },
    { NULL }
};

static JSObject*
importer_new(JSContext *context,
             gboolean   is_root)
{
    JSObject *importer;
    Importer *priv;
    JSObject *global;
    JSBool found;

    global = gjs_get_import_global(context);

    if (!JS_HasProperty(context, global, gjs_importer_class.name, &found))
void js_register_PluginAppnextJS_PluginAppnext(JSContext *cx, JSObject *global) {
    jsb_sdkbox_PluginAppnext_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_PluginAppnext_class->name = "PluginAppnext";
    jsb_sdkbox_PluginAppnext_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_PluginAppnext_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_PluginAppnext_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_PluginAppnext_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_PluginAppnext_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_PluginAppnext_class->resolve = JS_ResolveStub;
    jsb_sdkbox_PluginAppnext_class->convert = JS_ConvertStub;
    jsb_sdkbox_PluginAppnext_class->finalize = js_PluginAppnextJS_PluginAppnext_finalize;
    jsb_sdkbox_PluginAppnext_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
        {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FN("hideAd", js_PluginAppnextJS_PluginAppnext_hideAd, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("cacheAd", js_PluginAppnextJS_PluginAppnext_cacheAd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("showVideo", js_PluginAppnextJS_PluginAppnext_showVideo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("refreshAds", js_PluginAppnextJS_PluginAppnext_refreshAds, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("isVideoReady", js_PluginAppnextJS_PluginAppnext_isVideoReady, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setRewardsRewardTypeCurrency", js_PluginAppnextJS_PluginAppnext_setRewardsRewardTypeCurrency, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("isAdReady", js_PluginAppnextJS_PluginAppnext_isAdReady, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("refreshVideo", js_PluginAppnextJS_PluginAppnext_refreshVideo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("cacheVideo", js_PluginAppnextJS_PluginAppnext_cacheVideo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginAppnextJS_PluginAppnext_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setRewardsTransactionId", js_PluginAppnextJS_PluginAppnext_setRewardsTransactionId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setRewardsUserId", js_PluginAppnextJS_PluginAppnext_setRewardsUserId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("showAd", js_PluginAppnextJS_PluginAppnext_showAd, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setRewardsCustomParameter", js_PluginAppnextJS_PluginAppnext_setRewardsCustomParameter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setRewardsAmountRewarded", js_PluginAppnextJS_PluginAppnext_setRewardsAmountRewarded, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_PluginAppnext_prototype = JS_InitClass(
        cx, global,
        NULL, // parent proto
        jsb_sdkbox_PluginAppnext_class,
        dummy_constructor<sdkbox::PluginAppnext>, 0, // no constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);
    // make the class enumerable in the registered namespace
//  bool found;
//FIXME: Removed in Firefox v27
//  JS_SetPropertyAttributes(cx, global, "PluginAppnext", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::PluginAppnext> t;
    js_type_class_t *p;
    std::string typeName = t.s_name();
    if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
    {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->jsclass = jsb_sdkbox_PluginAppnext_class;
        p->proto = jsb_sdkbox_PluginAppnext_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
void js_register_PluginGoogleAnalyticsJS_PluginGoogleAnalytics(JSContext *cx, JSObject *global) {
    jsb_sdkbox_PluginGoogleAnalytics_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_PluginGoogleAnalytics_class->name = "PluginGoogleAnalytics";
    jsb_sdkbox_PluginGoogleAnalytics_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_PluginGoogleAnalytics_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_PluginGoogleAnalytics_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_PluginGoogleAnalytics_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_PluginGoogleAnalytics_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_PluginGoogleAnalytics_class->resolve = JS_ResolveStub;
    jsb_sdkbox_PluginGoogleAnalytics_class->convert = JS_ConvertStub;
    jsb_sdkbox_PluginGoogleAnalytics_class->finalize = js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_finalize;
    jsb_sdkbox_PluginGoogleAnalytics_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER},
        {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FN("createTracker", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_createTracker, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setMetric", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_setMetric, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("stopPeriodicalDispatch", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_stopPeriodicalDispatch, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setDryRun", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_setDryRun, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("logEvent", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logEvent, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("dispatchPeriodically", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_dispatchPeriodically, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("logScreen", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logScreen, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("startSession", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_startSession, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("logException", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logException, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setUser", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_setUser, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("stopSession", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_stopSession, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setDimension", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_setDimension, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("logSocial", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logSocial, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("enableAdvertisingTracking", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_enableAdvertisingTracking, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("dispatchHits", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_dispatchHits, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("enableTracker", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_enableTracker, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("logTiming", js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logTiming, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_PluginGoogleAnalytics_prototype = JS_InitClass(
                cx, global,
                NULL, // parent proto
                jsb_sdkbox_PluginGoogleAnalytics_class,
                dummy_constructor<sdkbox::PluginGoogleAnalytics>, 0, // no constructor
                properties,
                funcs,
                NULL, // no static properties
                st_funcs);
    // make the class enumerable in the registered namespace
//  bool found;
//FIXME: Removed in Firefox v27
//  JS_SetPropertyAttributes(cx, global, "PluginGoogleAnalytics", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::PluginGoogleAnalytics> t;
    js_type_class_t *p;
    std::string typeName = t.s_name();
    if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
    {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->jsclass = jsb_sdkbox_PluginGoogleAnalytics_class;
        p->proto = jsb_sdkbox_PluginGoogleAnalytics_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
Beispiel #24
0
    JS_StrictPropertyStub,
    JS_EnumerateStub,
    JS_ResolveStub,
    JS_ConvertStub,
    error_finalize,
    NULL,
    NULL,
    NULL, NULL, NULL
};

/* We need to shadow all fields of GError, to prevent calling the getter from GBoxed
   (which would trash memory accessing the instance private data) */
static JSPropertySpec gjs_error_proto_props[] = {
    { "domain", PROP_DOMAIN,
      GJS_MODULE_PROP_FLAGS | JSPROP_READONLY,
      JSOP_WRAPPER((JSPropertyOp)error_get_domain),
      JSOP_WRAPPER(JS_StrictPropertyStub)
    },
    { "code", PROP_CODE,
      GJS_MODULE_PROP_FLAGS | JSPROP_READONLY,
      JSOP_WRAPPER((JSPropertyOp)error_get_code),
      JSOP_WRAPPER(JS_StrictPropertyStub)
    },
    { "message", PROP_MESSAGE,
      GJS_MODULE_PROP_FLAGS | JSPROP_READONLY,
      JSOP_WRAPPER((JSPropertyOp)error_get_message),
      JSOP_WRAPPER(JS_StrictPropertyStub)
    },
    { NULL }
};
Beispiel #25
0
namespace MozJS {

   // Definition of the global object for the debugger compartment.
   static JSClass JSR_DebuggerEngineGlobalGlass = { "JSRDebuggerGlobal",
       JSCLASS_GLOBAL_FLAGS,
       JS_PropertyStub,
       JS_DeletePropertyStub,
       JS_PropertyStub,
       JS_StrictPropertyStub,
       JS_EnumerateStub,
       JS_ResolveStub,
       JS_ConvertStub,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       { NULL }
   };

   /**
    * Gets source code of the script in a safe way. The default implementation
    * returns critical error which makes the script to end execution if there
    * is no source available. This function returns null instead.
    */
    static JSBool JSR_fn_getSourceSafe( JSContext *context, unsigned int argc, Value *vp ) {

        if( argc != 1 ) {
            JS_ReportError( context, "JSR_fn_getSourceSafe:: Bad args." );
            return JS_FALSE;
        }

        CallArgs args = CallArgsFromVp(argc, vp);

        Value jsTextProperty;
        if( JS_GetProperty( context, args.get(0).toObjectOrNull(), "text", &jsTextProperty ) ) {
            args.rval().set(jsTextProperty);
        } else {
            args.rval().setNull();
        }

        return JS_TRUE;
    }

   /**
    * Prints function arguments into the console.
    */
   static JSBool JSR_fn_print( JSContext *context, unsigned int argc, Value *vp ) {

       if( argc == 0 ) {
           JS_ReportError( context, "JSR_fn_print:: Bad args." );
           return JS_FALSE;
       }

       CallArgs args = CallArgsFromVp(argc, vp);

       string val;

       MozJSUtils jsUtils(context);
       if(!jsUtils.argsToString(argc, JS_ARGV(context, vp), val)) {
           JS_ReportError( context, "JSDebuggerEngine:: Cannot convert arguments to C string." );
           return JS_FALSE;
       }

       // Environment's encoding is used here.
       cout << val << endl;

       args.rval().setNull();

       return JS_TRUE;
   }

   /**
    * Loads script by given script name.
    */
   static JSBool JSR_fn_loadScript( JSContext *cx, unsigned argc, Value *vp ) {

       Logger &log = LoggerFactory::getLogger();

       if( argc != 1 ) {
           JS_ReportError( cx, "Only one argument is allowed." );
           return JS_FALSE;
       }

       // Gets engine for context.
       JSDebuggerEngine *engine = JSDebuggerEngine::getEngineForContext(cx);
       if( !engine ) {
           log.error( "JSR_fn_loadScript:: There is no engine installed for given context." );
           JS_ReportError( cx, "There is no engine installed for given context." );
           return JS_FALSE;
       }

       MozJSUtils jsUtils(cx);

       CallArgs args = CallArgsFromVp(argc, vp);

       string filePath;
       RootedString filePathArg( cx, args.get(0).toString() );
       if( !jsUtils.toString(filePathArg, filePath) ) {
           log.error("JSR_fn_loadScript:: Cannot convert file name to C string.");
           JS_ReportError( cx, "Cannot convert file name to C string." );
           return JS_FALSE;
       }

       JSEngineEventHandler &handler = engine->getEngineEventHandler();

       string script;

       // Pass processing to a custom handler.
       int rc;
       if( ( rc = handler.loadScript( cx, filePath, script ) ) ) {
           log.error( "JSR_fn_loadScript:: Cannot read string using provided callback: %d", rc );
           string msg;
           if( rc == JSR_ERROR_CANNOT_READ_FILE ) {
               msg = "Cannot read string using provided callback. Source file not found: " + filePath;
           } else {
               msg = "Cannot read string using provided callback.";
           }
           JS_ReportError( cx, msg.c_str() );
           return JS_FALSE;
       }

       try {

           if( !script.empty() ) {

               JCharEncoder encoder;
               jstring jscript = encoder.utf8ToWide(script);

               RootedString jsScript(cx);
               if( !jsUtils.fromString( jscript, &jsScript ) ) {
                   log.error("JSR_fn_loadScript:: Cannot read string using provided callback.");
                   JS_ReportError( cx, "Cannot read string using provided callback." );
               }

               args.rval().setString( jsScript );

           } else {
               args.rval().setNull();
           }

       } catch( EncodingFailedException &exc ) {
           log.error("JSR_fn_loadScript:: Encoding failed, cannot encode script to UTF-16.");
           JS_ReportError( cx, "Encoding failed, cannot encode script to UTF-16." );
           return JS_FALSE;
       }

       return JS_TRUE;
   }

   /**
    * Waits for incoming command.
    */
   static JSBool JSR_fn_waitForCommand( JSContext *cx, unsigned argc, Value *vp ) {

       if( argc != 1 ) {
          JS_ReportError( cx, "Function should be called with one argument." );
          return JS_FALSE;
       }

       // Gets engine for context.
       JSDebuggerEngine *engine = JSDebuggerEngine::getEngineForContext(cx);
       if( !engine ) {
           JS_ReportError( cx, "There is no engine installed for given context." );
           return JS_FALSE;
       }

       // Inform the debugger what to do next.
       CallArgs args = CallArgsFromVp(argc, vp);

       // Enter the command loop.
       bool result = engine->getEngineEventHandler().waitForCommand( cx, args.get(0).toBoolean() );

       args.rval().setInt32( result ? JSENG_WFC_RES_CONTINUE : JSENG_WFC_RES_INTERRUPTED );

       return JS_TRUE;
   }

   /**
    * Sends command to the remote client.
    */
   static JSBool JSR_fn_sendCommand( JSContext *cx, unsigned argc, Value *vp ) {

       if( argc != 2 ) {
           JS_ReportError( cx, "Function should be called with exactly two arguments." );
           return JS_FALSE;
       }

       Logger &log = LoggerFactory::getLogger();

       // Gets engine for context.
       JSDebuggerEngine *engine = JSDebuggerEngine::getEngineForContext(cx);
       if( !engine ) {
           log.error("JSR_fn_sendCommand: There is no engine installed for given context." );
           JS_ReportError( cx, "There is no engine installed for given context." );
           return JS_FALSE;
       }

       CallArgs args = CallArgsFromVp(argc, vp);

       int clientId = args.get(0).toInt32();

       // Convert object into UTF-16 string using standard stringify logic.
       Value jsCommandStr = args.get(1);

       MozJSUtils jsUtils(cx);

       string commandStr;
       if( !jsUtils.stringifyToUtf8( jsCommandStr, commandStr ) ) {
           if( jsUtils.getLastError() == MozJSUtils::ERROR_JS_STRINGIFY_FAILED ) {
               log.error("JSR_fn_sendCommand: Cannot stringify debugger command.");
               if( !JS_IsExceptionPending( cx ) ) {
                   // Only if there is no exception from the stringify.
                   JS_ReportError( cx, "Cannot stringify debugger command." );
               }
               return JS_FALSE;
           } else if( jsUtils.getLastError() == MozJSUtils::ERROR_CHAR_ENCODING_FAILED ) {
               // Only if there is no exception from the stringify.
               log.error("JSR_fn_sendCommand: Cannot convert command string into UTF-8." );
               JS_ReportError( cx, "Cannot convert command string into UTF-8." );
               return JS_FALSE;
           } else {
               // Unknown error.
               log.error("JSR_fn_sendCommand: Stringify failed with error: %d", jsUtils.getLastError() );
               JS_ReportError( cx, "Stringify failed with unsupported error code." );
               return JS_FALSE;
           }
       }

       // Send command using provided handler.
       if( !engine->getEngineEventHandler().sendCommand( clientId, engine->getContextId(), commandStr ) ) {
           log.warn( "JSR_fn_sendCommand: Engine couldn't send a command for client: %d", clientId );
           if( !JS_IsExceptionPending( cx ) ) {
               JS_ReportError( cx, "Cannot send command, probably client has already been disconnected." );
           }
           return JS_FALSE;
       }

       return JS_TRUE;
   }

   static JSFunctionSpec JSR_EngineEnvironmentFuntions[] = {
       { "getSourceSafe", JSOP_WRAPPER ( JSR_fn_getSourceSafe ), 0, JSPROP_PERMANENT | JSPROP_ENUMERATE },
       { "print", JSOP_WRAPPER ( JSR_fn_print ), 0, JSPROP_PERMANENT | JSPROP_ENUMERATE },
       { "loadScriptSource", JSOP_WRAPPER (JSR_fn_loadScript), 0, JSPROP_PERMANENT | JSPROP_ENUMERATE },
       { "waitForCommand", JSOP_WRAPPER (JSR_fn_waitForCommand), 0, JSPROP_PERMANENT | JSPROP_ENUMERATE },
       { "sendCommand", JSOP_WRAPPER (JSR_fn_sendCommand), 0, JSPROP_PERMANENT | JSPROP_ENUMERATE },
       JS_FS_END
   };

}