mirror of https://github.com/axmolengine/axmol.git
Fix issues causing by temporary RootedObject passed as function parameters
This commit is contained in:
parent
c202834312
commit
ae2b75c8be
|
@ -350,22 +350,26 @@ void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global)
|
||||||
get_or_create_js_obj(cx, global, "jsb", &ccObj);
|
get_or_create_js_obj(cx, global, "jsb", &ccObj);
|
||||||
|
|
||||||
JS_GetProperty(cx, ccObj, "Sprite3D", &tmpVal);
|
JS_GetProperty(cx, ccObj, "Sprite3D", &tmpVal);
|
||||||
tmpObj = tmpVal.toObjectOrNull();
|
tmpObj.set(tmpVal.toObjectOrNull());
|
||||||
JS_DefineFunction(cx, tmpObj, "createAsync", js_cocos2dx_Sprite3D_createAsync, 4, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "createAsync", js_cocos2dx_Sprite3D_createAsync, 4, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_GetProperty(cx, ccObj, "Terrain", &tmpVal);
|
JS_GetProperty(cx, ccObj, "Terrain", &tmpVal);
|
||||||
tmpObj = tmpVal.toObjectOrNull();
|
tmpObj.set(tmpVal.toObjectOrNull());
|
||||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_Terrain_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_Terrain_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_GetProperty(cx, ccObj, "Bundle3D", &tmpVal);
|
JS_GetProperty(cx, ccObj, "Bundle3D", &tmpVal);
|
||||||
tmpObj = tmpVal.toObjectOrNull();
|
tmpObj.set(tmpVal.toObjectOrNull());
|
||||||
JS_DefineFunction(cx, tmpObj, "getTrianglesList", js_cocos2dx_Bundle3D_getTrianglesList, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "getTrianglesList", js_cocos2dx_Bundle3D_getTrianglesList, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), "getAABB", js_cocos2dx_Sprite3D_getAABB, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocos2d_Sprite3D_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "getAABB", js_cocos2dx_Sprite3D_getAABB, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
|
tmpObj.set(jsb_cocos2d_Mesh_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "getMeshVertexAttribute", js_cocos2dx_Mesh_getMeshVertexAttribute, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Mesh_prototype), "getMeshVertexAttribute", js_cocos2dx_Mesh_getMeshVertexAttribute, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocos2d_TextureCube_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "setTexParameters", js_cocos2dx_CCTextureCube_setTexParameters, 4, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_TextureCube_prototype), "setTexParameters", js_cocos2dx_CCTextureCube_setTexParameters, 4, JSPROP_READONLY | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocos2d_Terrain_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "getHeightData", js_cocos2dx_Terrain_getHeightData, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Terrain_prototype), "getHeightData", js_cocos2dx_Terrain_getHeightData, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,6 @@ static std::vector<sc_register_sth> registrationList;
|
||||||
static std::unordered_map<std::string, JSScript*> filename_script;
|
static std::unordered_map<std::string, JSScript*> filename_script;
|
||||||
// port ~> socket map
|
// port ~> socket map
|
||||||
static std::unordered_map<int,int> ports_sockets;
|
static std::unordered_map<int,int> ports_sockets;
|
||||||
// name ~> globals
|
|
||||||
static std::unordered_map<std::string, JSObject*> globals;
|
|
||||||
|
|
||||||
static void cc_closesocket(int fd)
|
static void cc_closesocket(int fd)
|
||||||
{
|
{
|
||||||
|
@ -135,7 +133,8 @@ static void executeJSFunctionFromReservedSpot(JSContext *cx, JS::HandleObject ob
|
||||||
JS_CallFunctionValue(cx, obj, func, dataVal, retval);
|
JS_CallFunctionValue(cx, obj, func, dataVal, retval);
|
||||||
} else {
|
} else {
|
||||||
assert(!thisObj.isPrimitive());
|
assert(!thisObj.isPrimitive());
|
||||||
JS_CallFunctionValue(cx, JS::RootedObject(cx, thisObj.toObjectOrNull()), func, dataVal, retval);
|
JS::RootedObject jsthis(cx, thisObj.toObjectOrNull());
|
||||||
|
JS_CallFunctionValue(cx, jsthis, func, dataVal, retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +250,8 @@ void ScriptingCore::executeJSFunctionWithThisObj(JS::HandleValue thisObj,
|
||||||
// So we have to check the availability of 'retVal'.
|
// So we have to check the availability of 'retVal'.
|
||||||
// if (retVal)
|
// if (retVal)
|
||||||
// {
|
// {
|
||||||
JS_CallFunctionValue(_cx, JS::RootedObject(_cx, thisObj.toObjectOrNull()), callback, vp, retVal);
|
JS::RootedObject jsthis(_cx, thisObj.toObjectOrNull());
|
||||||
|
JS_CallFunctionValue(_cx, jsthis, callback, vp, retVal);
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
|
@ -511,7 +511,8 @@ bool ScriptingCore::evalString(const char *string, jsval *outVal, const char *fi
|
||||||
global = _global.ref().get();
|
global = _global.ref().get();
|
||||||
|
|
||||||
JSAutoCompartment ac(cx, global);
|
JSAutoCompartment ac(cx, global);
|
||||||
return JS_EvaluateScript(cx, JS::RootedObject(cx, global), string, strlen(string), "ScriptingCore::evalString", 1);
|
JS::RootedObject jsglobal(cx, global);
|
||||||
|
return JS_EvaluateScript(cx, jsglobal, string, (unsigned)strlen(string), "ScriptingCore::evalString", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingCore::start()
|
void ScriptingCore::start()
|
||||||
|
@ -643,7 +644,7 @@ JSScript* ScriptingCore::getScript(const char *path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingCore::compileScript(const char *path, JSObject* global, JSContext* cx)
|
void ScriptingCore::compileScript(const char *path, JS::HandleObject global, JSContext* cx)
|
||||||
{
|
{
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return;
|
return;
|
||||||
|
@ -655,9 +656,6 @@ void ScriptingCore::compileScript(const char *path, JSObject* global, JSContext*
|
||||||
|
|
||||||
cocos2d::FileUtils *futil = cocos2d::FileUtils::getInstance();
|
cocos2d::FileUtils *futil = cocos2d::FileUtils::getInstance();
|
||||||
|
|
||||||
if (global == NULL) {
|
|
||||||
global = _global.ref().get();
|
|
||||||
}
|
|
||||||
if (cx == NULL) {
|
if (cx == NULL) {
|
||||||
cx = _cx;
|
cx = _cx;
|
||||||
}
|
}
|
||||||
|
@ -872,11 +870,15 @@ void ScriptingCore::removeScriptObjectByObject(Ref* pObj)
|
||||||
js_proxy_t* jsproxy;
|
js_proxy_t* jsproxy;
|
||||||
void *ptr = (void*)pObj;
|
void *ptr = (void*)pObj;
|
||||||
nproxy = jsb_get_native_proxy(ptr);
|
nproxy = jsb_get_native_proxy(ptr);
|
||||||
if (nproxy) {
|
if (nproxy)
|
||||||
|
{
|
||||||
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
|
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
|
||||||
jsproxy = jsb_get_js_proxy(nproxy->obj);
|
jsproxy = jsb_get_js_proxy(nproxy->obj);
|
||||||
RemoveObjectRoot(cx, &jsproxy->obj);
|
if (jsproxy)
|
||||||
jsb_remove_proxy(nproxy, jsproxy);
|
{
|
||||||
|
RemoveObjectRoot(cx, &jsproxy->obj);
|
||||||
|
jsb_remove_proxy(nproxy, jsproxy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -890,7 +892,8 @@ bool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
if (argc >= 1) {
|
if (argc >= 1) {
|
||||||
JSString* str = JS::ToString(cx, JS::RootedValue(cx, args.get(0)));
|
JS::RootedValue jsstr(cx, args.get(0));
|
||||||
|
JSString* str = JS::ToString(cx, jsstr);
|
||||||
JSStringWrapper path(str);
|
JSStringWrapper path(str);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
if (argc == 2 && args.get(1).isString()) {
|
if (argc == 2 && args.get(1).isString()) {
|
||||||
|
@ -1043,7 +1046,8 @@ int ScriptingCore::handleActionEvent(void* data)
|
||||||
|
|
||||||
if (eventType == kActionUpdate)
|
if (eventType == kActionUpdate)
|
||||||
{
|
{
|
||||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "update", js_cocos2dx_Action_update))
|
JS::RootedObject jstarget(_cx, p->obj);
|
||||||
|
if (isFunctionOverridedInJS(jstarget, "update", js_cocos2dx_Action_update))
|
||||||
{
|
{
|
||||||
jsval dataVal = DOUBLE_TO_JSVAL(*((float *)actionObjectScriptData->param));
|
jsval dataVal = DOUBLE_TO_JSVAL(*((float *)actionObjectScriptData->param));
|
||||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "update", 1, &dataVal, &retval);
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "update", 1, &dataVal, &retval);
|
||||||
|
@ -1070,10 +1074,12 @@ int ScriptingCore::handleNodeEvent(void* data)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
JS::RootedValue retval(_cx);
|
JS::RootedValue retval(_cx);
|
||||||
jsval dataVal = INT_TO_JSVAL(1);
|
jsval dataVal = INT_TO_JSVAL(1);
|
||||||
|
|
||||||
|
JS::RootedObject jstarget(_cx, p->obj);
|
||||||
|
|
||||||
if (action == kNodeOnEnter)
|
if (action == kNodeOnEnter)
|
||||||
{
|
{
|
||||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnter", js_cocos2dx_Node_onEnter))
|
if (isFunctionOverridedInJS(jstarget, "onEnter", js_cocos2dx_Node_onEnter))
|
||||||
{
|
{
|
||||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnter", 1, &dataVal, &retval);
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnter", 1, &dataVal, &retval);
|
||||||
}
|
}
|
||||||
|
@ -1081,7 +1087,7 @@ int ScriptingCore::handleNodeEvent(void* data)
|
||||||
}
|
}
|
||||||
else if (action == kNodeOnExit)
|
else if (action == kNodeOnExit)
|
||||||
{
|
{
|
||||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onExit", js_cocos2dx_Node_onExit))
|
if (isFunctionOverridedInJS(jstarget, "onExit", js_cocos2dx_Node_onExit))
|
||||||
{
|
{
|
||||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExit", 1, &dataVal, &retval);
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExit", 1, &dataVal, &retval);
|
||||||
}
|
}
|
||||||
|
@ -1089,14 +1095,14 @@ int ScriptingCore::handleNodeEvent(void* data)
|
||||||
}
|
}
|
||||||
else if (action == kNodeOnEnterTransitionDidFinish)
|
else if (action == kNodeOnEnterTransitionDidFinish)
|
||||||
{
|
{
|
||||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnterTransitionDidFinish", js_cocos2dx_Node_onEnterTransitionDidFinish))
|
if (isFunctionOverridedInJS(jstarget, "onEnterTransitionDidFinish", js_cocos2dx_Node_onEnterTransitionDidFinish))
|
||||||
{
|
{
|
||||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnterTransitionDidFinish", 1, &dataVal, &retval);
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnterTransitionDidFinish", 1, &dataVal, &retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (action == kNodeOnExitTransitionDidStart)
|
else if (action == kNodeOnExitTransitionDidStart)
|
||||||
{
|
{
|
||||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onExitTransitionDidStart", js_cocos2dx_Node_onExitTransitionDidStart))
|
if (isFunctionOverridedInJS(jstarget, "onExitTransitionDidStart", js_cocos2dx_Node_onExitTransitionDidStart))
|
||||||
{
|
{
|
||||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExitTransitionDidStart", 1, &dataVal, &retval);
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExitTransitionDidStart", 1, &dataVal, &retval);
|
||||||
}
|
}
|
||||||
|
@ -1104,7 +1110,7 @@ int ScriptingCore::handleNodeEvent(void* data)
|
||||||
else if (action == kNodeOnCleanup) {
|
else if (action == kNodeOnCleanup) {
|
||||||
cleanupSchedulesAndActions(p);
|
cleanupSchedulesAndActions(p);
|
||||||
|
|
||||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "cleanup", js_cocos2dx_Node_cleanup))
|
if (isFunctionOverridedInJS(jstarget, "cleanup", js_cocos2dx_Node_cleanup))
|
||||||
{
|
{
|
||||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "cleanup", 1, &dataVal, &retval);
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "cleanup", 1, &dataVal, &retval);
|
||||||
}
|
}
|
||||||
|
@ -1361,7 +1367,8 @@ bool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, cons
|
||||||
bool hasAction;
|
bool hasAction;
|
||||||
JSContext* cx = this->_cx;
|
JSContext* cx = this->_cx;
|
||||||
JS::RootedValue temp_retval(cx);
|
JS::RootedValue temp_retval(cx);
|
||||||
JS::RootedObject obj(cx, JS::RootedValue(cx, owner).toObjectOrNull());
|
JS::RootedValue ownerval(cx, owner);
|
||||||
|
JS::RootedObject obj(cx, ownerval.toObjectOrNull());
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1612,7 +1619,8 @@ void ScriptingCore::debugProcessInput(const std::string& str)
|
||||||
jsval argv = STRING_TO_JSVAL(jsstr);
|
jsval argv = STRING_TO_JSVAL(jsstr);
|
||||||
JS::RootedValue outval(_cx);
|
JS::RootedValue outval(_cx);
|
||||||
|
|
||||||
JS_CallFunctionName(_cx, JS::RootedObject(_cx, _debugGlobal.ref()), "processInput", JS::HandleValueArray::fromMarkedLocation(1, &argv), &outval);
|
JS::RootedObject debugGlobal(_cx, _debugGlobal.ref());
|
||||||
|
JS_CallFunctionName(_cx, debugGlobal, "processInput", JS::HandleValueArray::fromMarkedLocation(1, &argv), &outval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool NS_ProcessNextEvent()
|
static bool NS_ProcessNextEvent()
|
||||||
|
@ -1857,14 +1865,14 @@ void ScriptingCore::enableDebugger(unsigned int port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject* NewGlobalObject(JSContext* cx, bool debug)
|
JS::HandleObject NewGlobalObject(JSContext* cx, bool debug)
|
||||||
{
|
{
|
||||||
JS::CompartmentOptions options;
|
JS::CompartmentOptions options;
|
||||||
options.setVersion(JSVERSION_LATEST);
|
options.setVersion(JSVERSION_LATEST);
|
||||||
|
|
||||||
JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, &shellTrustedPrincipals, JS::DontFireOnNewGlobalHook, options));
|
JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, &shellTrustedPrincipals, JS::DontFireOnNewGlobalHook, options));
|
||||||
if (!glob) {
|
if (!glob) {
|
||||||
return NULL;
|
return JS::NullPtr();
|
||||||
}
|
}
|
||||||
JSAutoCompartment ac(cx, glob);
|
JSAutoCompartment ac(cx, glob);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@ -1874,7 +1882,7 @@ JSObject* NewGlobalObject(JSContext* cx, bool debug)
|
||||||
if (ok && debug)
|
if (ok && debug)
|
||||||
ok = JS_DefineDebuggerObject(cx, glob);
|
ok = JS_DefineDebuggerObject(cx, glob);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return NULL;
|
return JS::NullPtr();
|
||||||
|
|
||||||
JS_FireOnNewGlobalObject(cx, glob);
|
JS_FireOnNewGlobalObject(cx, glob);
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ public:
|
||||||
* @param global @~english The js global object
|
* @param global @~english The js global object
|
||||||
* @param cx @~english The js context
|
* @param cx @~english The js context
|
||||||
*/
|
*/
|
||||||
void compileScript(const char *path, JSObject* global = NULL, JSContext* cx = NULL);
|
void compileScript(const char *path, JS::HandleObject global, JSContext* cx = NULL);
|
||||||
|
|
||||||
/**@~english
|
/**@~english
|
||||||
* Run the specified js file
|
* Run the specified js file
|
||||||
|
@ -502,11 +502,36 @@ public:
|
||||||
void restartVM();
|
void restartVM();
|
||||||
};
|
};
|
||||||
|
|
||||||
JSObject* NewGlobalObject(JSContext* cx, bool debug = false);
|
JS::HandleObject NewGlobalObject(JSContext* cx, bool debug = false);
|
||||||
|
|
||||||
bool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value);
|
bool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value);
|
||||||
bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret);
|
bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
js_type_class_t *jsb_register_class(JSContext *cx, JSClass *jsClass, JS::HandleObject proto, JS::HandleObject parentProto)
|
||||||
|
{
|
||||||
|
TypeTest<T> t;
|
||||||
|
js_type_class_t *p = nullptr;
|
||||||
|
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 = jsClass;
|
||||||
|
if (p->proto.empty())
|
||||||
|
{
|
||||||
|
p->proto.construct(cx);
|
||||||
|
}
|
||||||
|
p->proto.ref() = proto;
|
||||||
|
if (p->parentProto.empty())
|
||||||
|
{
|
||||||
|
p->parentProto.construct(cx);
|
||||||
|
}
|
||||||
|
p->parentProto.ref() = parentProto ;
|
||||||
|
_js_global_type_map.insert(std::make_pair(typeName, p));
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj);
|
js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj);
|
||||||
js_proxy_t* jsb_get_native_proxy(void* nativeObj);
|
js_proxy_t* jsb_get_native_proxy(void* nativeObj);
|
||||||
js_proxy_t* jsb_get_js_proxy(JSObject* jsObj);
|
js_proxy_t* jsb_get_js_proxy(JSObject* jsObj);
|
||||||
|
|
|
@ -86,7 +86,8 @@ bool JSB_cpConstraint_getA(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
|
|
||||||
ret_val = cpConstraintGetA((cpConstraint*)arg0 );
|
ret_val = cpConstraintGetA((cpConstraint*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" );
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -103,8 +104,9 @@ bool JSB_cpConstraint_getB(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpBody* ret_val = nullptr;
|
cpBody* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpConstraintGetB((cpConstraint*)arg0 );
|
ret_val = cpConstraintGetB((cpConstraint*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" );
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -182,7 +184,8 @@ bool JSB_cpConstraint_getSpace(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
|
|
||||||
ret_val = cpConstraintGetSpace((cpConstraint*)arg0 );
|
ret_val = cpConstraintGetSpace((cpConstraint*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" );
|
JS::RootedObject spaceProto(cx, JSB_cpSpace_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -281,9 +284,8 @@ void JSB_cpConstraint_createClass(JSContext *cx, JS::HandleObject globalObj, con
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpConstraint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpConstraint_class, JSB_cpConstraint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject baseProto(cx, JSB_cpBase_object);
|
||||||
// bool found;
|
JSB_cpConstraint_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpConstraint_class, JSB_cpConstraint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -298,7 +300,8 @@ JSObject* JSB_cpGrooveJoint_object = NULL;
|
||||||
bool JSB_cpGrooveJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpGrooveJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpGrooveJoint_class, JS::RootedObject(cx, JSB_cpGrooveJoint_object), JS::NullPtr());
|
JS::RootedObject grooveJointProto(cx, JSB_cpGrooveJoint_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpGrooveJoint_class, grooveJointProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; cpVect arg4;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; cpVect arg4;
|
||||||
|
@ -475,9 +478,8 @@ void JSB_cpGrooveJoint_createClass(JSContext *cx, JS::HandleObject globalObj, co
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpGrooveJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpGrooveJoint_class, JSB_cpGrooveJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpGrooveJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpGrooveJoint_class, JSB_cpGrooveJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -492,7 +494,8 @@ JSObject* JSB_cpSimpleMotor_object = NULL;
|
||||||
bool JSB_cpSimpleMotor_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpSimpleMotor_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpSimpleMotor_class, JS::RootedObject(cx, JSB_cpSimpleMotor_object), JS::NullPtr());
|
JS::RootedObject simpleMotorProto(cx, JSB_cpSimpleMotor_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSimpleMotor_class, simpleMotorProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0;
|
||||||
|
@ -586,9 +589,8 @@ void JSB_cpSimpleMotor_createClass(JSContext *cx, JS::HandleObject globalObj, co
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpSimpleMotor_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpSimpleMotor_class, JSB_cpSimpleMotor_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpSimpleMotor_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpSimpleMotor_class, JSB_cpSimpleMotor_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -603,7 +605,8 @@ JSObject* JSB_cpPivotJoint_object = NULL;
|
||||||
bool JSB_cpPivotJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpPivotJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==4 || argc==3, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==4 || argc==3, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpPivotJoint_class, JS::RootedObject(cx, JSB_cpPivotJoint_object), JS::NullPtr());
|
JS::RootedObject pivotJointProto(cx, JSB_cpPivotJoint_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpPivotJoint_class, pivotJointProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; void *ret_val = nullptr;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; void *ret_val = nullptr;
|
||||||
|
@ -743,10 +746,9 @@ void JSB_cpPivotJoint_createClass(JSContext *cx, JS::HandleObject globalObj, con
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpPivotJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpPivotJoint_class, JSB_cpPivotJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpPivotJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpPivotJoint_class, JSB_cpPivotJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -761,7 +763,8 @@ JSObject* JSB_cpPinJoint_object = NULL;
|
||||||
bool JSB_cpPinJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpPinJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpPinJoint_class, JS::RootedObject(cx, JSB_cpPinJoint_object), JS::NullPtr());
|
JS::RootedObject pinJointProto(cx, JSB_cpPinJoint_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpPinJoint_class, pinJointProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3;
|
||||||
|
@ -933,10 +936,9 @@ void JSB_cpPinJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpPinJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpPinJoint_class, JSB_cpPinJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpPinJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpPinJoint_class, JSB_cpPinJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -951,7 +953,8 @@ JSObject* JSB_cpSlideJoint_object = NULL;
|
||||||
bool JSB_cpSlideJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpSlideJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==6, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==6, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpSlideJoint_class, JS::RootedObject(cx, JSB_cpSlideJoint_object), JS::NullPtr());
|
JS::RootedObject slideJointProto(cx, JSB_cpSlideJoint_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSlideJoint_class, slideJointProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; double arg4 = 0; double arg5 = 0;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; double arg4 = 0; double arg5 = 0;
|
||||||
|
@ -1161,10 +1164,9 @@ void JSB_cpSlideJoint_createClass(JSContext *cx, JS::HandleObject globalObj, con
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpSlideJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpSlideJoint_class, JSB_cpSlideJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpSlideJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpSlideJoint_class, JSB_cpSlideJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1179,7 +1181,8 @@ JSObject* JSB_cpGearJoint_object = NULL;
|
||||||
bool JSB_cpGearJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpGearJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpGearJoint_class, JS::RootedObject(cx, JSB_cpGearJoint_object), JS::NullPtr());
|
JS::RootedObject gearJointProto(cx, JSB_cpGearJoint_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpGearJoint_class, gearJointProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0;
|
||||||
|
@ -1309,10 +1312,9 @@ void JSB_cpGearJoint_createClass(JSContext *cx, JS::HandleObject globalObj, cons
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpGearJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpGearJoint_class, JSB_cpGearJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpGearJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpGearJoint_class, JSB_cpGearJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1327,7 +1329,8 @@ JSObject* JSB_cpDampedRotarySpring_object = NULL;
|
||||||
bool JSB_cpDampedRotarySpring_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpDampedRotarySpring_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedRotarySpring_class, JS::RootedObject(cx, JSB_cpDampedRotarySpring_object), JS::NullPtr());
|
JS::RootedObject dampedRotarySringProto(cx, JSB_cpDampedRotarySpring_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpDampedRotarySpring_class, dampedRotarySringProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0; double arg4 = 0;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0; double arg4 = 0;
|
||||||
|
@ -1494,10 +1497,9 @@ void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JS::HandleObject global
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpDampedRotarySpring_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpDampedRotarySpring_class, JSB_cpDampedRotarySpring_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpDampedRotarySpring_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpDampedRotarySpring_class, JSB_cpDampedRotarySpring_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1512,7 +1514,8 @@ JSObject* JSB_cpDampedSpring_object = NULL;
|
||||||
bool JSB_cpDampedSpring_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpDampedSpring_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==7, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==7, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedSpring_class, JS::RootedObject(cx, JSB_cpDampedSpring_object), JS::NullPtr());
|
JS::RootedObject dampedSpringProto(cx, JSB_cpDampedSpring_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpDampedSpring_class, dampedSpringProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; double arg4 = 0; double arg5 = 0; double arg6 = 0;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; double arg4 = 0; double arg5 = 0; double arg6 = 0;
|
||||||
|
@ -1759,10 +1762,9 @@ void JSB_cpDampedSpring_createClass(JSContext *cx, JS::HandleObject globalObj, c
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpDampedSpring_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpDampedSpring_class, JSB_cpDampedSpring_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpDampedSpring_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpDampedSpring_class, JSB_cpDampedSpring_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1777,7 +1779,8 @@ JSObject* JSB_cpRatchetJoint_object = NULL;
|
||||||
bool JSB_cpRatchetJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpRatchetJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpRatchetJoint_class, JS::RootedObject(cx, JSB_cpRatchetJoint_object), JS::NullPtr());
|
JS::RootedObject ratchetJointProto(cx, JSB_cpRatchetJoint_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpRatchetJoint_class, ratchetJointProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0;
|
||||||
|
@ -1943,10 +1946,9 @@ void JSB_cpRatchetJoint_createClass(JSContext *cx, JS::HandleObject globalObj, c
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpRatchetJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpRatchetJoint_class, JSB_cpRatchetJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpRatchetJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpRatchetJoint_class, JSB_cpRatchetJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1961,7 +1963,8 @@ JSObject* JSB_cpRotaryLimitJoint_object = NULL;
|
||||||
bool JSB_cpRotaryLimitJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpRotaryLimitJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpRotaryLimitJoint_class, JS::RootedObject(cx, JSB_cpRotaryLimitJoint_object), JS::NullPtr());
|
JS::RootedObject rotaryLimitJointProto(cx, JSB_cpRotaryLimitJoint_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpRotaryLimitJoint_class, rotaryLimitJointProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0;
|
cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0;
|
||||||
|
@ -2091,10 +2094,9 @@ void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JS::HandleObject globalOb
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpRotaryLimitJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpRotaryLimitJoint_class, JSB_cpRotaryLimitJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject constraintProto(cx, JSB_cpConstraint_object);
|
||||||
// bool found;
|
JSB_cpRotaryLimitJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpRotaryLimitJoint_class, JSB_cpRotaryLimitJoint_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2501,9 +2503,8 @@ void JSB_cpArbiter_createClass(JSContext *cx, JS::HandleObject globalObj, const
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpArbiter_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpArbiter_class, JSB_cpArbiter_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject baseProto(cx, JSB_cpBase_object);
|
||||||
// bool found;
|
JSB_cpArbiter_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpArbiter_class, JSB_cpArbiter_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2519,7 +2520,8 @@ bool JSB_cpSpace_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments");
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpSpace_class, JS::RootedObject(cx, JSB_cpSpace_object), JS::NullPtr());
|
JS::RootedObject spaceProto(cx, JSB_cpSpace_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSpace_class, spaceProto, JS::NullPtr()));
|
||||||
void* ret_val = cpSpaceNew( );
|
void* ret_val = cpSpaceNew( );
|
||||||
|
|
||||||
jsb_set_jsobject_for_proxy(jsobj, ret_val);
|
jsb_set_jsobject_for_proxy(jsobj, ret_val);
|
||||||
|
@ -2786,8 +2788,9 @@ bool JSB_cpSpace_getStaticBody(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpBody* ret_val = nullptr;
|
cpBody* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpSpaceGetStaticBody((cpSpace*)arg0 );
|
ret_val = cpSpaceGetStaticBody((cpSpace*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" );
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2804,8 +2807,9 @@ bool JSB_cpSpace_init(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpSpace* ret_val = nullptr;
|
cpSpace* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpSpaceInit((cpSpace*)arg0 );
|
ret_val = cpSpaceInit((cpSpace*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" );
|
JS::RootedObject spaceProto(cx, JSB_cpSpace_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2846,7 +2850,8 @@ bool JSB_cpSpace_pointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
ret_val = cpSpacePointQueryFirst((cpSpace*)arg0 , (cpVect)arg1 , (cpLayers)arg2 , (cpGroup)arg3 );
|
ret_val = cpSpacePointQueryFirst((cpSpace*)arg0 , (cpVect)arg1 , (cpLayers)arg2 , (cpGroup)arg3 );
|
||||||
|
|
||||||
if(ret_val) {
|
if(ret_val) {
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape" );
|
JS::RootedObject shapeProto(cx, JSB_cpShape_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, shapeProto, JSB_cpShape_class, "cpShape" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
} else {
|
} else {
|
||||||
args.rval().set(JSVAL_NULL);
|
args.rval().set(JSVAL_NULL);
|
||||||
|
@ -3188,10 +3193,9 @@ void JSB_cpSpace_createClass(JSContext *cx, JS::HandleObject globalObj, const ch
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpSpace_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpSpace_class, JSB_cpSpace_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject baseProto(cx, JSB_cpBase_object);
|
||||||
// bool found;
|
JSB_cpSpace_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpSpace_class, JSB_cpSpace_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3445,8 +3449,9 @@ bool JSB_cpBody_getSpace(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpSpace* ret_val = nullptr;
|
cpSpace* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpBodyGetSpace((cpBody*)arg0 );
|
ret_val = cpBodyGetSpace((cpBody*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" );
|
JS::RootedObject spaceProto(cx, JSB_cpSpace_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3563,8 +3568,9 @@ bool JSB_cpBody_init(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpBody* ret_val = nullptr;
|
cpBody* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpBodyInit((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 );
|
ret_val = cpBodyInit((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" );
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3581,8 +3587,9 @@ bool JSB_cpBody_initStatic(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpBody* ret_val = nullptr;
|
cpBody* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpBodyInitStatic((cpBody*)arg0 );
|
ret_val = cpBodyInitStatic((cpBody*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" );
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4081,10 +4088,9 @@ void JSB_cpBody_createClass(JSContext *cx, JS::HandleObject globalObj, const cha
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpBody_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpBody_class, JSB_cpBody_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject baseProto(cx, JSB_cpBase_object);
|
||||||
// bool found;
|
JSB_cpBody_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpBody_class, JSB_cpBody_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4181,8 +4187,9 @@ bool JSB_cpShape_getBody(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpBody* ret_val = nullptr;
|
cpBody* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpShapeGetBody((cpShape*)arg0 );
|
ret_val = cpShapeGetBody((cpShape*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" );
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4295,8 +4302,9 @@ bool JSB_cpShape_getSpace(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
cpSpace* ret_val = nullptr;
|
cpSpace* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = cpShapeGetSpace((cpShape*)arg0 );
|
ret_val = cpShapeGetSpace((cpShape*)arg0 );
|
||||||
|
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" );
|
JS::RootedObject spaceProto(cx, JSB_cpSpace_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4545,7 +4553,8 @@ bool JSB_cpShape_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
|
||||||
cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo();
|
cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo();
|
||||||
cpShapeNearestPointQuery(shape, p, info);
|
cpShapeNearestPointQuery(shape, p, info);
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, JS::RootedObject(cx, JSB_cpNearestPointQueryInfo_object), JS::NullPtr());
|
JS::RootedObject nearestPointQueryInfoProto(cx, JSB_cpNearestPointQueryInfo_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, nearestPointQueryInfoProto, JS::NullPtr()));
|
||||||
jsb_set_jsobject_for_proxy(jsobj, info);
|
jsb_set_jsobject_for_proxy(jsobj, info);
|
||||||
jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE);
|
jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE);
|
||||||
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
||||||
|
@ -4570,7 +4579,8 @@ bool JSB_cpShape_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
cpSegmentQueryInfo* info = new cpSegmentQueryInfo();
|
cpSegmentQueryInfo* info = new cpSegmentQueryInfo();
|
||||||
if(cpShapeSegmentQuery(shape, a, b, info))
|
if(cpShapeSegmentQuery(shape, a, b, info))
|
||||||
{
|
{
|
||||||
JSObject* jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, JS::RootedObject(cx, JSB_cpSegmentQueryInfo_object), JS::NullPtr());
|
JS::RootedObject segmentQueryInfoProto(cx, JSB_cpSegmentQueryInfo_object);
|
||||||
|
JSObject* jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, segmentQueryInfoProto, JS::NullPtr());
|
||||||
jsb_set_jsobject_for_proxy(jsobj, info);
|
jsb_set_jsobject_for_proxy(jsobj, info);
|
||||||
jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE);
|
jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE);
|
||||||
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
||||||
|
@ -4698,10 +4708,9 @@ void JSB_cpShape_createClass(JSContext *cx, JS::HandleObject globalObj, const ch
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpShape_class, JSB_cpShape_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject baseProto(cx, JSB_cpBase_object);
|
||||||
// bool found;
|
JSB_cpShape_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpShape_class, JSB_cpShape_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4716,7 +4725,8 @@ JSObject* JSB_cpCircleShape_object = NULL;
|
||||||
bool JSB_cpCircleShape_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpCircleShape_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpCircleShape_class, JS::RootedObject(cx, JSB_cpCircleShape_object), JS::NullPtr());
|
JS::RootedObject circleShapeProto(cx, JSB_cpCircleShape_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpCircleShape_class, circleShapeProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; double arg1 = 0; cpVect arg2;
|
cpBody* arg0 = nullptr; double arg1 = 0; cpVect arg2;
|
||||||
|
@ -4808,10 +4818,9 @@ void JSB_cpCircleShape_createClass(JSContext *cx, JS::HandleObject globalObj, co
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpCircleShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpCircleShape_class, JSB_cpCircleShape_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject shapeProto(cx, JSB_cpShape_object);
|
||||||
// bool found;
|
JSB_cpCircleShape_object = JS_InitClass(cx, globalObj, shapeProto, JSB_cpCircleShape_class, JSB_cpCircleShape_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4826,7 +4835,8 @@ JSObject* JSB_cpSegmentShape_object = NULL;
|
||||||
bool JSB_cpSegmentShape_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpSegmentShape_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentShape_class, JS::RootedObject(cx, JSB_cpSegmentShape_object), JS::NullPtr());
|
JS::RootedObject segmentShapeProto(cx, JSB_cpSegmentShape_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSegmentShape_class, segmentShapeProto, JS::NullPtr()));
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* arg0 = nullptr; cpVect arg1; cpVect arg2; double arg3 = 0;
|
cpBody* arg0 = nullptr; cpVect arg1; cpVect arg2; double arg3 = 0;
|
||||||
|
@ -5002,10 +5012,9 @@ void JSB_cpSegmentShape_createClass(JSContext *cx, JS::HandleObject globalObj, c
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpSegmentShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpSegmentShape_class, JSB_cpSegmentShape_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject shapeProto(cx, JSB_cpShape_object);
|
||||||
// bool found;
|
JSB_cpSegmentShape_object = JS_InitClass(cx, globalObj, shapeProto, JSB_cpSegmentShape_class, JSB_cpSegmentShape_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5109,10 +5118,11 @@ static bool js_get_cpPolyShape_planes(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
cpSplittingPlane *plane = planes + i;
|
cpSplittingPlane *plane = planes + i;
|
||||||
JS::RootedValue elem(cx);
|
JS::RootedValue elem(cx);
|
||||||
|
|
||||||
JSObject *jsobj = jsb_get_jsobject_for_proxy(plane);
|
JS::RootedObject jsobj(cx, jsb_get_jsobject_for_proxy(plane));
|
||||||
if(!jsobj)
|
if(!jsobj)
|
||||||
{
|
{
|
||||||
jsobj = JS_NewObject(cx, JSB_cpSplittingPlane_class, JS::RootedObject(cx, JSB_cpSplittingPlane_object), JS::NullPtr());
|
JS::RootedObject splittingPlaneProto(cx, JSB_cpSplittingPlane_object);
|
||||||
|
jsobj = JS_NewObject(cx, JSB_cpSplittingPlane_class, splittingPlaneProto, JS::NullPtr());
|
||||||
jsb_set_jsobject_for_proxy(jsobj, plane);
|
jsb_set_jsobject_for_proxy(jsobj, plane);
|
||||||
jsb_set_c_proxy_for_jsobject(jsobj, plane, JSB_C_FLAG_DO_NOT_CALL_FREE);
|
jsb_set_c_proxy_for_jsobject(jsobj, plane, JSB_C_FLAG_DO_NOT_CALL_FREE);
|
||||||
}
|
}
|
||||||
|
@ -5152,10 +5162,9 @@ void JSB_cpPolyShape_createClass(JSContext *cx, JS::HandleObject globalObj, cons
|
||||||
static JSFunctionSpec st_funcs[] = {
|
static JSFunctionSpec st_funcs[] = {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpPolyShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpPolyShape_class, JSB_cpPolyShape_constructor,0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject shapeProto(cx, JSB_cpShape_object);
|
||||||
// bool found;
|
JSB_cpPolyShape_object = JS_InitClass(cx, globalObj, shapeProto, JSB_cpPolyShape_class, JSB_cpPolyShape_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SplittingPlane
|
// SplittingPlane
|
||||||
|
@ -5293,7 +5302,8 @@ bool js_get_cpSegmentQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
cpShape* shape = info->shape;
|
cpShape* shape = info->shape;
|
||||||
|
|
||||||
if(shape){
|
if(shape){
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpShape_class, JS::RootedObject(cx, JSB_cpShape_object), JS::NullPtr());
|
JS::RootedObject shapeProto(cx, JSB_cpShape_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpShape_class, shapeProto, JS::NullPtr()));
|
||||||
//jsb_set_jsobject_for_proxy(jsobj, shape);
|
//jsb_set_jsobject_for_proxy(jsobj, shape);
|
||||||
jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE);
|
jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE);
|
||||||
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
||||||
|
@ -5387,8 +5397,6 @@ void JSB_cpSegmentQueryInfo_createClass(JSContext *cx, JS::HandleObject globalOb
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpSegmentQueryInfo_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpSegmentQueryInfo_class, NULL,0,properties,funcs,NULL,st_funcs);
|
JSB_cpSegmentQueryInfo_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpSegmentQueryInfo_class, NULL,0,properties,funcs,NULL,st_funcs);
|
||||||
// bool found;
|
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool js_get_cpNearestPointQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp)
|
bool js_get_cpNearestPointQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
@ -5399,7 +5407,8 @@ bool js_get_cpNearestPointQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *v
|
||||||
cpShape* shape = info->shape;
|
cpShape* shape = info->shape;
|
||||||
|
|
||||||
if(shape){
|
if(shape){
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpShape_class, JS::RootedObject(cx, JSB_cpShape_object), JS::NullPtr());
|
JS::RootedObject shapeProto(cx, JSB_cpShape_object);
|
||||||
|
JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpShape_class, shapeProto, JS::NullPtr()));
|
||||||
//jsb_set_jsobject_for_proxy(jsobj, shape);
|
//jsb_set_jsobject_for_proxy(jsobj, shape);
|
||||||
jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE);
|
jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE);
|
||||||
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
||||||
|
|
|
@ -48,7 +48,9 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||||
p = typeMapIter->second;
|
p = typeMapIter->second;
|
||||||
CCASSERT(p, "The value is null.");
|
CCASSERT(p, "The value is null.");
|
||||||
|
|
||||||
JSObject *_tmp = JS_NewObject(cx, p->jsclass, JS::RootedObject(cx, p->proto), JS::RootedObject(cx, p->parentProto));
|
JS::RootedObject proto(cx, p->proto.ref());
|
||||||
|
JS::RootedObject parentProto(cx, p->parentProto.ref());
|
||||||
|
JS::RootedObject _tmp(cx, JS_NewObject(cx, p->jsclass, proto, parentProto));
|
||||||
js_proxy_t *pp = jsb_new_proxy(cobj, _tmp);
|
js_proxy_t *pp = jsb_new_proxy(cobj, _tmp);
|
||||||
JS::AddObjectRoot(cx, &pp->obj);
|
JS::AddObjectRoot(cx, &pp->obj);
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
|
@ -101,7 +103,8 @@ bool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
cpBody* ret_val = nullptr;
|
cpBody* ret_val = nullptr;
|
||||||
|
|
||||||
ret_val = real->getCPBody();
|
ret_val = real->getCPBody();
|
||||||
jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" );
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" );
|
||||||
args.rval().set(ret_jsval);
|
args.rval().set(ret_jsval);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -200,7 +203,9 @@ bool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
|
|
||||||
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto);
|
||||||
jsret = OBJECT_TO_JSVAL(obj);
|
jsret = OBJECT_TO_JSVAL(obj);
|
||||||
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
||||||
JS::AddNamedObjectRoot(cx, &p->obj, "CCDebugNode");
|
JS::AddNamedObjectRoot(cx, &p->obj, "CCDebugNode");
|
||||||
|
@ -267,8 +272,9 @@ bool JSB_CCPhysicsDebugNode_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
//JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, typeClass->jsclass, args));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)));
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto));
|
||||||
args.rval().set(OBJECT_TO_JSVAL(obj));
|
args.rval().set(OBJECT_TO_JSVAL(obj));
|
||||||
// link the native object with the javascript object
|
// link the native object with the javascript object
|
||||||
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
||||||
|
@ -313,21 +319,12 @@ void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JS::HandleObject globalOb
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
|
|
||||||
JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, typeClass->proto), JSB_CCPhysicsDebugNode_class, JSB_CCPhysicsDebugNode_constructor, 0,properties,funcs,NULL,st_funcs);
|
|
||||||
|
|
||||||
TypeTest<PhysicsDebugNode> t;
|
|
||||||
js_type_class_t *p;
|
|
||||||
typeName = t.s_name();
|
|
||||||
|
|
||||||
if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
|
JS::RootedObject parentProto(cx, typeClass->proto.ref());
|
||||||
{
|
JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, parentProto, JSB_CCPhysicsDebugNode_class, JSB_CCPhysicsDebugNode_constructor, 0,properties,funcs,NULL,st_funcs);
|
||||||
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
|
|
||||||
p->jsclass = JSB_CCPhysicsDebugNode_class;
|
JS::RootedObject proto(cx, JSB_CCPhysicsDebugNode_object);
|
||||||
p->proto = JSB_CCPhysicsDebugNode_object;
|
jsb_register_class<PhysicsDebugNode>(cx, JSB_CCPhysicsDebugNode_class, proto, parentProto);
|
||||||
p->parentProto = typeClass->proto;
|
|
||||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments: NSString*, CGRect
|
// Arguments: NSString*, CGRect
|
||||||
|
@ -356,7 +353,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
|
|
||||||
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto);
|
||||||
jsret = OBJECT_TO_JSVAL(obj);
|
jsret = OBJECT_TO_JSVAL(obj);
|
||||||
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
||||||
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
||||||
|
@ -384,7 +383,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto);
|
||||||
jsret = OBJECT_TO_JSVAL(obj);
|
jsret = OBJECT_TO_JSVAL(obj);
|
||||||
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
||||||
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
||||||
|
@ -425,7 +426,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto);
|
||||||
jsret = OBJECT_TO_JSVAL(obj);
|
jsret = OBJECT_TO_JSVAL(obj);
|
||||||
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
||||||
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
||||||
|
@ -459,7 +462,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, ui
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto);
|
||||||
jsret = OBJECT_TO_JSVAL(obj);
|
jsret = OBJECT_TO_JSVAL(obj);
|
||||||
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
js_proxy_t *p = jsb_new_proxy(ret, obj);
|
||||||
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite");
|
||||||
|
@ -490,8 +495,9 @@ bool JSPROXY_CCPhysicsSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
//JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, typeClass->jsclass, args));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)));
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto));
|
||||||
args.rval().set(OBJECT_TO_JSVAL(obj));
|
args.rval().set(OBJECT_TO_JSVAL(obj));
|
||||||
// link the native object with the javascript object
|
// link the native object with the javascript object
|
||||||
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
||||||
|
@ -558,20 +564,12 @@ void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JS::HandleObject globalO
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
|
|
||||||
JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, typeClass->proto), JSPROXY_CCPhysicsSprite_class,/* dummy_constructor<PhysicsSprite>*/JSPROXY_CCPhysicsSprite_constructor, 0,properties,funcs,NULL,st_funcs);
|
JS::RootedObject parentProto(cx, typeClass->proto.ref());
|
||||||
|
JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, parentProto, JSPROXY_CCPhysicsSprite_class, JSPROXY_CCPhysicsSprite_constructor, 0,properties,funcs,NULL,st_funcs);
|
||||||
TypeTest<PhysicsSprite> t;
|
|
||||||
js_type_class_t *p;
|
JS::RootedObject proto(cx, JSPROXY_CCPhysicsSprite_object);
|
||||||
typeName = t.s_name();
|
jsb_register_class<PhysicsSprite>(cx, JSPROXY_CCPhysicsSprite_class, proto, parentProto);
|
||||||
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 = JSPROXY_CCPhysicsSprite_class;
|
|
||||||
p->proto = JSPROXY_CCPhysicsSprite_object;
|
|
||||||
p->parentProto = typeClass->proto;
|
|
||||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
|
||||||
}
|
|
||||||
|
|
||||||
anonEvaluate(cx, globalObj, "(function () { cc.PhysicsSprite.extend = cc.Class.extend; })()");
|
anonEvaluate(cx, globalObj, "(function () { cc.PhysicsSprite.extend = cc.Class.extend; })()");
|
||||||
}
|
}
|
||||||
|
@ -592,7 +590,8 @@ void register_CCPhysicsDebugNode(JSContext *cx, JS::HandleObject obj) {
|
||||||
bool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret )
|
bool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret )
|
||||||
{
|
{
|
||||||
JS::RootedObject jsobj(cx);
|
JS::RootedObject jsobj(cx);
|
||||||
bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj );
|
JS::RootedValue jsv(cx, vp);
|
||||||
|
bool ok = JS_ValueToObject(cx, jsv, &jsobj);
|
||||||
JSB_PRECONDITION( ok, "Error converting value to object");
|
JSB_PRECONDITION( ok, "Error converting value to object");
|
||||||
JSB_PRECONDITION( jsobj, "Not a valid JS object");
|
JSB_PRECONDITION( jsobj, "Not a valid JS object");
|
||||||
|
|
||||||
|
@ -645,7 +644,8 @@ bool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numV
|
||||||
{
|
{
|
||||||
// Parsing sequence
|
// Parsing sequence
|
||||||
JS::RootedObject jsobj(cx);
|
JS::RootedObject jsobj(cx);
|
||||||
bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj );
|
JS::RootedValue jsv(cx, vp);
|
||||||
|
bool ok = JS_ValueToObject(cx, jsv, &jsobj);
|
||||||
JSB_PRECONDITION( ok, "Error converting value to object");
|
JSB_PRECONDITION( ok, "Error converting value to object");
|
||||||
|
|
||||||
JSB_PRECONDITION( jsobj && JS_IsArrayObject( cx, jsobj), "Object must be an array");
|
JSB_PRECONDITION( jsobj && JS_IsArrayObject( cx, jsobj), "Object must be an array");
|
||||||
|
@ -683,7 +683,8 @@ bool jsval_to_cpVect( JSContext *cx, jsval vp, cpVect *ret )
|
||||||
#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES
|
#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES
|
||||||
|
|
||||||
JS::RootedObject jsobj(cx);
|
JS::RootedObject jsobj(cx);
|
||||||
if( ! JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj ) )
|
JS::RootedValue jsv(cx, vp);
|
||||||
|
if( !JS_ValueToObject(cx, jsv, &jsobj) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JSB_PRECONDITION( jsobj, "Not a valid JS object");
|
JSB_PRECONDITION( jsobj, "Not a valid JS object");
|
||||||
|
@ -797,8 +798,10 @@ static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
|
|
||||||
jsval args[2];
|
jsval args[2];
|
||||||
if( handler->is_oo ) {
|
if( handler->is_oo ) {
|
||||||
args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter");
|
JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object);
|
||||||
args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter");
|
JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object);
|
||||||
|
args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter");
|
||||||
|
args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter");
|
||||||
} else {
|
} else {
|
||||||
args[0] = opaque_to_jsval( handler->cx, arb);
|
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||||
args[1] = opaque_to_jsval( handler->cx, space );
|
args[1] = opaque_to_jsval( handler->cx, space );
|
||||||
|
@ -807,7 +810,9 @@ static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
|
|
||||||
JS::RootedValue rval(handler->cx);
|
JS::RootedValue rval(handler->cx);
|
||||||
bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->begin)), JS::HandleValueArray::fromMarkedLocation(2, args), &rval);
|
JS::RootedObject jsthis(handler->cx, handler->jsthis);
|
||||||
|
JS::RootedValue jsbegin(handler->cx, OBJECT_TO_JSVAL(handler->begin));
|
||||||
|
bool ok = JS_CallFunctionValue( handler->cx, jsthis, jsbegin, JS::HandleValueArray::fromMarkedLocation(2, args), &rval);
|
||||||
JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin");
|
JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin");
|
||||||
|
|
||||||
if( rval.isBoolean() ) {
|
if( rval.isBoolean() ) {
|
||||||
|
@ -823,8 +828,10 @@ static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
|
|
||||||
jsval args[2];
|
jsval args[2];
|
||||||
if( handler->is_oo ) {
|
if( handler->is_oo ) {
|
||||||
args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter");
|
JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object);
|
||||||
args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter");
|
JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object);
|
||||||
|
args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter");
|
||||||
|
args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter");
|
||||||
} else {
|
} else {
|
||||||
args[0] = opaque_to_jsval( handler->cx, arb);
|
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||||
args[1] = opaque_to_jsval( handler->cx, space );
|
args[1] = opaque_to_jsval( handler->cx, space );
|
||||||
|
@ -833,7 +840,9 @@ static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
|
|
||||||
JS::RootedValue rval(handler->cx);
|
JS::RootedValue rval(handler->cx);
|
||||||
bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->pre)), JS::HandleValueArray::fromMarkedLocation(2, args), &rval);
|
JS::RootedObject jsthis(handler->cx, handler->jsthis);
|
||||||
|
JS::RootedValue jspre(handler->cx, OBJECT_TO_JSVAL(handler->pre));
|
||||||
|
bool ok = JS_CallFunctionValue( handler->cx, jsthis, jspre, JS::HandleValueArray::fromMarkedLocation(2, args), &rval);
|
||||||
JSB_PRECONDITION2(ok, handler->cx, false, "Error calling collision callback: pre");
|
JSB_PRECONDITION2(ok, handler->cx, false, "Error calling collision callback: pre");
|
||||||
|
|
||||||
if( rval.isBoolean() ) {
|
if( rval.isBoolean() ) {
|
||||||
|
@ -850,8 +859,10 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
jsval args[2];
|
jsval args[2];
|
||||||
|
|
||||||
if( handler->is_oo ) {
|
if( handler->is_oo ) {
|
||||||
args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter");
|
JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object);
|
||||||
args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter");
|
JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object);
|
||||||
|
args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter");
|
||||||
|
args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter");
|
||||||
} else {
|
} else {
|
||||||
args[0] = opaque_to_jsval( handler->cx, arb);
|
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||||
args[1] = opaque_to_jsval( handler->cx, space );
|
args[1] = opaque_to_jsval( handler->cx, space );
|
||||||
|
@ -860,7 +871,9 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
|
|
||||||
JS::RootedValue ignore(handler->cx);
|
JS::RootedValue ignore(handler->cx);
|
||||||
bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->post)), JS::HandleValueArray::fromMarkedLocation(2, args), &ignore);
|
JS::RootedObject jsthis(handler->cx, handler->jsthis);
|
||||||
|
JS::RootedValue jspost(handler->cx, OBJECT_TO_JSVAL(handler->post));
|
||||||
|
bool ok = JS_CallFunctionValue( handler->cx, jsthis, jspost, JS::HandleValueArray::fromMarkedLocation(2, args), &ignore);
|
||||||
JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post");
|
JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,8 +885,10 @@ static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
|
|
||||||
jsval args[2];
|
jsval args[2];
|
||||||
if( handler->is_oo ) {
|
if( handler->is_oo ) {
|
||||||
args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter");
|
JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object);
|
||||||
args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter");
|
JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object);
|
||||||
|
args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter");
|
||||||
|
args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter");
|
||||||
} else {
|
} else {
|
||||||
args[0] = opaque_to_jsval( handler->cx, arb);
|
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||||
args[1] = opaque_to_jsval( handler->cx, space );
|
args[1] = opaque_to_jsval( handler->cx, space );
|
||||||
|
@ -882,7 +897,9 @@ static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data)
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
|
|
||||||
JS::RootedValue ignore(handler->cx);
|
JS::RootedValue ignore(handler->cx);
|
||||||
bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->separate)), JS::HandleValueArray::fromMarkedLocation(2, args), &ignore);
|
JS::RootedObject jsthis(handler->cx, handler->jsthis);
|
||||||
|
JS::RootedValue jssep(handler->cx, OBJECT_TO_JSVAL(handler->separate));
|
||||||
|
bool ok = JS_CallFunctionValue( handler->cx, jsthis, jssep, JS::HandleValueArray::fromMarkedLocation(2, args), &ignore);
|
||||||
JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");}
|
JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");}
|
||||||
|
|
||||||
#pragma mark - cpSpace
|
#pragma mark - cpSpace
|
||||||
|
@ -947,8 +964,10 @@ bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, c
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
// args
|
// args
|
||||||
ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeA );
|
JS::RootedValue jstypeA(cx, *argvp++);
|
||||||
ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeB );
|
JS::RootedValue jstypeB(cx, *argvp++);
|
||||||
|
ok &= jsval_to_int(cx, jstypeA, (int32_t*) &handler->typeA );
|
||||||
|
ok &= jsval_to_int(cx, jstypeB, (int32_t*) &handler->typeB );
|
||||||
|
|
||||||
handler->begin = argvp->toObjectOrNull();
|
handler->begin = argvp->toObjectOrNull();
|
||||||
argvp++;
|
argvp++;
|
||||||
|
@ -1014,7 +1033,8 @@ bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
// args
|
// args
|
||||||
cpSpace *space = nullptr;
|
cpSpace *space = nullptr;
|
||||||
jsval* argvp = args.array();
|
jsval* argvp = args.array();
|
||||||
bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**)&space);
|
JS::RootedValue jsarg(cx, *argvp++);
|
||||||
|
bool ok = jsval_to_opaque(cx, jsarg, (void**)&space);
|
||||||
JSB_PRECONDITION(ok, "Error parsing arguments");
|
JSB_PRECONDITION(ok, "Error parsing arguments");
|
||||||
|
|
||||||
return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0);
|
return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0);
|
||||||
|
@ -1115,8 +1135,10 @@ bool __jsb_cpSpace_removeCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp
|
||||||
|
|
||||||
cpCollisionType typeA = 0;
|
cpCollisionType typeA = 0;
|
||||||
cpCollisionType typeB = 0;
|
cpCollisionType typeB = 0;
|
||||||
ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &typeA );
|
JS::RootedValue jstypeA(cx, *argvp++);
|
||||||
ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &typeB );
|
JS::RootedValue jstypeB(cx, *argvp++);
|
||||||
|
ok &= jsval_to_int(cx, jstypeA, (int32_t*) &typeA);
|
||||||
|
ok &= jsval_to_int(cx, jstypeB, (int32_t*) &typeB);
|
||||||
|
|
||||||
JSB_PRECONDITION(ok, "Error parsing arguments");
|
JSB_PRECONDITION(ok, "Error parsing arguments");
|
||||||
|
|
||||||
|
@ -1154,7 +1176,8 @@ bool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
|
||||||
cpSpace* space = nullptr;
|
cpSpace* space = nullptr;
|
||||||
jsval* argvp = args.array();
|
jsval* argvp = args.array();
|
||||||
bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**)&space);
|
JS::RootedValue jsarg(cx, *argvp++);
|
||||||
|
bool ok = jsval_to_opaque( cx, jsarg, (void**)&space);
|
||||||
|
|
||||||
JSB_PRECONDITION(ok, "Error parsing arguments");
|
JSB_PRECONDITION(ok, "Error parsing arguments");
|
||||||
|
|
||||||
|
@ -1395,7 +1418,8 @@ bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){
|
||||||
|
|
||||||
if(target)
|
if(target)
|
||||||
{
|
{
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, JS::RootedObject(cx, JSB_cpSegmentQueryInfo_object), JS::NullPtr());
|
JS::RootedObject segmentQueryInfoProto(cx, JSB_cpSegmentQueryInfo_object);
|
||||||
|
JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, segmentQueryInfoProto, JS::NullPtr());
|
||||||
jsb_set_jsobject_for_proxy(jsobj, out);
|
jsb_set_jsobject_for_proxy(jsobj, out);
|
||||||
jsb_set_c_proxy_for_jsobject(jsobj, out, JSB_C_FLAG_CALL_FREE);
|
jsb_set_c_proxy_for_jsobject(jsobj, out, JSB_C_FLAG_CALL_FREE);
|
||||||
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
||||||
|
@ -1432,7 +1456,8 @@ bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *v
|
||||||
|
|
||||||
if(target)
|
if(target)
|
||||||
{
|
{
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, JS::RootedObject(cx, JSB_cpNearestPointQueryInfo_object), JS::NullPtr());
|
JS::RootedObject nearestPointQueryInfoProto(cx, JSB_cpNearestPointQueryInfo_object);
|
||||||
|
JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, nearestPointQueryInfoProto, JS::NullPtr());
|
||||||
jsb_set_jsobject_for_proxy(jsobj, info);
|
jsb_set_jsobject_for_proxy(jsobj, info);
|
||||||
jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE);
|
jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE);
|
||||||
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
args.rval().set(OBJECT_TO_JSVAL(jsobj));
|
||||||
|
@ -1457,12 +1482,12 @@ void JSB_cpSpace_pointQuery_func(cpShape *shape, void *data)
|
||||||
if(jsCpObject)
|
if(jsCpObject)
|
||||||
{
|
{
|
||||||
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
||||||
jsval* func = ((JSB_cp_each_UserData*)data)->func;
|
JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func);
|
||||||
JS::RootedValue rval(cx);
|
JS::RootedValue rval(cx);
|
||||||
jsval argv = OBJECT_TO_JSVAL(jsCpObject);
|
jsval argv = OBJECT_TO_JSVAL(jsCpObject);
|
||||||
|
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval);
|
JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1506,7 +1531,7 @@ void JSB_cpSpace_nearestPointQuery_func(cpShape *shape, cpFloat distance, cpVect
|
||||||
if(jsCpObject)
|
if(jsCpObject)
|
||||||
{
|
{
|
||||||
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
||||||
jsval* func = ((JSB_cp_each_UserData*)data)->func;
|
JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func);
|
||||||
JS::RootedValue rval(cx);
|
JS::RootedValue rval(cx);
|
||||||
jsval argv[3];
|
jsval argv[3];
|
||||||
argv[0] = OBJECT_TO_JSVAL(jsCpObject);
|
argv[0] = OBJECT_TO_JSVAL(jsCpObject);
|
||||||
|
@ -1514,7 +1539,7 @@ void JSB_cpSpace_nearestPointQuery_func(cpShape *shape, cpFloat distance, cpVect
|
||||||
argv[2] = cpVect_to_jsval(cx, point);
|
argv[2] = cpVect_to_jsval(cx, point);
|
||||||
|
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(3, argv), &rval);
|
JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(3, argv), &rval);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1559,7 +1584,7 @@ void JSB_cpSpace_segmentQuery_func(cpShape *shape, cpFloat t, cpVect n, void *da
|
||||||
if(jsCpObject)
|
if(jsCpObject)
|
||||||
{
|
{
|
||||||
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
||||||
jsval* func = ((JSB_cp_each_UserData*)data)->func;
|
JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func);
|
||||||
JS::RootedValue rval(cx);
|
JS::RootedValue rval(cx);
|
||||||
jsval argv[3];
|
jsval argv[3];
|
||||||
argv[0] = OBJECT_TO_JSVAL(jsCpObject);
|
argv[0] = OBJECT_TO_JSVAL(jsCpObject);
|
||||||
|
@ -1567,7 +1592,7 @@ void JSB_cpSpace_segmentQuery_func(cpShape *shape, cpFloat t, cpVect n, void *da
|
||||||
argv[2] = cpVect_to_jsval(cx, n);
|
argv[2] = cpVect_to_jsval(cx, n);
|
||||||
|
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(3, argv), &rval);
|
JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(3, argv), &rval);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1577,7 +1602,7 @@ bool JSB_cpSpace_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
JSB_PRECONDITION2(argc == 5, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc == 5, cx, false, "Invalid number of arguments");
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
|
|
||||||
JSObject* jsthis = args.thisv().toObjectOrNull();
|
JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull());
|
||||||
struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis);
|
struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis);
|
||||||
cpSpace* space = (cpSpace*) proxy->handle;
|
cpSpace* space = (cpSpace*) proxy->handle;
|
||||||
|
|
||||||
|
@ -1650,11 +1675,11 @@ void JSB_cpSpace_each_func(T* cpObject, void *data)
|
||||||
if(jsCpObject)
|
if(jsCpObject)
|
||||||
{
|
{
|
||||||
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
||||||
jsval* func = ((JSB_cp_each_UserData*)data)->func;
|
JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func);
|
||||||
JS::RootedValue rval(cx);
|
JS::RootedValue rval(cx);
|
||||||
jsval argv = OBJECT_TO_JSVAL(jsCpObject);
|
jsval argv = OBJECT_TO_JSVAL(jsCpObject);
|
||||||
|
|
||||||
JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval);
|
JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1768,11 +1793,11 @@ void JSB_cpBody_each_func(cpBody* body, T* cpObject, void* data)
|
||||||
if(jsCpObject)
|
if(jsCpObject)
|
||||||
{
|
{
|
||||||
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
JSContext* cx = ((JSB_cp_each_UserData*)data)->cx;
|
||||||
jsval* func = ((JSB_cp_each_UserData*)data)->func;
|
JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func);
|
||||||
JS::RootedValue rval(cx);
|
JS::RootedValue rval(cx);
|
||||||
jsval argv = OBJECT_TO_JSVAL(jsCpObject);
|
jsval argv = OBJECT_TO_JSVAL(jsCpObject);
|
||||||
|
|
||||||
JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval);
|
JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1850,8 +1875,9 @@ bool __jsb_cpArbiter_getBodies(JSContext *cx, const JS::CallArgs& args, cpArbite
|
||||||
JS::RootedValue valA(cx);
|
JS::RootedValue valA(cx);
|
||||||
JS::RootedValue valB(cx);
|
JS::RootedValue valB(cx);
|
||||||
if( is_oo ) {
|
if( is_oo ) {
|
||||||
valA = c_class_to_jsval(cx, bodyA, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpArbiter");
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
valB = c_class_to_jsval(cx, bodyB, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpArbiter");
|
valA = c_class_to_jsval(cx, bodyA, bodyProto, JSB_cpBody_class, "cpArbiter");
|
||||||
|
valB = c_class_to_jsval(cx, bodyB, bodyProto, JSB_cpBody_class, "cpArbiter");
|
||||||
} else {
|
} else {
|
||||||
valA = opaque_to_jsval(cx, bodyA);
|
valA = opaque_to_jsval(cx, bodyA);
|
||||||
valB = opaque_to_jsval(cx, bodyB);
|
valB = opaque_to_jsval(cx, bodyB);
|
||||||
|
@ -1905,8 +1931,9 @@ bool __jsb_cpArbiter_getShapes(JSContext *cx, const JS::CallArgs& args, cpArbite
|
||||||
JS::RootedValue valA(cx);
|
JS::RootedValue valA(cx);
|
||||||
JS::RootedValue valB(cx);
|
JS::RootedValue valB(cx);
|
||||||
if( is_oo ) {
|
if( is_oo ) {
|
||||||
valA = c_class_to_jsval(cx, shapeA, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape");
|
JS::RootedObject shapeProto(cx, JSB_cpShape_object);
|
||||||
valB = c_class_to_jsval(cx, shapeB, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape");
|
valA = c_class_to_jsval(cx, shapeA, shapeProto, JSB_cpShape_class, "cpShape");
|
||||||
|
valB = c_class_to_jsval(cx, shapeB, shapeProto, JSB_cpShape_class, "cpShape");
|
||||||
} else {
|
} else {
|
||||||
valA = opaque_to_jsval(cx, shapeA);
|
valA = opaque_to_jsval(cx, shapeA);
|
||||||
valB = opaque_to_jsval(cx, shapeB);
|
valB = opaque_to_jsval(cx, shapeB);
|
||||||
|
@ -1956,7 +1983,8 @@ bool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
bool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==2, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==2, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, JS::RootedObject(cx, JSB_cpBody_object), JS::NullPtr());
|
JS::RootedObject bodyProto(cx, JSB_cpBody_object);
|
||||||
|
JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, bodyProto, JS::NullPtr());
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
double m = 0; double i = 0;
|
double m = 0; double i = 0;
|
||||||
|
@ -2028,8 +2056,8 @@ static
|
||||||
bool __jsb_cpBody_setUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body)
|
bool __jsb_cpBody_setUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body)
|
||||||
{
|
{
|
||||||
JS::RootedObject jsobj(cx);
|
JS::RootedObject jsobj(cx);
|
||||||
|
JS::RootedValue jsv(cx, *argvp);
|
||||||
bool ok = JS_ValueToObject(cx, JS::RootedValue(cx, *argvp), &jsobj);
|
bool ok = JS_ValueToObject(cx, jsv, &jsobj);
|
||||||
|
|
||||||
JSB_PRECONDITION(ok, "Error parsing arguments");
|
JSB_PRECONDITION(ok, "Error parsing arguments");
|
||||||
|
|
||||||
|
@ -2046,7 +2074,8 @@ bool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
cpBody *body = nullptr;
|
cpBody *body = nullptr;
|
||||||
jsval* argvp = args.array();
|
jsval* argvp = args.array();
|
||||||
bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**) &body );
|
JS::RootedValue jsarg(cx, *argvp++);
|
||||||
|
bool ok = jsval_to_opaque(cx, jsarg, (void**) &body);
|
||||||
JSB_PRECONDITION(ok, "Error parsing arguments");
|
JSB_PRECONDITION(ok, "Error parsing arguments");
|
||||||
return __jsb_cpBody_setUserData(cx, vp, argvp, body);
|
return __jsb_cpBody_setUserData(cx, vp, argvp, body);
|
||||||
}
|
}
|
||||||
|
@ -2150,8 +2179,8 @@ JSObject* JSB_cpBase_object = NULL;
|
||||||
bool JSB_cpBase_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpBase_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2( argc==1, cx, false, "Invalid arguments. Expecting 1");
|
JSB_PRECONDITION2( argc==1, cx, false, "Invalid arguments. Expecting 1");
|
||||||
|
JS::RootedObject baseProto(cx, JSB_cpBase_object);
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, JS::RootedObject(cx, JSB_cpBase_object), JS::NullPtr());
|
JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, baseProto, JS::NullPtr());
|
||||||
|
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@ -2238,8 +2267,6 @@ void JSB_cpBase_createClass(JSContext *cx, JS::HandleObject globalObj, const cha
|
||||||
};
|
};
|
||||||
|
|
||||||
JSB_cpBase_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpBase_class, JSB_cpBase_constructor,0,properties,funcs,NULL,st_funcs);
|
JSB_cpBase_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpBase_class, JSB_cpBase_constructor,0,properties,funcs,NULL,st_funcs);
|
||||||
// bool found;
|
|
||||||
// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manual "methods"
|
// Manual "methods"
|
||||||
|
@ -2247,7 +2274,8 @@ void JSB_cpBase_createClass(JSContext *cx, JS::HandleObject globalObj, const cha
|
||||||
bool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
bool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
{
|
{
|
||||||
JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments");
|
JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments");
|
||||||
JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, JS::RootedObject(cx, JSB_cpPolyShape_object), JS::NullPtr());
|
JS::RootedObject polyShapeProto(cx, JSB_cpPolyShape_object);
|
||||||
|
JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, polyShapeProto, JS::NullPtr());
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cpBody* body = nullptr; cpVect *verts = nullptr; cpVect offset;
|
cpBody* body = nullptr; cpVect *verts = nullptr; cpVect offset;
|
||||||
|
|
|
@ -334,7 +334,8 @@ bool js_cocos2dx_CCSequence_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
Vector<FiniteTimeAction*> array;
|
Vector<FiniteTimeAction*> array;
|
||||||
if (argc == 1 && JS_IsArrayObject(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()))) {
|
JS::RootedObject actions(cx, args.get(0).toObjectOrNull());
|
||||||
|
if (argc == 1 && JS_IsArrayObject(cx, actions)) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
ok &= jsval_to_ccvector(cx, args.get(0), &array);
|
ok &= jsval_to_ccvector(cx, args.get(0), &array);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
@ -378,7 +379,8 @@ bool js_cocos2dx_CCSpawn_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
Vector<FiniteTimeAction*> array;
|
Vector<FiniteTimeAction*> array;
|
||||||
if (argc == 1 && JS_IsArrayObject(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()))) {
|
JS::RootedObject actions(cx, args.get(0).toObjectOrNull());
|
||||||
|
if (argc == 1 && JS_IsArrayObject(cx, actions)) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
ok &= jsval_to_ccvector(cx, args.get(0), &array);
|
ok &= jsval_to_ccvector(cx, args.get(0), &array);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
@ -468,7 +470,8 @@ bool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
ok &= jsval_to_ccvector(cx, args.get(0), &arg0);
|
ok &= jsval_to_ccvector(cx, args.get(0), &arg0);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
}
|
}
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &arg1);
|
JS::RootedValue jsarg1(cx, args.get(1));
|
||||||
|
ok &= JS::ToNumber(cx, jsarg1, &arg1);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1);
|
ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1);
|
||||||
} else if (argc == 3) {
|
} else if (argc == 3) {
|
||||||
|
@ -478,7 +481,8 @@ bool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
}
|
}
|
||||||
unsigned int loops;
|
unsigned int loops;
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &arg1);
|
JS::RootedValue jsarg1(cx, args.get(1));
|
||||||
|
ok &= JS::ToNumber(cx, jsarg1, &arg1);
|
||||||
ok &= jsval_to_uint32(cx, args.get(2), &loops);
|
ok &= jsval_to_uint32(cx, args.get(2), &loops);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
ret = cocos2d::Animation::create(arg0, arg1, loops);
|
ret = cocos2d::Animation::create(arg0, arg1, loops);
|
||||||
|
@ -1248,7 +1252,8 @@ bool js_CCNode_scheduleOnce(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
//
|
//
|
||||||
double delay;
|
double delay;
|
||||||
if( argc >= 2 ) {
|
if( argc >= 2 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &delay );
|
JS::RootedValue jsdelay(cx, args.get(1));
|
||||||
|
ok &= JS::ToNumber(cx, jsdelay, &delay);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1324,7 +1329,8 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
|
||||||
double interval = 0.0;
|
double interval = 0.0;
|
||||||
if( argc >= 2 ) {
|
if( argc >= 2 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &interval );
|
JS::RootedValue jsinterval(cx, args.get(1));
|
||||||
|
ok &= JS::ToNumber(cx, jsinterval, &interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1332,7 +1338,8 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
//
|
//
|
||||||
double repeat = 0.0;
|
double repeat = 0.0;
|
||||||
if( argc >= 3 ) {
|
if( argc >= 3 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &repeat );
|
JS::RootedValue jsrepeat(cx, args.get(2));
|
||||||
|
ok &= JS::ToNumber(cx, jsrepeat, &repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1340,7 +1347,8 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
//
|
//
|
||||||
double delay = 0.0;
|
double delay = 0.0;
|
||||||
if( argc >= 4 ) {
|
if( argc >= 4 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &delay );
|
JS::RootedValue jsdelay(cx, args.get(3));
|
||||||
|
ok &= JS::ToNumber(cx, jsdelay, &delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
@ -1629,7 +1637,8 @@ bool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
|
|
||||||
if( argc >= 3 ) {
|
if( argc >= 3 ) {
|
||||||
paused = JS::ToBoolean(JS::RootedValue(cx, args.get(2)));
|
JS::RootedValue jspaused(cx, args.get(2));
|
||||||
|
paused = JS::ToBoolean(jspaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
@ -1729,7 +1738,8 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva
|
||||||
|
|
||||||
double interval = 0;
|
double interval = 0;
|
||||||
if( argc >= 3 ) {
|
if( argc >= 3 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &interval );
|
JS::RootedValue jsinterval(cx, args.get(2));
|
||||||
|
ok &= JS::ToNumber(cx, jsinterval, &interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1737,7 +1747,8 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva
|
||||||
//
|
//
|
||||||
double repeat = kRepeatForever;
|
double repeat = kRepeatForever;
|
||||||
if( argc >= 4 ) {
|
if( argc >= 4 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &repeat );
|
JS::RootedValue jsrepeat(cx, args.get(3));
|
||||||
|
ok &= JS::ToNumber(cx, jsrepeat, &repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1745,13 +1756,15 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva
|
||||||
//
|
//
|
||||||
double delay = 0;
|
double delay = 0;
|
||||||
if( argc >= 5 ) {
|
if( argc >= 5 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(4)), &delay );
|
JS::RootedValue jsdelay(cx, args.get(4));
|
||||||
|
ok &= JS::ToNumber(cx, jsdelay, &delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
|
|
||||||
if( argc >= 6 ) {
|
if( argc >= 6 ) {
|
||||||
paused = JS::ToBoolean(JS::RootedValue(cx, args.get(5)));
|
JS::RootedValue jspaused(cx, args.get(5));
|
||||||
|
paused = JS::ToBoolean(jspaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
@ -1841,7 +1854,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
|
||||||
double interval = 0;
|
double interval = 0;
|
||||||
if( argc >= 3 ) {
|
if( argc >= 3 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &interval );
|
JS::RootedValue jsinterval(cx, args.get(2));
|
||||||
|
ok &= JS::ToNumber(cx, jsinterval, &interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1849,7 +1863,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
//
|
//
|
||||||
double repeat = kRepeatForever;
|
double repeat = kRepeatForever;
|
||||||
if( argc >= 4 ) {
|
if( argc >= 4 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &repeat );
|
JS::RootedValue jsrepeat(cx, args.get(3));
|
||||||
|
ok &= JS::ToNumber(cx, jsrepeat, &repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1857,7 +1872,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
//
|
//
|
||||||
double delay = 0;
|
double delay = 0;
|
||||||
if( argc >= 5 ) {
|
if( argc >= 5 ) {
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(4)), &delay );
|
JS::RootedValue jsdelay(cx, args.get(4));
|
||||||
|
ok &= JS::ToNumber(cx, jsdelay, &delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1865,7 +1881,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
//
|
//
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
if( argc >= 6 ) {
|
if( argc >= 6 ) {
|
||||||
paused = JS::ToBoolean(JS::RootedValue(cx, args.get(5)));
|
JS::RootedValue jspaused(cx, args.get(5));
|
||||||
|
paused = JS::ToBoolean(jspaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2177,9 +2194,11 @@ bool js_cocos2dx_CCNode_setPosition(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
return true;
|
return true;
|
||||||
} if (argc == 2) {
|
} if (argc == 2) {
|
||||||
double x;
|
double x;
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(0)), &x );
|
JS::RootedValue jsx(cx, args.get(0));
|
||||||
|
ok &= JS::ToNumber(cx, jsx, &x);
|
||||||
double y;
|
double y;
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &y );
|
JS::RootedValue jsy(cx, args.get(1));
|
||||||
|
ok &= JS::ToNumber(cx, jsy, &y);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
|
||||||
cobj->setPosition(Point(x,y));
|
cobj->setPosition(Point(x,y));
|
||||||
|
@ -2209,9 +2228,11 @@ bool js_cocos2dx_CCNode_setContentSize(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
return true;
|
return true;
|
||||||
} if (argc == 2) {
|
} if (argc == 2) {
|
||||||
double width;
|
double width;
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(0)), &width );
|
JS::RootedValue jsw(cx, args.get(0));
|
||||||
|
ok &= JS::ToNumber(cx, jsw, &width);
|
||||||
double height;
|
double height;
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &height );
|
JS::RootedValue jsh(cx, args.get(1));
|
||||||
|
ok &= JS::ToNumber(cx, jsh, &height);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
|
||||||
cobj->setContentSize(Size(width,height));
|
cobj->setContentSize(Size(width,height));
|
||||||
|
@ -2769,7 +2790,8 @@ bool js_BezierActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
double arg0;
|
double arg0;
|
||||||
cocos2d::_ccBezierConfig arg1;
|
cocos2d::_ccBezierConfig arg1;
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0);
|
JS::RootedValue jsarg0(cx, args.get(0));
|
||||||
|
ok &= JS::ToNumber( cx, jsarg0, &arg0);
|
||||||
|
|
||||||
int num;
|
int num;
|
||||||
cocos2d::Vec2 *arr;
|
cocos2d::Vec2 *arr;
|
||||||
|
@ -2901,7 +2923,8 @@ bool js_CatmullRomActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *
|
||||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CatmullRom_initWithDuration : Invalid Native Object");
|
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CatmullRom_initWithDuration : Invalid Native Object");
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
double arg0;
|
double arg0;
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0);
|
JS::RootedValue jsarg0(cx, args.get(0));
|
||||||
|
ok &= JS::ToNumber(cx, jsarg0, &arg0);
|
||||||
|
|
||||||
int num;
|
int num;
|
||||||
Point *arr;
|
Point *arr;
|
||||||
|
@ -2962,9 +2985,9 @@ bool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc,
|
||||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Invalid Native Object");
|
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Invalid Native Object");
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
double arg0;
|
double arg0;
|
||||||
|
|
||||||
double arg2;
|
double arg2;
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0);
|
JS::RootedValue jsarg0(cx, args.get(0));
|
||||||
|
ok &= JS::ToNumber(cx, jsarg0, &arg0);
|
||||||
|
|
||||||
int num;
|
int num;
|
||||||
Point *arr;
|
Point *arr;
|
||||||
|
@ -2973,8 +2996,9 @@ bool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc,
|
||||||
for( int i=0; i < num;i++) {
|
for( int i=0; i < num;i++) {
|
||||||
arg1->addControlPoint(arr[i]);
|
arg1->addControlPoint(arr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(2)), &arg2);
|
JS::RootedValue jsarg2(cx, args.get(2));
|
||||||
|
ok &= JS::ToNumber(cx, jsarg2, &arg2);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Error processing arguments");
|
||||||
bool ret = cobj->initWithDuration(arg0, arg1, arg2);
|
bool ret = cobj->initWithDuration(arg0, arg1, arg2);
|
||||||
|
|
||||||
|
@ -3939,7 +3963,8 @@ bool js_cocos2dx_CCTMXLayer_getTileFlagsAt(JSContext *cx, uint32_t argc, jsval *
|
||||||
|
|
||||||
static bool jsval_to_string_vector(JSContext* cx, jsval v, std::vector<std::string>& ret) {
|
static bool jsval_to_string_vector(JSContext* cx, jsval v, std::vector<std::string>& ret) {
|
||||||
JS::RootedObject jsobj(cx);
|
JS::RootedObject jsobj(cx);
|
||||||
bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, v), &jsobj );
|
JS::RootedValue jsv(cx, v);
|
||||||
|
bool ok = JS_ValueToObject(cx, jsv, &jsobj);
|
||||||
JSB_PRECONDITION2( ok, cx, false, "Error converting value to object");
|
JSB_PRECONDITION2( ok, cx, false, "Error converting value to object");
|
||||||
JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array");
|
JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array");
|
||||||
|
|
||||||
|
@ -4542,7 +4567,8 @@ bool js_PlistParser_parse(JSContext *cx, unsigned argc, JS::Value *vp) {
|
||||||
|
|
||||||
//JS_GetStringCharsZ was removed in SpiderMonkey 33
|
//JS_GetStringCharsZ was removed in SpiderMonkey 33
|
||||||
//ok = JS_ParseJSON(cx, JS_GetStringCharsZ(cx, strVal), static_cast<uint32_t>(JS_GetStringEncodingLength(JSVAL_TO_STRING(strVal))), &outVal);
|
//ok = JS_ParseJSON(cx, JS_GetStringCharsZ(cx, strVal), static_cast<uint32_t>(JS_GetStringEncodingLength(JSVAL_TO_STRING(strVal))), &outVal);
|
||||||
ok = JS_ParseJSON(cx, JS::RootedString(cx, strVal.toString()), &outVal);
|
JS::RootedString jsout(cx, strVal.toString());
|
||||||
|
ok = JS_ParseJSON(cx, jsout, &outVal);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
args.rval().set(outVal);
|
args.rval().set(outVal);
|
||||||
|
@ -4655,8 +4681,9 @@ bool jsval_to_TTFConfig(JSContext *cx, jsval v, TTFConfig* ret) {
|
||||||
std::string fontFilePath,customGlyphs;
|
std::string fontFilePath,customGlyphs;
|
||||||
double fontSize, glyphs, outlineSize;
|
double fontSize, glyphs, outlineSize;
|
||||||
|
|
||||||
bool ok = v.isObject() &&
|
JS::RootedValue jsv(cx, v);
|
||||||
JS_ValueToObject(cx, JS::RootedValue(cx, v), &tmp) &&
|
bool ok = jsv.isObject() &&
|
||||||
|
JS_ValueToObject(cx, jsv, &tmp) &&
|
||||||
JS_GetProperty(cx, tmp, "fontFilePath", &js_fontFilePath) &&
|
JS_GetProperty(cx, tmp, "fontFilePath", &js_fontFilePath) &&
|
||||||
JS_GetProperty(cx, tmp, "fontSize", &js_fontSize) &&
|
JS_GetProperty(cx, tmp, "fontSize", &js_fontSize) &&
|
||||||
JS_GetProperty(cx, tmp, "outlineSize", &js_outlineSize) &&
|
JS_GetProperty(cx, tmp, "outlineSize", &js_outlineSize) &&
|
||||||
|
@ -4805,7 +4832,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v
|
||||||
ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1);
|
ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1);
|
||||||
if (!ok) { ok = true; break; }
|
if (!ok) { ok = true; break; }
|
||||||
bool arg2;
|
bool arg2;
|
||||||
arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2)));
|
JS::RootedValue jsarg2(cx, args.get(2));
|
||||||
|
arg2 = JS::ToBoolean(jsarg2);
|
||||||
bool ret = cobj->saveToFile(arg0, arg1, arg2);
|
bool ret = cobj->saveToFile(arg0, arg1, arg2);
|
||||||
jsval jsret = JSVAL_NULL;
|
jsval jsret = JSVAL_NULL;
|
||||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||||
|
@ -4823,7 +4851,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v
|
||||||
ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1);
|
ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1);
|
||||||
if (!ok) { ok = true; break; }
|
if (!ok) { ok = true; break; }
|
||||||
bool arg2;
|
bool arg2;
|
||||||
arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2)));
|
JS::RootedValue jsarg2(cx, args.get(2));
|
||||||
|
arg2 = JS::ToBoolean(jsarg2);
|
||||||
std::function<void (cocos2d::RenderTexture *, const std::basic_string<char> &)> arg3;
|
std::function<void (cocos2d::RenderTexture *, const std::basic_string<char> &)> arg3;
|
||||||
do {
|
do {
|
||||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(3)));
|
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(3)));
|
||||||
|
@ -4877,7 +4906,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v
|
||||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||||
if (!ok) { ok = true; break; }
|
if (!ok) { ok = true; break; }
|
||||||
bool arg1;
|
bool arg1;
|
||||||
arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1)));
|
JS::RootedValue jsarg1(cx, args.get(1));
|
||||||
|
arg1 = JS::ToBoolean(jsarg1);
|
||||||
bool ret = cobj->saveToFile(arg0, arg1);
|
bool ret = cobj->saveToFile(arg0, arg1);
|
||||||
jsval jsret = JSVAL_NULL;
|
jsval jsret = JSVAL_NULL;
|
||||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||||
|
@ -4892,7 +4922,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v
|
||||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||||
if (!ok) { ok = true; break; }
|
if (!ok) { ok = true; break; }
|
||||||
bool arg1;
|
bool arg1;
|
||||||
arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1)));
|
JS::RootedValue jsarg1(cx, args.get(1));
|
||||||
|
arg1 = JS::ToBoolean(jsarg1);
|
||||||
std::function<void (cocos2d::RenderTexture *, const std::basic_string<char> &)> arg2;
|
std::function<void (cocos2d::RenderTexture *, const std::basic_string<char> &)> arg2;
|
||||||
do {
|
do {
|
||||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(2)));
|
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(2)));
|
||||||
|
@ -4972,14 +5003,15 @@ bool js_cocos2dx_Camera_isVisibleInFrustum(JSContext *cx, uint32_t argc, jsval *
|
||||||
cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL);
|
cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL);
|
||||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_isVisibleInFrustum : Invalid Native Object");
|
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_isVisibleInFrustum : Invalid Native Object");
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
cocos2d::Vec3 min;
|
cocos2d::Vec3 min;
|
||||||
JS::RootedValue jsmin(cx);
|
JS::RootedValue jsmin(cx);
|
||||||
ok &= JS_GetProperty(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()), "min", &jsmin);
|
JS::RootedObject jsarg0(cx, args.get(0).toObjectOrNull());
|
||||||
|
ok &= JS_GetProperty(cx, jsarg0, "min", &jsmin);
|
||||||
ok &= jsval_to_vector3(cx, jsmin, &min);
|
ok &= jsval_to_vector3(cx, jsmin, &min);
|
||||||
|
|
||||||
cocos2d::Vec3 max;
|
cocos2d::Vec3 max;
|
||||||
JS::RootedValue jsmax(cx);
|
JS::RootedValue jsmax(cx);
|
||||||
ok &= JS_GetProperty(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()), "max", &jsmax);
|
ok &= JS_GetProperty(cx, jsarg0, "max", &jsmax);
|
||||||
ok &= jsval_to_vector3(cx, jsmax, &max);
|
ok &= jsval_to_vector3(cx, jsmax, &max);
|
||||||
|
|
||||||
cocos2d::AABB aabb(min, max);
|
cocos2d::AABB aabb(min, max);
|
||||||
|
@ -5088,7 +5120,8 @@ bool js_cocos2dx_EventKeyboard_constructor(JSContext *cx, uint32_t argc, jsval *
|
||||||
ok &= jsval_to_int32(cx, retVal, (int32_t *)&arg0);
|
ok &= jsval_to_int32(cx, retVal, (int32_t *)&arg0);
|
||||||
|
|
||||||
bool arg1;
|
bool arg1;
|
||||||
arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1)));
|
JS::RootedValue jsarg1(cx, args.get(1));
|
||||||
|
arg1 = JS::ToBoolean(jsarg1);
|
||||||
|
|
||||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventKeyboard_constructor : Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventKeyboard_constructor : Error processing arguments");
|
||||||
|
|
||||||
|
@ -5104,8 +5137,11 @@ bool js_cocos2dx_EventKeyboard_constructor(JSContext *cx, uint32_t argc, jsval *
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
args.rval().set( OBJECT_TO_JSVAL(obj));
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto));
|
||||||
|
JS::RootedValue objVal(cx, OBJECT_TO_JSVAL(obj));
|
||||||
|
args.rval().set(objVal);
|
||||||
// link the native object with the javascript object
|
// link the native object with the javascript object
|
||||||
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
||||||
JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventKeyboard");
|
JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventKeyboard");
|
||||||
|
@ -5150,32 +5186,20 @@ void js_register_cocos2dx_EventKeyboard(JSContext *cx, JS::HandleObject global)
|
||||||
|
|
||||||
JSFunctionSpec *st_funcs = NULL;
|
JSFunctionSpec *st_funcs = NULL;
|
||||||
|
|
||||||
|
JS::RootedObject parentProto(cx, jsb_cocos2d_Event_prototype);
|
||||||
jsb_cocos2d_EventKeyboard_prototype = JS_InitClass(
|
jsb_cocos2d_EventKeyboard_prototype = JS_InitClass(
|
||||||
cx, global,
|
cx, global,
|
||||||
JS::RootedObject(cx, jsb_cocos2d_Event_prototype),
|
parentProto,
|
||||||
jsb_cocos2d_EventKeyboard_class,
|
jsb_cocos2d_EventKeyboard_class,
|
||||||
js_cocos2dx_EventKeyboard_constructor, 0, // constructor
|
js_cocos2dx_EventKeyboard_constructor, 0, // constructor
|
||||||
properties,
|
properties,
|
||||||
funcs,
|
funcs,
|
||||||
NULL, // no static properties
|
NULL, // no static properties
|
||||||
st_funcs);
|
st_funcs);
|
||||||
// make the class enumerable in the registered namespace
|
|
||||||
// bool found;
|
|
||||||
//FIXME: Removed in Firefox v27
|
|
||||||
// JS_SetPropertyAttributes(cx, global, "EventKeyboard", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
|
|
||||||
// add the proto and JSClass to the type->js info hash table
|
// add the proto and JSClass to the type->js info hash table
|
||||||
TypeTest<cocos2d::EventKeyboard> t;
|
JS::RootedObject proto(cx, jsb_cocos2d_EventKeyboard_prototype);
|
||||||
js_type_class_t *p;
|
jsb_register_class<cocos2d::EventKeyboard>(cx, jsb_cocos2d_EventKeyboard_class, proto, parentProto);
|
||||||
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_EventKeyboard_class;
|
|
||||||
p->proto = jsb_cocos2d_EventKeyboard_prototype;
|
|
||||||
p->parentProto = jsb_cocos2d_Event_prototype;
|
|
||||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log("Message");
|
// console.log("Message");
|
||||||
|
@ -5525,8 +5549,8 @@ bool js_cocos2dx_PolygonInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
JS::RootedObject proto(cx, typeClass->proto.get());
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
JS::RootedObject parent(cx, typeClass->parentProto.get());
|
JS::RootedObject parent(cx, typeClass->parentProto.ref());
|
||||||
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
||||||
args.rval().set(OBJECT_TO_JSVAL(obj));
|
args.rval().set(OBJECT_TO_JSVAL(obj));
|
||||||
// link the native object with the javascript object
|
// link the native object with the javascript object
|
||||||
|
@ -5596,17 +5620,8 @@ void js_register_cocos2dx_PolygonInfo(JSContext *cx, JS::HandleObject global)
|
||||||
st_funcs);
|
st_funcs);
|
||||||
|
|
||||||
// add the proto and JSClass to the type->js info hash table
|
// add the proto and JSClass to the type->js info hash table
|
||||||
TypeTest<cocos2d::PolygonInfo> t;
|
JS::RootedObject proto(cx, jsb_cocos2d_PolygonInfo_prototype);
|
||||||
js_type_class_t *p;
|
jsb_register_class<cocos2d::PolygonInfo>(cx, jsb_cocos2d_PolygonInfo_class, proto, JS::NullPtr());
|
||||||
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_PolygonInfo_class;
|
|
||||||
p->proto = jsb_cocos2d_PolygonInfo_prototype;
|
|
||||||
p->parentProto = NULL;
|
|
||||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSClass *jsb_cocos2d_AutoPolygon_class;
|
JSClass *jsb_cocos2d_AutoPolygon_class;
|
||||||
|
@ -5715,8 +5730,8 @@ bool js_cocos2dx_AutoPolygon_constructor(JSContext *cx, uint32_t argc, jsval *vp
|
||||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
JS::RootedObject proto(cx, typeClass->proto.get());
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
JS::RootedObject parent(cx, typeClass->parentProto.get());
|
JS::RootedObject parent(cx, typeClass->parentProto.ref());
|
||||||
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
||||||
args.rval().set(OBJECT_TO_JSVAL(obj));
|
args.rval().set(OBJECT_TO_JSVAL(obj));
|
||||||
// link the native object with the javascript object
|
// link the native object with the javascript object
|
||||||
|
@ -5778,23 +5793,10 @@ void js_register_cocos2dx_AutoPolygon(JSContext *cx, JS::HandleObject global) {
|
||||||
funcs,
|
funcs,
|
||||||
NULL, // no static properties
|
NULL, // no static properties
|
||||||
st_funcs);
|
st_funcs);
|
||||||
// make the class enumerable in the registered namespace
|
|
||||||
// bool found;
|
|
||||||
//FIXME: Removed in Firefox v27
|
|
||||||
// JS_SetPropertyAttributes(cx, global, "AutoPolygon", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
|
|
||||||
// add the proto and JSClass to the type->js info hash table
|
// add the proto and JSClass to the type->js info hash table
|
||||||
TypeTest<cocos2d::AutoPolygon> t;
|
JS::RootedObject proto(cx, jsb_cocos2d_AutoPolygon_prototype);
|
||||||
js_type_class_t *p;
|
jsb_register_class<cocos2d::AutoPolygon>(cx, jsb_cocos2d_AutoPolygon_class, proto, JS::NullPtr());
|
||||||
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_AutoPolygon_class;
|
|
||||||
p->proto = jsb_cocos2d_AutoPolygon_prototype;
|
|
||||||
p->parentProto = NULL;
|
|
||||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool js_cocos2dx_ComponentJS_getScriptObject(JSContext *cx, uint32_t argc, jsval *vp)
|
bool js_cocos2dx_ComponentJS_getScriptObject(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
|
|
@ -100,8 +100,8 @@ inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) {
|
||||||
|
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
|
|
||||||
JS::RootedObject proto(cx, const_cast<JSObject*>(typeProxy->proto.get()));
|
JS::RootedObject proto(cx, typeProxy->proto.ref().get());
|
||||||
JS::RootedObject parent(cx, const_cast<JSObject*>(typeProxy->parentProto.get()));
|
JS::RootedObject parent(cx, typeProxy->parentProto.ref().get());
|
||||||
JS::RootedObject js_obj(cx, JS_NewObject(cx, typeProxy->jsclass, proto, parent));
|
JS::RootedObject js_obj(cx, JS_NewObject(cx, typeProxy->jsclass, proto, parent));
|
||||||
proxy = jsb_new_proxy(native_obj, js_obj);
|
proxy = jsb_new_proxy(native_obj, js_obj);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -44,7 +44,9 @@ public:
|
||||||
|
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
|
|
||||||
JS_CallFunctionValue(cx, JS::RootedObject(cx, thisObj.toObjectOrNull()), JS::RootedValue(cx, callback), JS::HandleValueArray::empty(), &retval);
|
JS::RootedObject jsThis(cx, thisObj.toObjectOrNull());
|
||||||
|
JS::RootedValue jsCallback(cx, callback);
|
||||||
|
JS_CallFunctionValue(cx, jsThis, jsCallback, JS::HandleValueArray::empty(), &retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,8 @@ void register_CCBuilderReader(JSContext *cx, JS::HandleObject global)
|
||||||
JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocosbuilder_CCBReader_prototype), "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocosbuilder_CCBReader_prototype);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocosbuilder_CCBAnimationManager_prototype), "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
tmpObj.set(jsb_cocosbuilder_CCBAnimationManager_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ jsval animationInfo_to_jsval(JSContext* cx, const cocostudio::timeline::Animatio
|
||||||
{
|
{
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, std_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsname(cx, std_string_to_jsval(cx, v.name));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "startIndex", v.startIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "startIndex", v.startIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "endIndex", v.endIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "endIndex", v.endIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|
|
@ -217,8 +217,6 @@ static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
if(argc == 5){
|
if(argc == 5){
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
|
||||||
|
|
||||||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||||
tmpObj->autorelease();
|
tmpObj->autorelease();
|
||||||
|
|
||||||
|
@ -747,7 +745,8 @@ bool js_set_AnimationData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId
|
||||||
cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj);
|
cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj);
|
||||||
if (cobj) {
|
if (cobj) {
|
||||||
std::string name;
|
std::string name;
|
||||||
bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name);
|
JS::RootedValue jsname(cx, vp.get());
|
||||||
|
bool ok = jsval_to_std_string(cx, jsname, &name);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_name : Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_name : Error processing arguments");
|
||||||
cobj->name = name;
|
cobj->name = name;
|
||||||
return true;
|
return true;
|
||||||
|
@ -776,7 +775,8 @@ bool js_set_AnimationData_movementNames(JSContext *cx, JS::HandleObject obj, JS:
|
||||||
cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj);
|
cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj);
|
||||||
if (cobj) {
|
if (cobj) {
|
||||||
std::vector<std::string> movementNames;
|
std::vector<std::string> movementNames;
|
||||||
bool ok = jsval_to_std_vector_string(cx, JS::RootedValue(cx, vp.get()), &movementNames);
|
JS::RootedValue jsmovementNames(cx, vp.get());
|
||||||
|
bool ok = jsval_to_std_vector_string(cx, jsmovementNames, &movementNames);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_movementNames : Error processing arguments.");
|
JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_movementNames : Error processing arguments.");
|
||||||
cobj->movementNames.clear();
|
cobj->movementNames.clear();
|
||||||
cobj->movementNames = movementNames;
|
cobj->movementNames = movementNames;
|
||||||
|
@ -901,7 +901,8 @@ bool js_set_MovementData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId
|
||||||
cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj);
|
cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj);
|
||||||
if (cobj) {
|
if (cobj) {
|
||||||
std::string name;
|
std::string name;
|
||||||
bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name);
|
JS::RootedValue jsname(cx, vp.get());
|
||||||
|
bool ok = jsval_to_std_string(cx, jsname, &name);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "js_set_MovementData_name : Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "js_set_MovementData_name : Error processing arguments");
|
||||||
cobj->name = name;
|
cobj->name = name;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1375,7 +1376,8 @@ bool js_set_TextureData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId i
|
||||||
cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL);
|
cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL);
|
||||||
if (cobj) {
|
if (cobj) {
|
||||||
std::string name;
|
std::string name;
|
||||||
bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name);
|
JS::RootedValue jsname(cx, vp.get());
|
||||||
|
bool ok = jsval_to_std_string(cx, jsname, &name);
|
||||||
JSB_PRECONDITION2(ok, cx, false, "js_set_TextureData_name : Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "js_set_TextureData_name : Error processing arguments");
|
||||||
cobj->name = name;
|
cobj->name = name;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1398,15 +1400,18 @@ extern JSObject* jsb_cocostudio_timeline_Frame_prototype;
|
||||||
|
|
||||||
void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global)
|
void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global)
|
||||||
{
|
{
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ColliderBody_prototype), "getCalculatedVertexList", js_cocos2dx_studio_ColliderBody_getCalculatedVertexList, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedObject proto(cx, jsb_cocostudio_ColliderBody_prototype);
|
||||||
|
JS_DefineFunction(cx, proto, "getCalculatedVertexList", js_cocos2dx_studio_ColliderBody_getCalculatedVertexList, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureAnimation_prototype), "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
proto.set(jsb_cocostudio_ArmatureAnimation_prototype);
|
||||||
|
JS_DefineFunction(cx, proto, "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureAnimation_prototype), "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, proto, "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureDataManager_prototype), "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
proto.set(jsb_cocostudio_ArmatureDataManager_prototype);
|
||||||
|
JS_DefineFunction(cx, proto, "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ActionManagerEx_prototype), "initWithDictionaryEx", js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
|
||||||
|
proto.set(jsb_cocostudio_ActionManagerEx_prototype);
|
||||||
|
JS_DefineFunction(cx, proto, "initWithDictionaryEx", js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
||||||
|
|
||||||
JS::RootedObject frame(cx, jsb_cocostudio_timeline_Frame_prototype);
|
JS::RootedObject frame(cx, jsb_cocostudio_timeline_Frame_prototype);
|
||||||
JS_DefineFunction(cx, frame, "setEasingParams", js_cocos2dx_studio_Frame_setEasingParams, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
JS_DefineFunction(cx, frame, "setEasingParams", js_cocos2dx_studio_Frame_setEasingParams, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
||||||
|
@ -1442,7 +1447,8 @@ void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global)
|
||||||
JS_DefineProperty(cx, movementData, "loop", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_loop, js_set_MovementData_loop);
|
JS_DefineProperty(cx, movementData, "loop", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_loop, js_set_MovementData_loop);
|
||||||
JS_DefineProperty(cx, movementData, "tweenEasing", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_tweenEasing, js_set_MovementData_tweenEasing);
|
JS_DefineProperty(cx, movementData, "tweenEasing", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_tweenEasing, js_set_MovementData_tweenEasing);
|
||||||
|
|
||||||
JS_DefineProperty(cx, JS::RootedObject(cx, jsb_cocostudio_ContourData_prototype), "vertextList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_ContourData_vertexList, js_set_ContourData_vertexList);
|
proto.set(jsb_cocostudio_ContourData_prototype);
|
||||||
|
JS_DefineProperty(cx, proto, "vertextList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_ContourData_vertexList, js_set_ContourData_vertexList);
|
||||||
|
|
||||||
JS::RootedObject textureData(cx, jsb_cocostudio_TextureData_prototype);
|
JS::RootedObject textureData(cx, jsb_cocostudio_TextureData_prototype);
|
||||||
JS_DefineProperty(cx, textureData, "contourDataList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_contourDataList, js_set_TextureData_contourDataList);
|
JS_DefineProperty(cx, textureData, "contourDataList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_contourDataList, js_set_TextureData_contourDataList);
|
||||||
|
|
|
@ -61,10 +61,10 @@ ComponentJS::ComponentJS(const std::string& scriptFileName)
|
||||||
|
|
||||||
if (_succeedLoadingScript)
|
if (_succeedLoadingScript)
|
||||||
{
|
{
|
||||||
JSObject* classObj = classValue.toObjectOrNull();
|
JS::RootedObject classObj(cx, classValue.toObjectOrNull());
|
||||||
const JSClass* theClass = JS_GetClass(classObj);
|
const JSClass* theClass = JS_GetClass(classObj);
|
||||||
JS::RootedValue protoValue(cx);
|
JS::RootedValue protoValue(cx);
|
||||||
JS_GetProperty(cx, JS::RootedObject(cx, classObj), "prototype", &protoValue);
|
JS_GetProperty(cx, classObj, "prototype", &protoValue);
|
||||||
|
|
||||||
TypeTest<ComponentJS> t;
|
TypeTest<ComponentJS> t;
|
||||||
js_type_class_t *typeClass = nullptr;
|
js_type_class_t *typeClass = nullptr;
|
||||||
|
|
|
@ -43,7 +43,8 @@ extern JSObject* jsb_cocos2d_experimental_ui_VideoPlayer_prototype;
|
||||||
|
|
||||||
void register_all_cocos2dx_experimental_video_manual(JSContext* cx, JS::HandleObject global)
|
void register_all_cocos2dx_experimental_video_manual(JSContext* cx, JS::HandleObject global)
|
||||||
{
|
{
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype), "addEventListener", jsb_cocos2dx_experimental_ui_VideoPlayer_addEventListener, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype);
|
||||||
|
JS_DefineFunction(cx, proto, "addEventListener", jsb_cocos2dx_experimental_ui_VideoPlayer_addEventListener, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -145,10 +145,11 @@ extern JSObject* jsb_cocos2d_experimental_ui_WebView_prototype;
|
||||||
|
|
||||||
void register_all_cocos2dx_experimental_webView_manual(JSContext* cx, JS::HandleObject global)
|
void register_all_cocos2dx_experimental_webView_manual(JSContext* cx, JS::HandleObject global)
|
||||||
{
|
{
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnShouldStartLoading", jsb_cocos2dx_experimental_webView_setOnShouldStartLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_WebView_prototype);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnDidFinishLoading", jsb_cocos2dx_experimental_webView_setOnDidFinishLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, proto, "setOnShouldStartLoading", jsb_cocos2dx_experimental_webView_setOnShouldStartLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnDidFailLoading", jsb_cocos2dx_experimental_webView_setOnDidFailLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, proto, "setOnDidFinishLoading", jsb_cocos2dx_experimental_webView_setOnDidFinishLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnJSCallback", jsb_cocos2dx_experimental_webView_setOnJSCallback, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, proto, "setOnDidFailLoading", jsb_cocos2dx_experimental_webView_setOnDidFailLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
JS_DefineFunction(cx, proto, "setOnJSCallback", jsb_cocos2dx_experimental_webView_setOnJSCallback, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -377,7 +377,8 @@ static bool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc,
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
||||||
pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull()));
|
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
|
||||||
|
pNativeSource->setTableViewDataSource(jsdata);
|
||||||
|
|
||||||
__Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject());
|
__Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject());
|
||||||
if (NULL == userDict)
|
if (NULL == userDict)
|
||||||
|
@ -409,7 +410,8 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *
|
||||||
{
|
{
|
||||||
|
|
||||||
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
||||||
pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull()));
|
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
|
||||||
|
pNativeSource->setTableViewDataSource(jsdata);
|
||||||
|
|
||||||
cocos2d::Size arg1;
|
cocos2d::Size arg1;
|
||||||
ok &= jsval_to_ccsize(cx, args.get(1), &arg1);
|
ok &= jsval_to_ccsize(cx, args.get(1), &arg1);
|
||||||
|
@ -479,7 +481,8 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp
|
||||||
{
|
{
|
||||||
|
|
||||||
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource();
|
||||||
pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull()));
|
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
|
||||||
|
pNativeSource->setTableViewDataSource(jsdata);
|
||||||
cobj->setDataSource(pNativeSource);
|
cobj->setDataSource(pNativeSource);
|
||||||
|
|
||||||
cocos2d::Size arg1;
|
cocos2d::Size arg1;
|
||||||
|
@ -630,7 +633,8 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext
|
||||||
// save the delegate
|
// save the delegate
|
||||||
JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget();
|
JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget();
|
||||||
|
|
||||||
nativeDelegate->setJSCallback(args.get(1), JS::RootedObject(cx, jsDelegate));
|
JS::RootedObject jscb(cx, jsDelegate);
|
||||||
|
nativeDelegate->setJSCallback(args.get(1), jscb);
|
||||||
nativeDelegate->setEventType(arg2);
|
nativeDelegate->setEventType(arg2);
|
||||||
|
|
||||||
__Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject());
|
__Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject());
|
||||||
|
@ -997,17 +1001,18 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject glob
|
||||||
JS::RootedObject tmpObj(cx);
|
JS::RootedObject tmpObj(cx);
|
||||||
get_or_create_js_obj(cx, global, "cc", &ccObj);
|
get_or_create_js_obj(cx, global, "cc", &ccObj);
|
||||||
|
|
||||||
JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype);
|
tmpObj.set(jsb_cocos2d_extension_AssetsManagerEx_prototype);
|
||||||
JS_DefineFunction(cx, am, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, am, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS::RootedObject manifest(cx, jsb_cocos2d_extension_Manifest_prototype);
|
tmpObj.set(jsb_cocos2d_extension_Manifest_prototype);
|
||||||
JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, manifest, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
//JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
//JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
//JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
//JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_extension_ScrollView_prototype), "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocos2d_extension_ScrollView_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS::RootedObject tableview(cx, jsb_cocos2d_extension_TableView_prototype);
|
JS::RootedObject tableview(cx, jsb_cocos2d_extension_TableView_prototype);
|
||||||
JS_DefineFunction(cx, tableview, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tableview, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, tableview, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tableview, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
@ -1017,7 +1022,7 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject glob
|
||||||
JS_DefineFunction(cx, control, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, control, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_GetProperty(cx, ccObj, "TableView", &tmpVal);
|
JS_GetProperty(cx, ccObj, "TableView", &tmpVal);
|
||||||
tmpObj = tmpVal.toObjectOrNull();
|
tmpObj.set(tmpVal.toObjectOrNull());
|
||||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS::RootedObject jsbObj(cx);
|
JS::RootedObject jsbObj(cx);
|
||||||
|
|
|
@ -85,7 +85,9 @@ bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
typeClass = typeMapIter->second;
|
typeClass = typeMapIter->second;
|
||||||
CCASSERT(typeClass, "The value is null.");
|
CCASSERT(typeClass, "The value is null.");
|
||||||
|
|
||||||
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto));
|
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||||
|
JS::RootedObject parentProto(cx, typeClass->parentProto.ref());
|
||||||
|
JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto);
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
args.rval().set(OBJECT_TO_JSVAL(obj));
|
args.rval().set(OBJECT_TO_JSVAL(obj));
|
||||||
// link the native object with the javascript object
|
// link the native object with the javascript object
|
||||||
|
@ -159,32 +161,21 @@ void js_register_cocos2dx_GLNode(JSContext *cx, JS::HandleObject global) {
|
||||||
JS_FN("create", js_cocos2dx_GLNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
JS_FN("create", js_cocos2dx_GLNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JS::RootedObject parentProto(cx, jsb_cocos2d_Node_prototype);
|
||||||
js_cocos2dx_GLNode_prototype = JS_InitClass(
|
js_cocos2dx_GLNode_prototype = JS_InitClass(
|
||||||
cx, global,
|
cx, global,
|
||||||
JS::RootedObject(cx, jsb_cocos2d_Node_prototype),
|
parentProto,
|
||||||
js_cocos2dx_GLNode_class,
|
js_cocos2dx_GLNode_class,
|
||||||
js_cocos2dx_GLNode_constructor, 0, // constructor
|
js_cocos2dx_GLNode_constructor, 0, // constructor
|
||||||
properties,
|
properties,
|
||||||
funcs,
|
funcs,
|
||||||
NULL, // no static properties
|
NULL, // no static properties
|
||||||
st_funcs);
|
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<cocos2d::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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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; })()");
|
anonEvaluate(cx, global, "(function () { cc.GLNode.extend = cc.Class.extend; })()");
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,15 +73,8 @@ void JSStringWrapper::set(JSString* str, JSContext* cx)
|
||||||
{
|
{
|
||||||
cx = ScriptingCore::getInstance()->getGlobalContext();
|
cx = ScriptingCore::getInstance()->getGlobalContext();
|
||||||
}
|
}
|
||||||
// JS_EncodeString isn't supported in SpiderMonkey ff19.0.
|
JS::RootedString jsstr(cx, str);
|
||||||
//buffer = JS_EncodeString(cx, string);
|
_buffer = JS_EncodeStringToUTF8(cx, jsstr);
|
||||||
|
|
||||||
//JS_GetStringCharsZ is removed in SpiderMonkey 33
|
|
||||||
// unsigned short* pStrUTF16 = (unsigned short*)JS_GetStringCharsZ(cx, str);
|
|
||||||
|
|
||||||
// _buffer = cc_utf16_to_utf8(pStrUTF16, -1, NULL, NULL);
|
|
||||||
|
|
||||||
_buffer = JS_EncodeStringToUTF8(cx, JS::RootedString(cx, str));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* JSStringWrapper::get()
|
const char* JSStringWrapper::get()
|
||||||
|
@ -315,7 +308,7 @@ bool jsval_to_charptr( JSContext *cx, JS::HandleValue vp, const char **ret )
|
||||||
JSStringWrapper strWrapper(jsstr);
|
JSStringWrapper strWrapper(jsstr);
|
||||||
|
|
||||||
// XXX: It is converted to String and then back to char* to autorelease the created object.
|
// XXX: It is converted to String and then back to char* to autorelease the created object.
|
||||||
__String *tmp = String::create(strWrapper.get());
|
__String *tmp = __String::create(strWrapper.get());
|
||||||
|
|
||||||
JSB_PRECONDITION2( tmp, cx, false, "Error creating string from UTF8");
|
JSB_PRECONDITION2( tmp, cx, false, "Error creating string from UTF8");
|
||||||
|
|
||||||
|
@ -696,27 +689,28 @@ bool jsval_to_ray(JSContext *cx, JS::HandleValue v, cocos2d::Ray* ret)
|
||||||
bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, __Array** ret)
|
bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, __Array** ret)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
__Array* pArray = Array::create();
|
__Array* pArray = __Array::create();
|
||||||
for( int i=0; i < argc; i++ )
|
for( int i=0; i < argc; i++ )
|
||||||
{
|
{
|
||||||
double num = 0.0;
|
double num = 0.0;
|
||||||
// optimization: JS::ToNumber is expensive. And can convert an string like "12" to a number
|
// optimization: JS::ToNumber is expensive. And can convert an string like "12" to a number
|
||||||
if (vp->isNumber()) {
|
JS::RootedValue jsv(cx, *vp);
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx, *vp), &num );
|
if (jsv.isNumber()) {
|
||||||
|
ok &= JS::ToNumber(cx, jsv, &num );
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pArray->addObject(Integer::create((int)num));
|
pArray->addObject(__Integer::create((int)num));
|
||||||
}
|
}
|
||||||
else if (vp->isString())
|
else if (jsv.isString())
|
||||||
{
|
{
|
||||||
JSStringWrapper str(vp->toString(), cx);
|
JSStringWrapper str(jsv, cx);
|
||||||
pArray->addObject(String::create(str.get()));
|
pArray->addObject(__String::create(str.get()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
js_proxy_t* p;
|
js_proxy_t* p;
|
||||||
JSObject* obj = vp->toObjectOrNull();
|
JS::RootedObject obj(cx, jsv.toObjectOrNull());
|
||||||
p = jsb_get_js_proxy(obj);
|
p = jsb_get_js_proxy(obj);
|
||||||
if (p) {
|
if (p) {
|
||||||
pArray->addObject((Ref*)p->ptr);
|
pArray->addObject((Ref*)p->ptr);
|
||||||
|
@ -1003,20 +997,20 @@ bool jsval_to_ccarray(JSContext* cx, JS::HandleValue v, __Array** ret)
|
||||||
}
|
}
|
||||||
else if (value.isString()) {
|
else if (value.isString()) {
|
||||||
JSStringWrapper valueWapper(value.toString(), cx);
|
JSStringWrapper valueWapper(value.toString(), cx);
|
||||||
arr->addObject(String::create(valueWapper.get()));
|
arr->addObject(__String::create(valueWapper.get()));
|
||||||
// CCLOG("iterate array: value = %s", valueWapper.get().c_str());
|
// CCLOG("iterate array: value = %s", valueWapper.get().c_str());
|
||||||
}
|
}
|
||||||
else if (value.isNumber()) {
|
else if (value.isNumber()) {
|
||||||
double number = 0.0;
|
double number = 0.0;
|
||||||
ok = JS::ToNumber(cx, value, &number);
|
ok = JS::ToNumber(cx, value, &number);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
arr->addObject(Double::create(number));
|
arr->addObject(__Double::create(number));
|
||||||
// CCLOG("iterate array: value = %lf", number);
|
// CCLOG("iterate array: value = %lf", number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value.isBoolean()) {
|
else if (value.isBoolean()) {
|
||||||
bool boolVal = JS::ToBoolean(value);
|
bool boolVal = JS::ToBoolean(value);
|
||||||
arr->addObject(Bool::create(boolVal));
|
arr->addObject(__Bool::create(boolVal));
|
||||||
// CCLOG("iterate object: value = %d", boolVal);
|
// CCLOG("iterate object: value = %d", boolVal);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1928,20 +1922,20 @@ bool jsval_to_ccdictionary(JSContext* cx, JS::HandleValue v, __Dictionary** ret)
|
||||||
}
|
}
|
||||||
else if (value.isString()) {
|
else if (value.isString()) {
|
||||||
JSStringWrapper valueWapper(value.toString(), cx);
|
JSStringWrapper valueWapper(value.toString(), cx);
|
||||||
dict->setObject(String::create(valueWapper.get()), keyWrapper.get());
|
dict->setObject(__String::create(valueWapper.get()), keyWrapper.get());
|
||||||
// CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str());
|
// CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str());
|
||||||
}
|
}
|
||||||
else if (value.isNumber()) {
|
else if (value.isNumber()) {
|
||||||
double number = 0.0;
|
double number = 0.0;
|
||||||
bool ok = JS::ToNumber(cx, value, &number);
|
bool ok = JS::ToNumber(cx, value, &number);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
dict->setObject(Double::create(number), keyWrapper.get());
|
dict->setObject(__Double::create(number), keyWrapper.get());
|
||||||
// CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number);
|
// CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value.isBoolean()) {
|
else if (value.isBoolean()) {
|
||||||
bool boolVal = JS::ToBoolean(value);
|
bool boolVal = JS::ToBoolean(value);
|
||||||
dict->setObject(Bool::create(boolVal), keyWrapper.get());
|
dict->setObject(__Bool::create(boolVal), keyWrapper.get());
|
||||||
// CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal);
|
// CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2184,10 +2178,11 @@ jsval uniform_to_jsval(JSContext* cx, const cocos2d::Uniform* uniform)
|
||||||
{
|
{
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||||
if(!tmp) return JSVAL_NULL;
|
if(!tmp) return JSVAL_NULL;
|
||||||
|
JS::RootedValue jsname(cx, std_string_to_jsval(cx, uniform->name));
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "location", uniform->location, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
bool ok = JS_DefineProperty(cx, tmp, "location", uniform->location, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "size", uniform->size, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "size", uniform->size, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "type", uniform->type, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "type", uniform->type, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, std_string_to_jsval(cx, uniform->name)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
if(ok)
|
if(ok)
|
||||||
return OBJECT_TO_JSVAL(tmp);
|
return OBJECT_TO_JSVAL(tmp);
|
||||||
|
|
||||||
|
@ -2214,39 +2209,33 @@ jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t)
|
||||||
JS::RootedObject proto(cx);
|
JS::RootedObject proto(cx);
|
||||||
JS::RootedObject parent(cx);
|
JS::RootedObject parent(cx);
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent));
|
||||||
// if (!tmp) return JSVAL_NULL;
|
JS::RootedValue prop(cx);
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "fontName", JS::RootedValue(cx, std_string_to_jsval(cx, t._fontName)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
|
||||||
|
|
||||||
|
prop.set(std_string_to_jsval(cx, t._fontName));
|
||||||
|
ok &= JS_DefineProperty(cx, tmp, "fontName", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
ok &= JS_DefineProperty(cx, tmp, "fontSize", t._fontSize, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "fontSize", t._fontSize, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "textAlign", (int32_t)t._alignment, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "textAlign", (int32_t)t._alignment, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "verticalAlign", (int32_t)t._vertAlignment, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "verticalAlign", (int32_t)t._vertAlignment, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
prop.set(cccolor3b_to_jsval(cx, t._fontFillColor));
|
||||||
ok &= JS_DefineProperty(cx, tmp, "fillStyle", JS::RootedValue(cx, cccolor3b_to_jsval(cx, t._fontFillColor)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "fillStyle", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "boundingWidth", t._dimensions.width, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "boundingWidth", t._dimensions.width, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "boundingHeight", t._dimensions.height, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "boundingHeight", t._dimensions.height, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
// Shadow
|
// Shadow
|
||||||
ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", JS::RootedValue(cx, BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
prop.set(BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled));
|
||||||
|
ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
ok &= JS_DefineProperty(cx, tmp, "shadowOffsetX", t._shadow._shadowOffset.width, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "shadowOffsetX", t._shadow._shadowOffset.width, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "shadowOffsetY", t._shadow._shadowOffset.height, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "shadowOffsetY", t._shadow._shadowOffset.height, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "shadowBlur", t._shadow._shadowBlur, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "shadowBlur", t._shadow._shadowBlur, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
ok &= JS_DefineProperty(cx, tmp, "shadowOpacity", t._shadow._shadowOpacity, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "shadowOpacity", t._shadow._shadowOpacity, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
// Stroke
|
// Stroke
|
||||||
ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", JS::RootedValue(cx, BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
prop.set(BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled));
|
||||||
|
ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
ok &= JS_DefineProperty(cx, tmp, "strokeStyle", JS::RootedValue(cx, cccolor3b_to_jsval(cx, t._stroke._strokeColor)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
prop.set(cccolor3b_to_jsval(cx, t._stroke._strokeColor));
|
||||||
|
ok &= JS_DefineProperty(cx, tmp, "strokeStyle", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
ok &= JS_DefineProperty(cx, tmp, "lineWidth", t._stroke._strokeSize, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
ok &= JS_DefineProperty(cx, tmp, "lineWidth", t._stroke._strokeSize, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
@ -2343,7 +2332,8 @@ bool jsval_to_FontDefinition( JSContext *cx, JS::HandleValue vp, FontDefinition
|
||||||
JS_GetProperty(cx, jsobj, "fillStyle", &jsr);
|
JS_GetProperty(cx, jsobj, "fillStyle", &jsr);
|
||||||
|
|
||||||
JS::RootedObject jsobjColor(cx);
|
JS::RootedObject jsobjColor(cx);
|
||||||
if (!JS_ValueToObject( cx, JS::RootedValue(cx, jsr), &jsobjColor ) )
|
JS::RootedValue jsvalColor(cx, jsr);
|
||||||
|
if (!JS_ValueToObject( cx, jsvalColor, &jsobjColor ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
out->_fontFillColor = getColorFromJSObject(cx, jsobjColor);
|
out->_fontFillColor = getColorFromJSObject(cx, jsobjColor);
|
||||||
|
|
|
@ -123,14 +123,13 @@ bool jsvals_variadic_to_ccvector( JSContext *cx, /*jsval *vp, int argc,*/const J
|
||||||
for (int i = 0; i < args.length(); i++)
|
for (int i = 0; i < args.length(); i++)
|
||||||
{
|
{
|
||||||
js_proxy_t* p;
|
js_proxy_t* p;
|
||||||
JSObject* obj = JS::RootedValue(cx, args.get(i)).toObjectOrNull();
|
JS::RootedObject obj(cx, args.get(i).toObjectOrNull());
|
||||||
|
|
||||||
p = jsb_get_js_proxy(obj);
|
p = jsb_get_js_proxy(obj);
|
||||||
CCASSERT(p, "Native object not found!");
|
CCASSERT(p, "Native object not found!");
|
||||||
if (p) {
|
if (p) {
|
||||||
ret->pushBack((T)p->ptr);
|
ret->pushBack((T)p->ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSB_PRECONDITION3(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION3(ok, cx, false, "Error processing arguments");
|
||||||
|
|
|
@ -273,9 +273,10 @@ bool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() ));
|
JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() ));
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object");
|
JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object");
|
||||||
|
|
||||||
|
JS::RootedValue jsname(cx, charptr_to_jsval(cx, buffer));
|
||||||
if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
||||||
!JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
!JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
||||||
!JS_DefineProperty(cx, object, "name", JS::RootedValue(cx, charptr_to_jsval(cx, buffer)), JSPROP_ENUMERATE | JSPROP_PERMANENT) )
|
!JS_DefineProperty(cx, object, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
retval = OBJECT_TO_JSVAL(object);
|
retval = OBJECT_TO_JSVAL(object);
|
||||||
|
@ -317,9 +318,10 @@ bool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() ));
|
JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() ));
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object");
|
JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object");
|
||||||
|
|
||||||
|
JS::RootedValue jsname(cx, charptr_to_jsval(cx, buffer));
|
||||||
if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
||||||
!JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
!JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) ||
|
||||||
!JS_DefineProperty(cx, object, "name", JS::RootedValue(cx, charptr_to_jsval(cx, buffer)), JSPROP_ENUMERATE | JSPROP_PERMANENT) )
|
!JS_DefineProperty(cx, object, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
retval = OBJECT_TO_JSVAL(object);
|
retval = OBJECT_TO_JSVAL(object);
|
||||||
|
|
|
@ -37,23 +37,22 @@ void jsb_register_system( JSContext *_cx, JS::HandleObject object)
|
||||||
//
|
//
|
||||||
JS::RootedObject proto(_cx);
|
JS::RootedObject proto(_cx);
|
||||||
JS::RootedObject parent(_cx);
|
JS::RootedObject parent(_cx);
|
||||||
JSObject *sys = JS_NewObject(_cx, nullptr, proto, parent);
|
JS::RootedObject sys(_cx, JS_NewObject(_cx, nullptr, proto, parent));
|
||||||
JS::RootedValue systemVal(_cx);
|
JS::RootedValue systemVal(_cx);
|
||||||
systemVal = OBJECT_TO_JSVAL(sys);
|
systemVal.set(OBJECT_TO_JSVAL(sys));
|
||||||
JS_SetProperty(_cx, object, "sys", systemVal);
|
JS_SetProperty(_cx, object, "sys", systemVal);
|
||||||
|
|
||||||
|
|
||||||
// sys.localStorage
|
// sys.localStorage
|
||||||
JSObject *ls = JS_NewObject(_cx, nullptr, proto, parent);
|
JSObject *ls = JS_NewObject(_cx, nullptr, proto, parent);
|
||||||
JS::RootedValue lsVal(_cx);
|
JS::RootedValue lsVal(_cx);
|
||||||
lsVal = OBJECT_TO_JSVAL(ls);
|
lsVal.set(OBJECT_TO_JSVAL(ls));
|
||||||
JS_SetProperty(_cx, JS::RootedObject(_cx, sys), "localStorage", lsVal);
|
JS_SetProperty(_cx, sys, "localStorage", lsVal);
|
||||||
|
|
||||||
// sys.localStorage functions
|
// sys.localStorage functions
|
||||||
JS::RootedObject system(_cx, ls);
|
JS::RootedObject system(_cx, ls);
|
||||||
#include "js_bindings_system_functions_registration.h"
|
#include "js_bindings_system_functions_registration.h"
|
||||||
|
|
||||||
|
|
||||||
// Init DB with full path
|
// Init DB with full path
|
||||||
//NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
|
//NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
|
||||||
//NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"];
|
//NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"];
|
||||||
|
|
|
@ -84,8 +84,10 @@ jsval offMeshLinkData_to_jsval(JSContext* cx, const cocos2d::OffMeshLinkData& v)
|
||||||
JS::RootedObject parent(cx);
|
JS::RootedObject parent(cx);
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "startPosition", JS::RootedValue(cx, vector3_to_jsval(cx, v.startPosition)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsstartPos(cx, vector3_to_jsval(cx, v.startPosition));
|
||||||
JS_DefineProperty(cx, tmp, "endPosition", JS::RootedValue(cx, vector3_to_jsval(cx, v.endPosition)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedValue jsendPos(cx, vector3_to_jsval(cx, v.endPosition));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "startPosition", jsstartPos, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
JS_DefineProperty(cx, tmp, "endPosition", jsendPos, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
return OBJECT_TO_JSVAL(tmp);
|
return OBJECT_TO_JSVAL(tmp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ extern JSObject *jsb_cocos2d_NavMeshAgent_prototype;
|
||||||
|
|
||||||
void register_all_cocos2dx_navmesh_manual(JSContext *cx, JS::HandleObject global)
|
void register_all_cocos2dx_navmesh_manual(JSContext *cx, JS::HandleObject global)
|
||||||
{
|
{
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_NavMeshAgent_prototype), "move", jsb_cocos2dx_navmesh_NavMeshAgent_move, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedObject proto(cx, jsb_cocos2d_NavMeshAgent_prototype);
|
||||||
|
JS_DefineFunction(cx, proto, "move", jsb_cocos2dx_navmesh_NavMeshAgent_move, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
}
|
}
|
||||||
#endif //#if CC_USE_NAVMESH
|
#endif //#if CC_USE_NAVMESH
|
||||||
|
|
|
@ -341,7 +341,9 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest)
|
||||||
js_proxy_t *p;
|
js_proxy_t *p;
|
||||||
jsval out;
|
jsval out;
|
||||||
|
|
||||||
JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, JS::RootedObject(cx, MinXmlHttpRequest::js_proto), JS::RootedObject(cx, MinXmlHttpRequest::js_parent));
|
JS::RootedObject proto(cx, MinXmlHttpRequest::js_proto);
|
||||||
|
JS::RootedObject parentProto(cx, MinXmlHttpRequest::js_parent);
|
||||||
|
JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, proto, parentProto);
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
JS_SetPrivate(obj, req);
|
JS_SetPrivate(obj, req);
|
||||||
|
@ -519,7 +521,7 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState)
|
||||||
*/
|
*/
|
||||||
JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status)
|
JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status)
|
||||||
{
|
{
|
||||||
args.rval().set(INT_TO_JSVAL(_status));
|
args.rval().set(INT_TO_JSVAL((int)_status));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +623,8 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response)
|
||||||
//size_t utf16Count = 0;
|
//size_t utf16Count = 0;
|
||||||
//const jschar* utf16Buf = JS_GetStringCharsZAndLength(cx, JSVAL_TO_STRING(strVal), &utf16Count);
|
//const jschar* utf16Buf = JS_GetStringCharsZAndLength(cx, JSVAL_TO_STRING(strVal), &utf16Count);
|
||||||
//bool ok = JS_ParseJSON(cx, utf16Buf, static_cast<uint32_t>(utf16Count), &outVal);
|
//bool ok = JS_ParseJSON(cx, utf16Buf, static_cast<uint32_t>(utf16Count), &outVal);
|
||||||
bool ok = JS_ParseJSON(cx, JS::RootedString(cx, strVal.toString()), &outVal);
|
JS::RootedString jsstr(cx, strVal.toString());
|
||||||
|
bool ok = JS_ParseJSON(cx, jsstr, &outVal);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
|
|
@ -169,9 +169,11 @@ bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp)
|
||||||
if(!p)
|
if(!p)
|
||||||
{
|
{
|
||||||
//previous connection not found, create a new one
|
//previous connection not found, create a new one
|
||||||
JSObject *obj = JS_NewObject(cx, js_cocos2dx_socketio_class, JS::RootedObject(cx, js_cocos2dx_socketio_prototype), JS::NullPtr());
|
JS::RootedObject proto(cx, js_cocos2dx_socketio_prototype);
|
||||||
|
JSObject *obj = JS_NewObject(cx, js_cocos2dx_socketio_class, proto, JS::NullPtr());
|
||||||
p = jsb_new_proxy(ret, obj);
|
p = jsb_new_proxy(ret, obj);
|
||||||
siodelegate->setJSDelegate(JS::RootedObject(cx, p->obj));
|
JS::RootedObject jsdelegate(cx, p->obj);
|
||||||
|
siodelegate->setJSDelegate(jsdelegate);
|
||||||
}
|
}
|
||||||
jsret = OBJECT_TO_JSVAL(p->obj);
|
jsret = OBJECT_TO_JSVAL(p->obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,8 @@ bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, j
|
||||||
JSB_PRECONDITION2( ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2( ok, cx, false, "Error processing arguments");
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, JS::RootedObject(cx, js_cocos2dx_websocket_prototype), JS::NullPtr()));
|
JS::RootedObject proto(cx, js_cocos2dx_websocket_prototype);
|
||||||
|
JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, proto, JS::NullPtr()));
|
||||||
//JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, js_cocos2dx_websocket_class, args));
|
//JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, js_cocos2dx_websocket_class, args));
|
||||||
|
|
||||||
WebSocket* cobj = new WebSocket();
|
WebSocket* cobj = new WebSocket();
|
||||||
|
@ -316,7 +317,8 @@ bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, j
|
||||||
JS_DefineProperty(cx, obj, "URL", args.get(0), JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
JS_DefineProperty(cx, obj, "URL", args.get(0), JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
||||||
|
|
||||||
//protocol not support yet (always return "")
|
//protocol not support yet (always return "")
|
||||||
JS_DefineProperty(cx, obj, "protocol", JS::RootedValue(cx, c_string_to_jsval(cx, "")), JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
JS::RootedValue jsprotocol(cx, c_string_to_jsval(cx, ""));
|
||||||
|
JS_DefineProperty(cx, obj, "protocol", jsprotocol, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
||||||
|
|
||||||
// link the native object with the javascript object
|
// link the native object with the javascript object
|
||||||
js_proxy_t *p = jsb_new_proxy(cobj, obj);
|
js_proxy_t *p = jsb_new_proxy(cobj, obj);
|
||||||
|
@ -392,10 +394,6 @@ void register_jsb_websocket(JSContext *cx, JS::HandleObject global) {
|
||||||
JS_DefineProperty(cx, jsclassObj, "OPEN", (int)WebSocket::State::OPEN, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
JS_DefineProperty(cx, jsclassObj, "OPEN", (int)WebSocket::State::OPEN, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
||||||
JS_DefineProperty(cx, jsclassObj, "CLOSING", (int)WebSocket::State::CLOSING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
JS_DefineProperty(cx, jsclassObj, "CLOSING", (int)WebSocket::State::CLOSING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
||||||
JS_DefineProperty(cx, jsclassObj, "CLOSED", (int)WebSocket::State::CLOSED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
JS_DefineProperty(cx, jsclassObj, "CLOSED", (int)WebSocket::State::CLOSED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
||||||
|
|
||||||
// make the class enumerable in the registered namespace
|
|
||||||
//FIXME: bool found;
|
|
||||||
// JS_SetPropertyAttributes(cx, global, "WebSocket", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -222,11 +222,16 @@ jsval physics3d_collisionPoint_to_jsval(JSContext*cx, const Physics3DCollisionIn
|
||||||
{
|
{
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
||||||
|
|
||||||
JS_DefineProperty(cx, tmp, "localPositionOnA", JS::RootedValue(cx, vector3_to_jsval(cx, point.localPositionOnA)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedValue prop(cx, vector3_to_jsval(cx, point.localPositionOnA));
|
||||||
JS_DefineProperty(cx, tmp, "localPositionOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.localPositionOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "localPositionOnA", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineProperty(cx, tmp, "worldPositionOnA", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldPositionOnA)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
prop.set(vector3_to_jsval(cx, point.localPositionOnB));
|
||||||
JS_DefineProperty(cx, tmp, "worldPositionOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldPositionOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "localPositionOnB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineProperty(cx, tmp, "worldNormalOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldNormalOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
prop.set(vector3_to_jsval(cx, point.worldPositionOnA));
|
||||||
|
JS_DefineProperty(cx, tmp, "worldPositionOnA", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
prop.set(vector3_to_jsval(cx, point.worldPositionOnB));
|
||||||
|
JS_DefineProperty(cx, tmp, "worldPositionOnB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
prop.set(vector3_to_jsval(cx, point.worldNormalOnB));
|
||||||
|
JS_DefineProperty(cx, tmp, "worldNormalOnB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
return OBJECT_TO_JSVAL(tmp);
|
return OBJECT_TO_JSVAL(tmp);
|
||||||
}
|
}
|
||||||
|
@ -236,10 +241,12 @@ jsval physics3d_collisioninfo_to_jsval(JSContext* cx, const Physics3DCollisionIn
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
||||||
|
|
||||||
js_proxy_t* proxy = js_get_or_create_proxy<Physics3DObject>(cx, ci.objA);
|
js_proxy_t* proxy = js_get_or_create_proxy<Physics3DObject>(cx, ci.objA);
|
||||||
JS_DefineProperty(cx, tmp, "objA", JS::RootedValue(cx, OBJECT_TO_JSVAL(proxy->obj)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedValue prop(cx, OBJECT_TO_JSVAL(proxy->obj));
|
||||||
|
JS_DefineProperty(cx, tmp, "objA", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
proxy = js_get_or_create_proxy<Physics3DObject>(cx, ci.objB);
|
proxy = js_get_or_create_proxy<Physics3DObject>(cx, ci.objB);
|
||||||
JS_DefineProperty(cx, tmp, "objB", JS::RootedValue(cx, OBJECT_TO_JSVAL(proxy->obj)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
prop.set(OBJECT_TO_JSVAL(proxy->obj));
|
||||||
|
JS_DefineProperty(cx, tmp, "objB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS::RootedObject jsarr(cx, JS_NewArrayObject(cx, ci.collisionPointList.size()));
|
JS::RootedObject jsarr(cx, JS_NewArrayObject(cx, ci.collisionPointList.size()));
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
@ -248,7 +255,8 @@ jsval physics3d_collisioninfo_to_jsval(JSContext* cx, const Physics3DCollisionIn
|
||||||
JS::RootedValue element(cx, physics3d_collisionPoint_to_jsval(cx, *iter));
|
JS::RootedValue element(cx, physics3d_collisionPoint_to_jsval(cx, *iter));
|
||||||
JS_SetElement(cx, jsarr, i++, element);
|
JS_SetElement(cx, jsarr, i++, element);
|
||||||
}
|
}
|
||||||
JS_DefineProperty(cx, tmp, "collisionPointList", JS::RootedValue(cx, OBJECT_TO_JSVAL(jsarr)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
prop.set(OBJECT_TO_JSVAL(jsarr));
|
||||||
|
JS_DefineProperty(cx, tmp, "collisionPointList", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
return OBJECT_TO_JSVAL(tmp);
|
return OBJECT_TO_JSVAL(tmp);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +273,8 @@ bool jsb_cocos2d_Physics3DObject_setCollisionCallback(JSContext *cx, uint32_t ar
|
||||||
JSB_PRECONDITION2( cobj, cx, false, "jsb_cocos2d_Physics3DObject_setCollisionCallback : Invalid Native Object");
|
JSB_PRECONDITION2( cobj, cx, false, "jsb_cocos2d_Physics3DObject_setCollisionCallback : Invalid Native Object");
|
||||||
|
|
||||||
std::function<void(const Physics3DCollisionInfo &)> arg0;
|
std::function<void(const Physics3DCollisionInfo &)> arg0;
|
||||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, JS::RootedObject(cx, args.get(1).toObjectOrNull()), args.get(0)));
|
JS::RootedObject jstarget(cx, args.get(1).toObjectOrNull());
|
||||||
|
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(0)));
|
||||||
auto lambda = [=](const Physics3DCollisionInfo &ci) -> void {
|
auto lambda = [=](const Physics3DCollisionInfo &ci) -> void {
|
||||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
|
|
||||||
|
@ -473,20 +482,23 @@ void register_all_cocos2dx_physics3d_manual(JSContext *cx, JS::HandleObject glob
|
||||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_PhysicsSprite3D_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_PhysicsSprite3D_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_GetProperty(cx, ccObj, "Physics3DRigidBody", &tmpVal);
|
JS_GetProperty(cx, ccObj, "Physics3DRigidBody", &tmpVal);
|
||||||
tmpObj = tmpVal.toObjectOrNull();
|
tmpObj.set(tmpVal.toObjectOrNull());
|
||||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_physics3d_Physics3DRigidBody_create, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_physics3d_Physics3DRigidBody_create, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_GetProperty(cx, ccObj, "Physics3DShape", &tmpVal);
|
JS_GetProperty(cx, ccObj, "Physics3DShape", &tmpVal);
|
||||||
tmpObj = tmpVal.toObjectOrNull();
|
tmpObj.set(tmpVal.toObjectOrNull());
|
||||||
JS_DefineFunction(cx, tmpObj, "createMesh", js_cocos2dx_physics3d_Physics3dShape_createMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "createMesh", js_cocos2dx_physics3d_Physics3dShape_createMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, tmpObj, "createHeightfield", js_cocos2dx_physics3d_Physics3dShape_createHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "createHeightfield", js_cocos2dx_physics3d_Physics3dShape_createHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DShape_prototype), "initMesh", js_cocos2dx_physics3d_Physics3dShape_initMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocos2d_Physics3DShape_prototype);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DShape_prototype), "initHeightfield", js_cocos2dx_physics3d_Physics3dShape_initHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, tmpObj, "initMesh", js_cocos2dx_physics3d_Physics3dShape_initMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "initHeightfield", js_cocos2dx_physics3d_Physics3dShape_initHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DObject_prototype), "setCollisionCallback", jsb_cocos2d_Physics3DObject_setCollisionCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocos2d_Physics3DObject_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "setCollisionCallback", jsb_cocos2d_Physics3DObject_setCollisionCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
|
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DWorld_prototype), "rayCast", js_cocos2dx_physics3d_Physics3DWorld_rayCast, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
tmpObj.set(jsb_cocos2d_Physics3DWorld_prototype);
|
||||||
|
JS_DefineFunction(cx, tmpObj, "rayCast", js_cocos2dx_physics3d_Physics3DWorld_rayCast, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
#endif //CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||||
|
|
|
@ -48,6 +48,8 @@ JS::Value JavaScriptObjCBridge::convertReturnValue(JSContext *cx, ReturnValue re
|
||||||
return BOOLEAN_TO_JSVAL(retValue.boolValue);
|
return BOOLEAN_TO_JSVAL(retValue.boolValue);
|
||||||
case TypeString:
|
case TypeString:
|
||||||
return c_string_to_jsval(cx, retValue.stringValue->c_str(),retValue.stringValue->size());
|
return c_string_to_jsval(cx, retValue.stringValue->c_str(),retValue.stringValue->size());
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -74,11 +76,13 @@ bool JavaScriptObjCBridge::CallInfo::execute(JSContext *cx,jsval *argv,unsigned
|
||||||
[m_dic setObject:[NSString stringWithCString:valueWapper.get() encoding:NSUTF8StringEncoding] forKey:key];
|
[m_dic setObject:[NSString stringWithCString:valueWapper.get() encoding:NSUTF8StringEncoding] forKey:key];
|
||||||
}else if(arg.isNumber()){
|
}else if(arg.isNumber()){
|
||||||
double a;
|
double a;
|
||||||
ok &= JS::ToNumber(cx, JS::RootedValue(cx,arg), &a);
|
JS::RootedValue jsa(cx,arg);
|
||||||
|
ok &= JS::ToNumber(cx, jsa, &a);
|
||||||
|
|
||||||
[m_dic setObject:[NSNumber numberWithFloat:a] forKey:key];
|
[m_dic setObject:[NSNumber numberWithFloat:a] forKey:key];
|
||||||
}else if(arg.isBoolean()){
|
}else if(arg.isBoolean()){
|
||||||
bool a = JS::ToBoolean(JS::RootedValue(cx,arg));
|
JS::RootedValue jsa(cx,arg);
|
||||||
|
bool a = JS::ToBoolean(jsa);
|
||||||
[m_dic setObject:[NSNumber numberWithBool:a] forKey:key];
|
[m_dic setObject:[NSNumber numberWithBool:a] forKey:key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,7 +237,9 @@ JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge)
|
||||||
js_proxy_t *p;
|
js_proxy_t *p;
|
||||||
jsval out;
|
jsval out;
|
||||||
|
|
||||||
JSObject *obj = JS_NewObject(cx, &JavaScriptObjCBridge::js_class, JS::RootedObject(cx, JavaScriptObjCBridge::js_proto), JS::RootedObject(cx, JavaScriptObjCBridge::js_parent));
|
JS::RootedObject proto(cx, JavaScriptObjCBridge::js_proto);
|
||||||
|
JS::RootedObject parentProto(cx, JavaScriptObjCBridge::js_parent);
|
||||||
|
JSObject *obj = JS_NewObject(cx, &JavaScriptObjCBridge::js_class, proto, parentProto);
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
JS_SetPrivate(obj, jsj);
|
JS_SetPrivate(obj, jsj);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jsfriendapi.h"
|
#include "jsfriendapi.h"
|
||||||
#include "uthash.h"
|
#include "uthash.h"
|
||||||
|
#include "mozilla/Maybe.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
typedef struct js_proxy {
|
typedef struct js_proxy {
|
||||||
|
@ -39,8 +40,8 @@ extern js_proxy_t *_js_native_global_ht;
|
||||||
|
|
||||||
typedef struct js_type_class {
|
typedef struct js_type_class {
|
||||||
JSClass *jsclass;
|
JSClass *jsclass;
|
||||||
JS::Heap<JSObject*> proto;
|
mozilla::Maybe<JS::PersistentRootedObject> proto;
|
||||||
JS::Heap<JSObject*> parentProto;
|
mozilla::Maybe<JS::PersistentRootedObject> parentProto;
|
||||||
} js_type_class_t;
|
} js_type_class_t;
|
||||||
|
|
||||||
extern std::unordered_map<std::string, js_type_class_t*> _js_global_type_map;
|
extern std::unordered_map<std::string, js_type_class_t*> _js_global_type_map;
|
||||||
|
|
|
@ -32,10 +32,12 @@ jsval speventdata_to_jsval(JSContext* cx, spEventData& v)
|
||||||
{
|
{
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name));
|
||||||
|
JS::RootedValue jsstr(cx, c_string_to_jsval(cx, v.stringValue));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "stringValue", JS::RootedValue(cx, c_string_to_jsval(cx, v.stringValue)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "stringValue", jsstr, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
@ -49,10 +51,12 @@ jsval spevent_to_jsval(JSContext* cx, spEvent& v)
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
|
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, speventdata_to_jsval(cx, *v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsdata(cx, speventdata_to_jsval(cx, *v.data));
|
||||||
|
JS::RootedValue jsstr(cx, c_string_to_jsval(cx, v.stringValue));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "data", jsdata, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "stringValue", JS::RootedValue(cx, c_string_to_jsval(cx, v.stringValue)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "stringValue", jsstr, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +76,8 @@ jsval spbonedata_to_jsval(JSContext* cx, const spBoneData* v)
|
||||||
if (strcmp(v->name, "root") && v->parent)
|
if (strcmp(v->name, "root") && v->parent)
|
||||||
parentVal = spbonedata_to_jsval(cx, v->parent);
|
parentVal = spbonedata_to_jsval(cx, v->parent);
|
||||||
|
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v->name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsname(cx, c_string_to_jsval(cx, v->name));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "parent", parentVal,JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "parent", parentVal,JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "length", v->length, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "length", v->length, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "x", v->x, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "x", v->x, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
@ -101,7 +106,8 @@ jsval spbone_to_jsval(JSContext* cx, spBone& v)
|
||||||
if (strcmp(v.data->name, "root") && v.parent)
|
if (strcmp(v.data->name, "root") && v.parent)
|
||||||
parentVal = spbone_to_jsval(cx, *v.parent);
|
parentVal = spbone_to_jsval(cx, *v.parent);
|
||||||
|
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, spbonedata_to_jsval(cx, v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsdata(cx, spbonedata_to_jsval(cx, v.data));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "data", jsdata, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "parent", parentVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "parent", parentVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
@ -152,7 +158,8 @@ jsval spattachment_to_jsval(JSContext* cx, spAttachment& v)
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
|
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "type", v.type, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "type", v.type, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
|
@ -168,14 +175,17 @@ jsval spslotdata_to_jsval(JSContext* cx, spSlotData& v)
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
|
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name));
|
||||||
JS_DefineProperty(cx, tmp, "attachmentName", JS::RootedValue(cx, c_string_to_jsval(cx, v.attachmentName)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS::RootedValue jsattachmentName(cx, c_string_to_jsval(cx, v.attachmentName));
|
||||||
|
JS::RootedValue jsboneData(cx, spbonedata_to_jsval(cx, v.boneData));
|
||||||
|
bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
JS_DefineProperty(cx, tmp, "attachmentName", jsattachmentName, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "blendMode", v.blendMode, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "blendMode", v.blendMode, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "boneData", JS::RootedValue(cx, spbonedata_to_jsval(cx, v.boneData)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "boneData", jsboneData, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
@ -190,14 +200,17 @@ jsval spslot_to_jsval(JSContext* cx, spSlot& v)
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
|
|
||||||
|
JS::RootedValue jsbone(cx, spbone_to_jsval(cx, *v.bone));
|
||||||
|
JS::RootedValue jsattachment(cx, spattachment_to_jsval(cx, *v.attachment));
|
||||||
|
JS::RootedValue jsdata(cx, spslotdata_to_jsval(cx, *v.data));
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
bool ok = JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "bone", JS::RootedValue(cx, spbone_to_jsval(cx, *v.bone)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "bone", jsbone, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
//JS_DefineProperty(cx, tmp, "skeleton", spskeleton_to_jsval(cx, *v.skeleton), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
//JS_DefineProperty(cx, tmp, "skeleton", spskeleton_to_jsval(cx, *v.skeleton), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "attachment", JS::RootedValue(cx, spattachment_to_jsval(cx, *v.attachment)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "attachment", jsattachment, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, spslotdata_to_jsval(cx, *v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "data", jsdata, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
@ -243,10 +256,12 @@ jsval spanimation_to_jsval(JSContext* cx, spAnimation& v)
|
||||||
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||||
if (!tmp) return JSVAL_NULL;
|
if (!tmp) return JSVAL_NULL;
|
||||||
|
|
||||||
|
JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name));
|
||||||
|
JS::RootedValue jstimelines(cx, sptimeline_to_jsval(cx, **v.timelines));
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "duration", v.duration, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
bool ok = JS_DefineProperty(cx, tmp, "duration", v.duration, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "timelineCount", v.timelinesCount, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "timelineCount", v.timelinesCount, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "timelines", JS::RootedValue(cx, sptimeline_to_jsval(cx, **v.timelines)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "timelines", jstimelines, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
@ -269,6 +284,7 @@ jsval sptrackentry_to_jsval(JSContext* cx, spTrackEntry& v)
|
||||||
if (v.previous)
|
if (v.previous)
|
||||||
previousVal = sptrackentry_to_jsval(cx, *v.previous);
|
previousVal = sptrackentry_to_jsval(cx, *v.previous);
|
||||||
|
|
||||||
|
JS::RootedValue jsanimation(cx, spanimation_to_jsval(cx, *v.animation));
|
||||||
bool ok = JS_DefineProperty(cx, tmp, "delay", v.delay, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
bool ok = JS_DefineProperty(cx, tmp, "delay", v.delay, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "time", v.time, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "time", v.time, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "lastTime", v.lastTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "lastTime", v.lastTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
@ -276,7 +292,7 @@ jsval sptrackentry_to_jsval(JSContext* cx, spTrackEntry& v)
|
||||||
JS_DefineProperty(cx, tmp, "timeScale", v.timeScale, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "timeScale", v.timeScale, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "mixTime", v.mixTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "mixTime", v.mixTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "mixDuration", v.mixDuration, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "mixDuration", v.mixDuration, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "animation", JS::RootedValue(cx, spanimation_to_jsval(cx, *v.animation)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "animation", jsanimation, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "next", nextVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
JS_DefineProperty(cx, tmp, "next", nextVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
JS_DefineProperty(cx, tmp, "previous", previousVal, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineProperty(cx, tmp, "previous", previousVal, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
|
@ -472,7 +488,7 @@ bool jsb_cocos2dx_spine_setAnimation(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
const char* arg1;
|
const char* arg1;
|
||||||
std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str();
|
std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str();
|
||||||
|
|
||||||
bool arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2)));
|
bool arg2 = JS::ToBoolean(args.get(2));
|
||||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||||
|
|
||||||
spTrackEntry* ret = cobj->setAnimation(arg0, arg1, arg2);
|
spTrackEntry* ret = cobj->setAnimation(arg0, arg1, arg2);
|
||||||
|
|
|
@ -61,10 +61,14 @@ static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc,
|
||||||
else if (argc == 4) {
|
else if (argc == 4) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
double left, top,right,bottom;
|
double left, top,right,bottom;
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[0]), &left);
|
JS::RootedValue jsv(cx, args[0]);
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[1]), &top);
|
ok &= JS::ToNumber( cx, jsv, &left);
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[2]), &right);
|
jsv.set(args[1]);
|
||||||
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[3]), &bottom);
|
ok &= JS::ToNumber( cx, jsv, &top);
|
||||||
|
jsv.set(args[2]);
|
||||||
|
ok &= JS::ToNumber( cx, jsv, &right);
|
||||||
|
jsv.set(args[3]);
|
||||||
|
ok &= JS::ToNumber( cx, jsv, &bottom);
|
||||||
|
|
||||||
JSB_PRECONDITION3(ok, cx, false, "Error processing arguments");
|
JSB_PRECONDITION3(ok, cx, false, "Error processing arguments");
|
||||||
|
|
||||||
|
@ -200,7 +204,10 @@ extern JSObject* jsb_cocos2d_ui_EditBox_prototype;
|
||||||
|
|
||||||
void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global)
|
void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global)
|
||||||
{
|
{
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS::RootedObject proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, proto, "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_EditBox_prototype), "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
JS_DefineFunction(cx, proto, "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
||||||
|
proto.set(jsb_cocos2d_ui_EditBox_prototype);
|
||||||
|
JS_DefineFunction(cx, proto, "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -557,32 +557,20 @@ void js_register_cocos2dx_DrawNode3D(JSContext *cx, JS::HandleObject global) {
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
jsb_cocos2d_DrawNode3D_prototype = JS_InitClass(
|
JS::RootedObject parentProto(cx, jsb_cocos2d_Node_prototype);
|
||||||
|
JS::RootedObject proto(cx, JS_InitClass(
|
||||||
cx, global,
|
cx, global,
|
||||||
JS::RootedObject(cx, jsb_cocos2d_Node_prototype),
|
parentProto,
|
||||||
jsb_cocos2d_DrawNode3D_class,
|
jsb_cocos2d_DrawNode3D_class,
|
||||||
js_cocos2dx_DrawNode3D_constructor, 0, // constructor
|
js_cocos2dx_DrawNode3D_constructor, 0, // constructor
|
||||||
properties,
|
properties,
|
||||||
funcs,
|
funcs,
|
||||||
NULL, // no static properties
|
NULL, // no static properties
|
||||||
st_funcs);
|
st_funcs));
|
||||||
// make the class enumerable in the registered namespace
|
|
||||||
// bool found;
|
jsb_cocos2d_DrawNode3D_prototype = proto.get();
|
||||||
//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
|
// add the proto and JSClass to the type->js info hash table
|
||||||
TypeTest<cocos2d::DrawNode3D> t;
|
jsb_register_class<cocos2d::DrawNode3D>(cx, jsb_cocos2d_DrawNode3D_class, proto, parentProto);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_DrawNode3D_bindings(JSContext *cx, JS::HandleObject global)
|
void register_DrawNode3D_bindings(JSContext *cx, JS::HandleObject global)
|
||||||
|
|
|
@ -525,32 +525,20 @@ void js_register_cocos2dx_Effect3DOutline(JSContext *cx, JS::HandleObject global
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JS::RootedObject parentProto(cx, jsb_Effect3D_prototype);
|
||||||
jsb_Effect3DOutline_prototype = JS_InitClass(
|
jsb_Effect3DOutline_prototype = JS_InitClass(
|
||||||
cx, global,
|
cx, global,
|
||||||
JS::RootedObject(cx, jsb_Effect3D_prototype),
|
parentProto,
|
||||||
jsb_Effect3DOutline_class,
|
jsb_Effect3DOutline_class,
|
||||||
jsb_Effect3DOutline_constructor, 0,
|
jsb_Effect3DOutline_constructor, 0,
|
||||||
properties,
|
properties,
|
||||||
funcs,
|
funcs,
|
||||||
NULL, // no static properties
|
NULL, // no static properties
|
||||||
st_funcs);
|
st_funcs);
|
||||||
// make the class enumerable in the registered namespace
|
|
||||||
// bool found;
|
|
||||||
//FIXME: Removed in Firefox v27
|
|
||||||
// JS_SetPropertyAttributes(cx, global, "Effect3DOutline", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
|
|
||||||
// add the proto and JSClass to the type->js info hash table
|
// add the proto and JSClass to the type->js info hash table
|
||||||
TypeTest<Effect3DOutline> t;
|
JS::RootedObject proto(cx, jsb_Effect3DOutline_prototype);
|
||||||
js_type_class_t *p;
|
jsb_register_class<Effect3DOutline>(cx, jsb_Effect3DOutline_class, proto, parentProto);
|
||||||
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_Effect3DOutline_class;
|
|
||||||
p->proto = jsb_Effect3DOutline_prototype;
|
|
||||||
p->parentProto = jsb_Effect3D_prototype;
|
|
||||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -740,32 +728,20 @@ void js_register_cocos2dx_EffectSprite3D(JSContext *cx, JS::HandleObject global)
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JS::RootedObject parentProto(cx, jsb_cocos2d_Sprite3D_prototype);
|
||||||
jsb_EffectSprite3D_prototype = JS_InitClass(
|
jsb_EffectSprite3D_prototype = JS_InitClass(
|
||||||
cx, global,
|
cx, global,
|
||||||
JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype),
|
parentProto,
|
||||||
jsb_EffectSprite3D_class,
|
jsb_EffectSprite3D_class,
|
||||||
jsb_EffectSprite3D_constructor, 1,
|
jsb_EffectSprite3D_constructor, 1,
|
||||||
properties,
|
properties,
|
||||||
funcs,
|
funcs,
|
||||||
NULL, // no static properties
|
NULL, // no static properties
|
||||||
st_funcs);
|
st_funcs);
|
||||||
// make the class enumerable in the registered namespace
|
|
||||||
// bool found;
|
|
||||||
//FIXME: Removed in Firefox v27
|
|
||||||
// JS_SetPropertyAttributes(cx, global, "EffectSprite3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
|
||||||
|
|
||||||
// add the proto and JSClass to the type->js info hash table
|
// add the proto and JSClass to the type->js info hash table
|
||||||
TypeTest<EffectSprite3D> t;
|
JS::RootedObject proto(cx, jsb_EffectSprite3D_prototype);
|
||||||
js_type_class_t *p;
|
jsb_register_class<EffectSprite3D>(cx, jsb_EffectSprite3D_class, proto, parentProto);
|
||||||
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_EffectSprite3D_class;
|
|
||||||
p->proto = jsb_EffectSprite3D_prototype;
|
|
||||||
p->parentProto = jsb_cocos2d_Sprite3D_prototype;
|
|
||||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_Effect3D_bindings(JSContext *cx, JS::HandleObject global)
|
void register_Effect3D_bindings(JSContext *cx, JS::HandleObject global)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4ecd2f4536bd57d42b4b370a6a4fc7c7420f5404
|
Subproject commit 3dd232b790e85b2cc4a0a0a0e2fb1fc103f57249
|
Loading…
Reference in New Issue