当前位置: 首页>>代码示例>>C++>>正文


C++ JS_FN函数代码示例

本文整理汇总了C++中JS_FN函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_FN函数的具体用法?C++ JS_FN怎么用?C++ JS_FN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了JS_FN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: register_jsb_websocket

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_DeletePropertyStub;
    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::State::CONNECTING)
                      , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
	JS_DefineProperty(cx, jsclassObj, "OPEN", INT_TO_JSVAL((int)WebSocket::State::OPEN)
                      , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
	JS_DefineProperty(cx, jsclassObj, "CLOSING", INT_TO_JSVAL((int)WebSocket::State::CLOSING)
                      , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
	JS_DefineProperty(cx, jsclassObj, "CLOSED", INT_TO_JSVAL((int)WebSocket::State::CLOSED)
                      , 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);
}
开发者ID:csouls,项目名称:nyangame-v3,代码行数:54,代码来源:jsb_websocket.cpp

示例2: js_register_cocos2dx_GLNode

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

    static JSPropertySpec properties[] = {
        {0, 0, 0, 0, 0}
    };

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

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

    js_cocos2dx_GLNode_prototype = JS_InitClass(
        cx, global,
        jsb_cocos2d_Node_prototype,
        js_cocos2dx_GLNode_class,
        js_cocos2dx_GLNode_constructor, 0, // constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);
    // make the class enumerable in the registered namespace
//    bool found;
//    JS_SetPropertyAttributes(cx, global, "GLNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<GLNode> 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 = js_cocos2dx_GLNode_class;
        p->proto = js_cocos2dx_GLNode_prototype;
        p->parentProto = jsb_cocos2d_Node_prototype;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
开发者ID:2youyou2,项目名称:cocos2d-js,代码行数:53,代码来源:js_bindings_opengl.cpp

示例3: js_register_PluginVungleJS_PluginVungle

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

    JSPropertySpec *properties = NULL;

    JSFunctionSpec *funcs = NULL;

    static JSFunctionSpec st_funcs[] = {
        JS_FN("setUserID", js_PluginVungleJS_PluginVungle_setUserID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("show", js_PluginVungleJS_PluginVungle_show, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_PluginVungleJS_PluginVungle_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setDebug", js_PluginVungleJS_PluginVungle_setDebug, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("isCacheAvailable", js_PluginVungleJS_PluginVungle_isCacheAvailable, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    jsb_sdkbox_PluginVungle_prototype = JS_InitClass(
        cx, global,
        NULL, // parent proto
        jsb_sdkbox_PluginVungle_class,
        dummy_constructor<sdkbox::PluginVungle>, 0, // no constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);
    // make the class enumerable in the registered namespace
    JSBool found;
    JS_SetPropertyAttributes(cx, global, "PluginVungle", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<sdkbox::PluginVungle> t;
    js_type_class_t *p;
    uint32_t typeId = t.s_id();
    HASH_FIND_INT(_js_global_type_ht, &typeId, p);
    if (!p) {
        p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
        p->type = typeId;
        p->jsclass = jsb_sdkbox_PluginVungle_class;
        p->proto = jsb_sdkbox_PluginVungle_prototype;
        p->parentProto = NULL;
        HASH_ADD_INT(_js_global_type_ht, type, p);
    }
}
开发者ID:pabitrapadhy,项目名称:sdkbox-vungle-sample,代码行数:53,代码来源:PluginVungleJS.cpp

示例4: js_register_coolexp_ErayLayer

void js_register_coolexp_ErayLayer(JSContext *cx, JS::HandleObject global) {
    jsb_ErayLayer_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_ErayLayer_class->name = "ErayLayer";
    jsb_ErayLayer_class->addProperty = JS_PropertyStub;
    jsb_ErayLayer_class->delProperty = JS_DeletePropertyStub;
    jsb_ErayLayer_class->getProperty = JS_PropertyStub;
    jsb_ErayLayer_class->setProperty = JS_StrictPropertyStub;
    jsb_ErayLayer_class->enumerate = JS_EnumerateStub;
    jsb_ErayLayer_class->resolve = JS_ResolveStub;
    jsb_ErayLayer_class->convert = JS_ConvertStub;
    jsb_ErayLayer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        JS_PS_END
    };

    static JSFunctionSpec funcs[] = {
        JS_FN("init", js_coolexp_ErayLayer_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setDelegate", js_coolexp_ErayLayer_setDelegate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("ctor", js_coolexp_ErayLayer_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

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

    JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype);
    jsb_ErayLayer_prototype = JS_InitClass(
        cx, global,
        parent_proto,
        jsb_ErayLayer_class,
        js_coolexp_ErayLayer_constructor, 0, // constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);

    JS::RootedObject proto(cx, jsb_ErayLayer_prototype);
    JS::RootedValue className(cx, std_string_to_jsval(cx, "ErayLayer"));
    JS_SetProperty(cx, proto, "_className", className);
    JS_SetProperty(cx, proto, "__nativeObj", JS::TrueHandleValue);
    JS_SetProperty(cx, proto, "__is_ref", JS::TrueHandleValue);
    // add the proto and JSClass to the type->js info hash table
    jsb_register_class<ErayLayer>(cx, jsb_ErayLayer_class, proto, parent_proto);
    anonEvaluate(cx, global, "(function () { .ErayLayer.extend = cc.Class.extend; })()");
}
开发者ID:coolexp,项目名称:HelloCocosJS,代码行数:48,代码来源:jsb_coolexp_auto.cpp

示例5: js_register_myClass

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

	static JSPropertySpec properties[] = {
		{ 0, 0, 0, 0, 0 }
	};
	static JSFunctionSpec funcs[] = { 
		JS_FN("functionTest", js_my_functionTest, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FS_END
	};
	static JSFunctionSpec st_funcs[] = {
		JS_FS_END
	};
	jsb_my_prototype = JS_InitClass(
		cx, global,
		NULL, // parent proto
		jsb_my_class,
		js_myClass_constructor, 0, // constructor
		properties,
		funcs,
		NULL, // no static properties
		st_funcs);	
}
开发者ID:VirtuosWangH,项目名称:HTML5RESEARCH,代码行数:33,代码来源:JSB_Manual_Test.cpp

示例6: sizeof

void S_AnotherClass::jsCreateClass(JSContext *cx, JSObject *globalObj, const char *name)
{
	jsClass = (JSClass *)calloc(1, sizeof(JSClass));
	jsClass->name = name;
	jsClass->addProperty = JS_PropertyStub;
	jsClass->delProperty = JS_PropertyStub;
	jsClass->getProperty = JS_PropertyStub;
	jsClass->setProperty = JS_StrictPropertyStub;
	jsClass->enumerate = JS_EnumerateStub;
	jsClass->resolve = JS_ResolveStub;
	jsClass->convert = JS_ConvertStub;
	jsClass->finalize = jsFinalize;
	jsClass->flags = JSCLASS_HAS_PRIVATE;
		static JSPropertySpec properties[] = {
			{"aPublicField", kAPublicField, JSPROP_PERMANENT | JSPROP_SHARED, S_AnotherClass::jsPropertyGet, S_AnotherClass::jsPropertySet},
			{"justOneField", kJustOneField, JSPROP_PERMANENT | JSPROP_SHARED, S_AnotherClass::jsPropertyGet, S_AnotherClass::jsPropertySet},
			{0, 0, 0, 0, 0}
		};

		static JSFunctionSpec funcs[] = {
			JS_FN("doSomethingSimple", S_AnotherClass::jsdoSomethingSimple, 0, JSPROP_PERMANENT | JSPROP_SHARED),
			JS_FS_END
		};

		static JSFunctionSpec st_funcs[] = {
			JS_FS_END
		};

	jsObject = JS_InitClass(cx,globalObj,NULL,jsClass,S_AnotherClass::jsConstructor,0,properties,funcs,NULL,st_funcs);
}
开发者ID:funkaster,项目名称:testjs,代码行数:30,代码来源:simple_native_generated.cpp

示例7: JSB_IOSiAP_createClass

static void JSB_IOSiAP_createClass(JSContext *cx, JSObject* globalObj, const char* name)
{
	JSB_IOSiAP_class = (JSClass *)calloc(1, sizeof(JSClass));
	JSB_IOSiAP_class->name = name;
	JSB_IOSiAP_class->addProperty = JS_PropertyStub;
	JSB_IOSiAP_class->delProperty = JS_DeletePropertyStub;
	JSB_IOSiAP_class->getProperty = JS_PropertyStub;
	JSB_IOSiAP_class->setProperty = JS_StrictPropertyStub;
	JSB_IOSiAP_class->enumerate = JS_EnumerateStub;
	JSB_IOSiAP_class->resolve = JS_ResolveStub;
	JSB_IOSiAP_class->convert = JS_ConvertStub;
	JSB_IOSiAP_class->finalize = JSB_IOSiAP_finalize;
	JSB_IOSiAP_class->flags = JSCLASS_HAS_PRIVATE;
	
    // no property for this class
	static JSPropertySpec properties[] = {
        {0, 0, 0, 0, 0}
	};
    
    // define member function
	static JSFunctionSpec funcs[] = {
        // param: array[string] to hold identifier of iAp items
		JS_FN("requestProducts", JSB_IOSiAP_requestProducts, 1, JSPROP_PERMANENT  | JSPROP_ENUMERATE),
        // param: string of identifier
        JS_FN("iOSProductByIdentifier", JSB_IOSiAP_iOSProductByIdentifier, 1, JSPROP_PERMANENT  | JSPROP_ENUMERATE),
        // param[0] : js object of Product
        // param[1] : quantity (Option, Default value = 1)
        JS_FN("paymentWithProduct", JSB_IOSiAP_paymentWithProduct, 2, JSPROP_PERMANENT  | JSPROP_ENUMERATE),
		JS_FS_END
	};
    
	static JSFunctionSpec st_funcs[] = {
		JS_FS_END
	};
	
	JSB_IOSiAP_object = JS_InitClass(
                                      cx,
                                      globalObj,
                                      NULL,
                                      JSB_IOSiAP_class,
                                      JSB_IOSiAP_constructor,
                                      0,
                                      properties,
                                      funcs,
                                      NULL,
                                      st_funcs);
}
开发者ID:1007650105,项目名称:cocos-docs,代码行数:47,代码来源:IOSiAP_JSB.cpp

示例8: js_register_PluginShareJS_PluginShare

void js_register_PluginShareJS_PluginShare(JSContext *cx, JS::HandleObject global) {
    jsb_sdkbox_PluginShare_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_sdkbox_PluginShare_class->name = "PluginShare";
    jsb_sdkbox_PluginShare_class->addProperty = JS_PropertyStub;
    jsb_sdkbox_PluginShare_class->delProperty = JS_DeletePropertyStub;
    jsb_sdkbox_PluginShare_class->getProperty = JS_PropertyStub;
    jsb_sdkbox_PluginShare_class->setProperty = JS_StrictPropertyStub;
    jsb_sdkbox_PluginShare_class->enumerate = JS_EnumerateStub;
    jsb_sdkbox_PluginShare_class->resolve = JS_ResolveStub;
    jsb_sdkbox_PluginShare_class->convert = JS_ConvertStub;
    jsb_sdkbox_PluginShare_class->finalize = js_PluginShareJS_PluginShare_finalize;
    jsb_sdkbox_PluginShare_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_PS_END
    };

    static JSFunctionSpec funcs[] = {
        JS_FS_END
    };

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

    jsb_sdkbox_PluginShare_prototype = JS_InitClass(
        cx, global,
        JS::NullPtr(), // parent proto
        jsb_sdkbox_PluginShare_class,
        dummy_constructor<sdkbox::PluginShare>, 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, "PluginShare", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
#if (COCOS2D_VERSION >= 0x00031000)
    JS::RootedObject proto(cx, jsb_sdkbox_PluginShare_prototype);
    jsb_register_class<sdkbox::PluginShare>(cx, jsb_sdkbox_PluginShare_class, proto, JS::NullPtr());
#else
    TypeTest<sdkbox::PluginShare> 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_PluginShare_class;
        p->proto = jsb_sdkbox_PluginShare_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
#endif
}
开发者ID:tinybearc,项目名称:sdkbox-share-sample,代码行数:59,代码来源:PluginShareJS.cpp

示例9: js_register_cocos2dx_DrawNode3D

void js_register_cocos2dx_DrawNode3D(JSContext *cx, JS::HandleObject global) {
    jsb_cocos2d_DrawNode3D_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_cocos2d_DrawNode3D_class->name = "DrawNode3D";
    jsb_cocos2d_DrawNode3D_class->addProperty = JS_PropertyStub;
    jsb_cocos2d_DrawNode3D_class->delProperty = JS_DeletePropertyStub;
    jsb_cocos2d_DrawNode3D_class->getProperty = JS_PropertyStub;
    jsb_cocos2d_DrawNode3D_class->setProperty = JS_StrictPropertyStub;
    jsb_cocos2d_DrawNode3D_class->enumerate = JS_EnumerateStub;
    jsb_cocos2d_DrawNode3D_class->resolve = JS_ResolveStub;
    jsb_cocos2d_DrawNode3D_class->convert = JS_ConvertStub;
    jsb_cocos2d_DrawNode3D_class->finalize = js_cocos2d_DrawNode3D_finalize;
    jsb_cocos2d_DrawNode3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_PS_END
    };

    static JSFunctionSpec funcs[] = {
        JS_FN("getBlendFunc", js_cocos2dx_DrawNode3D_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setBlendFunc", js_cocos2dx_DrawNode3D_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("drawLine", js_cocos2dx_DrawNode3D_drawLine, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("clear", js_cocos2dx_DrawNode3D_clear, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("onDraw", js_cocos2dx_DrawNode3D_onDraw, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("init", js_cocos2dx_DrawNode3D_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("drawCube", js_cocos2dx_DrawNode3D_drawCube, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    static JSFunctionSpec st_funcs[] = {
        JS_FS_END
    };

    jsb_cocos2d_DrawNode3D_prototype = JS_InitClass(
        cx, global,
        JS::RootedObject(cx, jsb_cocos2d_Node_prototype),
        jsb_cocos2d_DrawNode3D_class,
        js_cocos2dx_DrawNode3D_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, "DrawNode3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<cocos2d::DrawNode3D> 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_cocos2d_DrawNode3D_class;
        p->proto = jsb_cocos2d_DrawNode3D_prototype;
        p->parentProto = jsb_cocos2d_Node_prototype;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
开发者ID:1414648814,项目名称:cocos2d-js,代码行数:60,代码来源:js_DrawNode3D_bindings.cpp

示例10: js_register_cocos2dx_nativehelper_NativeHelper

void js_register_cocos2dx_nativehelper_NativeHelper(JSContext *cx, JS::HandleObject global) {
    jsb_cocos2d_NativeHelper_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_cocos2d_NativeHelper_class->name = "NativeHelper";
    jsb_cocos2d_NativeHelper_class->addProperty = JS_PropertyStub;
    jsb_cocos2d_NativeHelper_class->delProperty = JS_DeletePropertyStub;
    jsb_cocos2d_NativeHelper_class->getProperty = JS_PropertyStub;
    jsb_cocos2d_NativeHelper_class->setProperty = JS_StrictPropertyStub;
    jsb_cocos2d_NativeHelper_class->enumerate = JS_EnumerateStub;
    jsb_cocos2d_NativeHelper_class->resolve = JS_ResolveStub;
    jsb_cocos2d_NativeHelper_class->convert = JS_ConvertStub;
    jsb_cocos2d_NativeHelper_class->finalize = js_cocos2d_NativeHelper_finalize;
    jsb_cocos2d_NativeHelper_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_PS_END
    };

    static JSFunctionSpec funcs[] = {
        JS_FN("recvJsMsg", js_cocos2dx_nativehelper_NativeHelper_recvJsMsg, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("startSendMsg", js_cocos2dx_nativehelper_NativeHelper_startSendMsg, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setPacketAssembler", js_cocos2dx_nativehelper_NativeHelper_setPacketAssembler, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("setCallBack", js_cocos2dx_nativehelper_NativeHelper_setCallBack, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("sendJsMsg", js_cocos2dx_nativehelper_NativeHelper_sendJsMsg, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("test", js_cocos2dx_nativehelper_NativeHelper_test, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

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

    jsb_cocos2d_NativeHelper_prototype = JS_InitClass(
        cx, global,
        JS::NullPtr(), // parent proto
        jsb_cocos2d_NativeHelper_class,
        dummy_constructor<cocos2d::NativeHelper>, 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, "NativeHelper", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<cocos2d::NativeHelper> 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_cocos2d_NativeHelper_class;
        p->proto = jsb_cocos2d_NativeHelper_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
开发者ID:xungong91,项目名称:ZjhMobile,代码行数:60,代码来源:jsb_cocos2dx_nativehelper.cpp

示例11: js_register_cocos2dx_GLNode

void js_register_cocos2dx_GLNode(JSContext *cx, JS::HandleObject global) {
    js_cocos2dx_GLNode_class = (JSClass *)calloc(1, sizeof(JSClass));
    js_cocos2dx_GLNode_class->name = "GLNode";
    js_cocos2dx_GLNode_class->addProperty = JS_PropertyStub;
    js_cocos2dx_GLNode_class->delProperty = JS_DeletePropertyStub;
    js_cocos2dx_GLNode_class->getProperty = JS_PropertyStub;
    js_cocos2dx_GLNode_class->setProperty = JS_StrictPropertyStub;
    js_cocos2dx_GLNode_class->enumerate = JS_EnumerateStub;
    js_cocos2dx_GLNode_class->resolve = JS_ResolveStub;
    js_cocos2dx_GLNode_class->convert = JS_ConvertStub;
    js_cocos2dx_GLNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        {0, 0, 0, 0, 0}
    };

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

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

    JS::RootedObject parentProto(cx, jsb_cocos2d_Node_prototype);
    js_cocos2dx_GLNode_prototype = JS_InitClass(
        cx, global,
        parentProto,
        js_cocos2dx_GLNode_class,
        js_cocos2dx_GLNode_constructor, 0, // constructor
        properties,
        funcs,
        NULL, // no static properties
        st_funcs);

    // add the proto and JSClass to the type->js info hash table
    JS::RootedObject proto(cx, js_cocos2dx_GLNode_prototype);
    jsb_register_class<cocos2d::GLNode>(cx, js_cocos2dx_GLNode_class, proto, parentProto);

    anonEvaluate(cx, global, "(function () { cc.GLNode.extend = cc.Class.extend; })()");
}
开发者ID:FenneX,项目名称:FenneXEmptyProject,代码行数:43,代码来源:js_bindings_opengl.cpp

示例12: js_register_FlatUtil

void js_register_FlatUtil(JSContext *cx, JS::HandleObject global) {
    jsb_FlatUtil_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_FlatUtil_class->name = "FlatUtil";
    jsb_FlatUtil_class->addProperty = JS_PropertyStub;
    jsb_FlatUtil_class->delProperty = JS_DeletePropertyStub;
    jsb_FlatUtil_class->getProperty = JS_PropertyStub;
    jsb_FlatUtil_class->setProperty = JS_StrictPropertyStub;
    jsb_FlatUtil_class->enumerate = JS_EnumerateStub;
    jsb_FlatUtil_class->resolve = JS_ResolveStub;
    jsb_FlatUtil_class->convert = JS_ConvertStub;
    jsb_FlatUtil_class->finalize = jsb_ref_finalize;
    jsb_FlatUtil_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
    
    static JSPropertySpec properties[] = {
        JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_PS_END
    };
    
    static JSFunctionSpec *funcs = NULL;
    
    static JSFunctionSpec st_funcs[] = {
        JS_FN("default4js", js_FlatUtil_default4js, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("flat2js", js_FlatUtil_flat2js, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("js2flat", js_FlatUtil_js2flat, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FN("clear", js_FlatUtil_clear, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };
    
    jsb_FlatUtil_prototype = JS_InitClass(
                                          cx, global,
                                          JS::NullPtr(),
                                          jsb_FlatUtil_class,
                                          empty_constructor, 0,
                                          properties,
                                          funcs,
                                          NULL, // no static properties
                                          st_funcs);
    
    // add the proto and JSClass to the type->js info hash table
    JS::RootedObject proto(cx, jsb_FlatUtil_prototype);
    jsb_register_class<FlatUtil>(cx, jsb_FlatUtil_class, proto, JS::NullPtr());
}
开发者ID:darklinden,项目名称:flat2js,代码行数:42,代码来源:jsb_flatutil_manual.cpp

示例13: js_register_cocos2dx_extension_ImagePickerDelegate

void js_register_cocos2dx_extension_ImagePickerDelegate(JSContext *cx, JS::HandleObject global) {
    jsb_cocos2d_ImagePickerDelegate_class = (JSClass *)calloc(1, sizeof(JSClass));
    jsb_cocos2d_ImagePickerDelegate_class->name = "ImagePickerDelegate";
    jsb_cocos2d_ImagePickerDelegate_class->addProperty = JS_PropertyStub;
    jsb_cocos2d_ImagePickerDelegate_class->delProperty = JS_DeletePropertyStub;
    jsb_cocos2d_ImagePickerDelegate_class->getProperty = JS_PropertyStub;
    jsb_cocos2d_ImagePickerDelegate_class->setProperty = JS_StrictPropertyStub;
    jsb_cocos2d_ImagePickerDelegate_class->enumerate = JS_EnumerateStub;
    jsb_cocos2d_ImagePickerDelegate_class->resolve = JS_ResolveStub;
    jsb_cocos2d_ImagePickerDelegate_class->convert = JS_ConvertStub;
    jsb_cocos2d_ImagePickerDelegate_class->finalize = js_cocos2d_ImagePickerDelegate_finalize;
    jsb_cocos2d_ImagePickerDelegate_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);

    static JSPropertySpec properties[] = {
        JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_PS_END
    };

    static JSFunctionSpec funcs[] = {
        JS_FN("didFinishPickingWithResult", js_cocos2dx_extension_ImagePickerDelegate_didFinishPickingWithResult, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
    };

    JSFunctionSpec *st_funcs = NULL;

    jsb_cocos2d_ImagePickerDelegate_prototype = JS_InitClass(
        cx, global,
        JS::NullPtr(), // parent proto
        jsb_cocos2d_ImagePickerDelegate_class,
        js_cocos2dx_extension_ImagePickerDelegate_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, "ImagePickerDelegate", JSPROP_ENUMERATE | JSPROP_READONLY, &found);

    // add the proto and JSClass to the type->js info hash table
    TypeTest<JSBImagePickerDelegate> 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_cocos2d_ImagePickerDelegate_class;
        p->proto = jsb_cocos2d_ImagePickerDelegate_prototype;
        p->parentProto = NULL;
        _js_global_type_map.insert(std::make_pair(typeName, p));
    }
}
开发者ID:NikhilShetye,项目名称:ImagePicker,代码行数:52,代码来源:jsb_cocos2dx_extension_ImagePicker.cpp

示例14: js_register_cocos2dx_spine_SkeletonAnimation

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));
	}
}
开发者ID:2youyou2,项目名称:cocos2d-js,代码行数:59,代码来源:jsb_cocos2dx_spine_auto.cpp

示例15: js_register_PluginIAPJS_IAP

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));
    }
}
开发者ID:tinybearc,项目名称:sdkbox-sample-iap,代码行数:59,代码来源:PluginIAPJS.cpp


注:本文中的JS_FN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。