mirror of https://github.com/axmolengine/axmol.git
[ci skip][AUTO]: updating luabinding & jsbinding automatically
This commit is contained in:
parent
f281ae31b0
commit
cfe0be269b
|
@ -592,6 +592,102 @@ str
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Component
|
||||
*/
|
||||
cc.Component = {
|
||||
|
||||
/**
|
||||
* @method setEnabled
|
||||
* @param {bool} arg0
|
||||
*/
|
||||
setEnabled : function (
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setName
|
||||
* @param {String} arg0
|
||||
*/
|
||||
setName : function (
|
||||
str
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method isEnabled
|
||||
* @return {bool}
|
||||
*/
|
||||
isEnabled : function (
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getOwner
|
||||
* @return {cc.Node}
|
||||
*/
|
||||
getOwner : function (
|
||||
)
|
||||
{
|
||||
return cc.Node;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method init
|
||||
* @return {bool}
|
||||
*/
|
||||
init : function (
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getName
|
||||
* @return {String}
|
||||
*/
|
||||
getName : function (
|
||||
)
|
||||
{
|
||||
return ;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setOwner
|
||||
* @param {cc.Node} arg0
|
||||
*/
|
||||
setOwner : function (
|
||||
node
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @return {cc.Component}
|
||||
*/
|
||||
create : function (
|
||||
)
|
||||
{
|
||||
return cc.Component;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Component
|
||||
* @constructor
|
||||
*/
|
||||
Component : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Node
|
||||
*/
|
||||
|
@ -20695,102 +20791,6 @@ TextureCache : function (
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Component
|
||||
*/
|
||||
cc.Component = {
|
||||
|
||||
/**
|
||||
* @method setEnabled
|
||||
* @param {bool} arg0
|
||||
*/
|
||||
setEnabled : function (
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setName
|
||||
* @param {String} arg0
|
||||
*/
|
||||
setName : function (
|
||||
str
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method isEnabled
|
||||
* @return {bool}
|
||||
*/
|
||||
isEnabled : function (
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getOwner
|
||||
* @return {cc.Node}
|
||||
*/
|
||||
getOwner : function (
|
||||
)
|
||||
{
|
||||
return cc.Node;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method init
|
||||
* @return {bool}
|
||||
*/
|
||||
init : function (
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getName
|
||||
* @return {String}
|
||||
*/
|
||||
getName : function (
|
||||
)
|
||||
{
|
||||
return ;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setOwner
|
||||
* @param {cc.Node} arg0
|
||||
*/
|
||||
setOwner : function (
|
||||
node
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @return {cc.Component}
|
||||
*/
|
||||
create : function (
|
||||
)
|
||||
{
|
||||
return cc.Component;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Component
|
||||
* @constructor
|
||||
*/
|
||||
Component : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Device
|
||||
*/
|
||||
|
|
|
@ -1645,6 +1645,289 @@ void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject glo
|
|||
}
|
||||
}
|
||||
|
||||
JSClass *jsb_cocos2d_Component_class;
|
||||
JSObject *jsb_cocos2d_Component_prototype;
|
||||
|
||||
bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setEnabled : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
bool arg0;
|
||||
arg0 = JS::ToBoolean(args.get(0));
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setEnabled : Error processing arguments");
|
||||
cobj->setEnabled(arg0);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setName : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
std::string arg0;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setName : Error processing arguments");
|
||||
cobj->setName(arg0);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_setName : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_isEnabled : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
bool ret = cobj->isEnabled();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getOwner : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
cocos2d::Node* ret = cobj->getOwner();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::Node>(cx, (cocos2d::Node*)ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_getOwner : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_init : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
bool ret = cobj->init();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_init : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getName : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
const std::string& ret = cobj->getName();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = std_string_to_jsval(cx, ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setOwner : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
cocos2d::Node* arg0;
|
||||
do {
|
||||
if (args.get(0).isNull()) { arg0 = nullptr; break; }
|
||||
if (!args.get(0).isObject()) { ok = false; break; }
|
||||
js_proxy_t *jsProxy;
|
||||
JSObject *tmpObj = args.get(0).toObjectOrNull();
|
||||
jsProxy = jsb_get_js_proxy(tmpObj);
|
||||
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
|
||||
} while (0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setOwner : Error processing arguments");
|
||||
cobj->setOwner(arg0);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_setOwner : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
if (argc == 0) {
|
||||
cocos2d::Component* ret = cocos2d::Component::create();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::Component>(cx, (cocos2d::Component*)ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_create : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
cocos2d::Component* cobj = new (std::nothrow) cocos2d::Component();
|
||||
cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj);
|
||||
if (_ccobj) {
|
||||
_ccobj->autorelease();
|
||||
}
|
||||
TypeTest<cocos2d::Component> t;
|
||||
js_type_class_t *typeClass = nullptr;
|
||||
std::string typeName = t.s_name();
|
||||
auto typeMapIter = _js_global_type_map.find(typeName);
|
||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||
typeClass = typeMapIter->second;
|
||||
CCASSERT(typeClass, "The value is null.");
|
||||
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
|
||||
JS::RootedObject proto(cx, typeClass->proto.get());
|
||||
JS::RootedObject parent(cx, typeClass->parentProto.get());
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
||||
args.rval().set(OBJECT_TO_JSVAL(obj));
|
||||
// link the native object with the javascript object
|
||||
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
||||
AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component");
|
||||
if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok)
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
|
||||
return true;
|
||||
}static bool js_cocos2dx_Component_ctor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
cocos2d::Component *nobj = new (std::nothrow) cocos2d::Component();
|
||||
if (nobj) {
|
||||
nobj->autorelease();
|
||||
}
|
||||
js_proxy_t* p = jsb_new_proxy(nobj, obj);
|
||||
AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component");
|
||||
bool isFound = false;
|
||||
if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound)
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
void js_cocos2d_Component_finalize(JSFreeOp *fop, JSObject *obj) {
|
||||
CCLOGINFO("jsbindings: finalizing JS object %p (Component)", obj);
|
||||
}
|
||||
|
||||
void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) {
|
||||
jsb_cocos2d_Component_class = (JSClass *)calloc(1, sizeof(JSClass));
|
||||
jsb_cocos2d_Component_class->name = "Component";
|
||||
jsb_cocos2d_Component_class->addProperty = JS_PropertyStub;
|
||||
jsb_cocos2d_Component_class->delProperty = JS_DeletePropertyStub;
|
||||
jsb_cocos2d_Component_class->getProperty = JS_PropertyStub;
|
||||
jsb_cocos2d_Component_class->setProperty = JS_StrictPropertyStub;
|
||||
jsb_cocos2d_Component_class->enumerate = JS_EnumerateStub;
|
||||
jsb_cocos2d_Component_class->resolve = JS_ResolveStub;
|
||||
jsb_cocos2d_Component_class->convert = JS_ConvertStub;
|
||||
jsb_cocos2d_Component_class->finalize = js_cocos2d_Component_finalize;
|
||||
jsb_cocos2d_Component_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
|
||||
|
||||
static JSPropertySpec properties[] = {
|
||||
JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_PS_END
|
||||
};
|
||||
|
||||
static JSFunctionSpec funcs[] = {
|
||||
JS_FN("setEnabled", js_cocos2dx_Component_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("setName", js_cocos2dx_Component_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("isEnabled", js_cocos2dx_Component_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("getOwner", js_cocos2dx_Component_getOwner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("init", js_cocos2dx_Component_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("getName", js_cocos2dx_Component_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("ctor", js_cocos2dx_Component_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
static JSFunctionSpec st_funcs[] = {
|
||||
JS_FN("create", js_cocos2dx_Component_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
jsb_cocos2d_Component_prototype = JS_InitClass(
|
||||
cx, global,
|
||||
JS::NullPtr(), // parent proto
|
||||
jsb_cocos2d_Component_class,
|
||||
js_cocos2dx_Component_constructor, 0, // constructor
|
||||
properties,
|
||||
funcs,
|
||||
NULL, // no static properties
|
||||
st_funcs);
|
||||
// make the class enumerable in the registered namespace
|
||||
// bool found;
|
||||
//FIXME: Removed in Firefox v27
|
||||
// JS_SetPropertyAttributes(cx, global, "Component", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
||||
|
||||
// add the proto and JSClass to the type->js info hash table
|
||||
TypeTest<cocos2d::Component> t;
|
||||
js_type_class_t *p;
|
||||
std::string typeName = t.s_name();
|
||||
if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
|
||||
{
|
||||
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
|
||||
p->jsclass = jsb_cocos2d_Component_class;
|
||||
p->proto = jsb_cocos2d_Component_prototype;
|
||||
p->parentProto = NULL;
|
||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
||||
}
|
||||
anonEvaluate(cx, global, "(function () { cc.Component.extend = cc.Class.extend; })()");
|
||||
}
|
||||
|
||||
JSClass *jsb_cocos2d_Node_class;
|
||||
JSObject *jsb_cocos2d_Node_prototype;
|
||||
|
||||
|
@ -65064,289 +65347,6 @@ void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global) {
|
|||
}
|
||||
}
|
||||
|
||||
JSClass *jsb_cocos2d_Component_class;
|
||||
JSObject *jsb_cocos2d_Component_prototype;
|
||||
|
||||
bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setEnabled : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
bool arg0;
|
||||
arg0 = JS::ToBoolean(args.get(0));
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setEnabled : Error processing arguments");
|
||||
cobj->setEnabled(arg0);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setName : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
std::string arg0;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setName : Error processing arguments");
|
||||
cobj->setName(arg0);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_setName : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_isEnabled : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
bool ret = cobj->isEnabled();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getOwner : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
cocos2d::Node* ret = cobj->getOwner();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::Node>(cx, (cocos2d::Node*)ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_getOwner : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_init : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
bool ret = cobj->init();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_init : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getName : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
const std::string& ret = cobj->getName();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = std_string_to_jsval(cx, ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setOwner : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
cocos2d::Node* arg0;
|
||||
do {
|
||||
if (args.get(0).isNull()) { arg0 = nullptr; break; }
|
||||
if (!args.get(0).isObject()) { ok = false; break; }
|
||||
js_proxy_t *jsProxy;
|
||||
JSObject *tmpObj = args.get(0).toObjectOrNull();
|
||||
jsProxy = jsb_get_js_proxy(tmpObj);
|
||||
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
|
||||
} while (0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setOwner : Error processing arguments");
|
||||
cobj->setOwner(arg0);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_setOwner : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
if (argc == 0) {
|
||||
cocos2d::Component* ret = cocos2d::Component::create();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::Component>(cx, (cocos2d::Component*)ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_create : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
cocos2d::Component* cobj = new (std::nothrow) cocos2d::Component();
|
||||
cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj);
|
||||
if (_ccobj) {
|
||||
_ccobj->autorelease();
|
||||
}
|
||||
TypeTest<cocos2d::Component> t;
|
||||
js_type_class_t *typeClass = nullptr;
|
||||
std::string typeName = t.s_name();
|
||||
auto typeMapIter = _js_global_type_map.find(typeName);
|
||||
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
|
||||
typeClass = typeMapIter->second;
|
||||
CCASSERT(typeClass, "The value is null.");
|
||||
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
|
||||
JS::RootedObject proto(cx, typeClass->proto.get());
|
||||
JS::RootedObject parent(cx, typeClass->parentProto.get());
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
||||
args.rval().set(OBJECT_TO_JSVAL(obj));
|
||||
// link the native object with the javascript object
|
||||
js_proxy_t* p = jsb_new_proxy(cobj, obj);
|
||||
AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component");
|
||||
if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok)
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
|
||||
return true;
|
||||
}static bool js_cocos2dx_Component_ctor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
cocos2d::Component *nobj = new (std::nothrow) cocos2d::Component();
|
||||
if (nobj) {
|
||||
nobj->autorelease();
|
||||
}
|
||||
js_proxy_t* p = jsb_new_proxy(nobj, obj);
|
||||
AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component");
|
||||
bool isFound = false;
|
||||
if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound)
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
void js_cocos2d_Component_finalize(JSFreeOp *fop, JSObject *obj) {
|
||||
CCLOGINFO("jsbindings: finalizing JS object %p (Component)", obj);
|
||||
}
|
||||
|
||||
void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) {
|
||||
jsb_cocos2d_Component_class = (JSClass *)calloc(1, sizeof(JSClass));
|
||||
jsb_cocos2d_Component_class->name = "Component";
|
||||
jsb_cocos2d_Component_class->addProperty = JS_PropertyStub;
|
||||
jsb_cocos2d_Component_class->delProperty = JS_DeletePropertyStub;
|
||||
jsb_cocos2d_Component_class->getProperty = JS_PropertyStub;
|
||||
jsb_cocos2d_Component_class->setProperty = JS_StrictPropertyStub;
|
||||
jsb_cocos2d_Component_class->enumerate = JS_EnumerateStub;
|
||||
jsb_cocos2d_Component_class->resolve = JS_ResolveStub;
|
||||
jsb_cocos2d_Component_class->convert = JS_ConvertStub;
|
||||
jsb_cocos2d_Component_class->finalize = js_cocos2d_Component_finalize;
|
||||
jsb_cocos2d_Component_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
|
||||
|
||||
static JSPropertySpec properties[] = {
|
||||
JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_PS_END
|
||||
};
|
||||
|
||||
static JSFunctionSpec funcs[] = {
|
||||
JS_FN("setEnabled", js_cocos2dx_Component_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("setName", js_cocos2dx_Component_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("isEnabled", js_cocos2dx_Component_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("getOwner", js_cocos2dx_Component_getOwner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("init", js_cocos2dx_Component_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("getName", js_cocos2dx_Component_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("ctor", js_cocos2dx_Component_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
static JSFunctionSpec st_funcs[] = {
|
||||
JS_FN("create", js_cocos2dx_Component_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
jsb_cocos2d_Component_prototype = JS_InitClass(
|
||||
cx, global,
|
||||
JS::NullPtr(), // parent proto
|
||||
jsb_cocos2d_Component_class,
|
||||
js_cocos2dx_Component_constructor, 0, // constructor
|
||||
properties,
|
||||
funcs,
|
||||
NULL, // no static properties
|
||||
st_funcs);
|
||||
// make the class enumerable in the registered namespace
|
||||
// bool found;
|
||||
//FIXME: Removed in Firefox v27
|
||||
// JS_SetPropertyAttributes(cx, global, "Component", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
||||
|
||||
// add the proto and JSClass to the type->js info hash table
|
||||
TypeTest<cocos2d::Component> t;
|
||||
js_type_class_t *p;
|
||||
std::string typeName = t.s_name();
|
||||
if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
|
||||
{
|
||||
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
|
||||
p->jsclass = jsb_cocos2d_Component_class;
|
||||
p->proto = jsb_cocos2d_Component_prototype;
|
||||
p->parentProto = NULL;
|
||||
_js_global_type_map.insert(std::make_pair(typeName, p));
|
||||
}
|
||||
anonEvaluate(cx, global, "(function () { cc.Component.extend = cc.Class.extend; })()");
|
||||
}
|
||||
|
||||
JSClass *jsb_cocos2d_Device_class;
|
||||
JSObject *jsb_cocos2d_Device_prototype;
|
||||
|
||||
|
|
|
@ -98,6 +98,23 @@ bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
bool js_cocos2dx_ComponentContainer_isEmpty(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ComponentContainer_get(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_Component_class;
|
||||
extern JSObject *jsb_cocos2d_Component_prototype;
|
||||
|
||||
bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_Component_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_Component(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_Node_class;
|
||||
extern JSObject *jsb_cocos2d_Node_prototype;
|
||||
|
||||
|
@ -3702,23 +3719,6 @@ bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval
|
|||
bool js_cocos2dx_TextureCache_waitForQuit(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TextureCache_TextureCache(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_Component_class;
|
||||
extern JSObject *jsb_cocos2d_Component_prototype;
|
||||
|
||||
bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_Component_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_Component(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_Device_class;
|
||||
extern JSObject *jsb_cocos2d_Device_prototype;
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
-- @field [parent=#cc] EventKeyboard#EventKeyboard EventKeyboard preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc Component
|
||||
-- @field [parent=#cc] Component#Component Component preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc Node
|
||||
-- @field [parent=#cc] Node#Node Node preloaded module
|
||||
|
@ -1236,11 +1241,6 @@
|
|||
-- @field [parent=#cc] TextureCache#TextureCache TextureCache preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc Component
|
||||
-- @field [parent=#cc] Component#Component Component preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc Device
|
||||
-- @field [parent=#cc] Device#Device Device preloaded module
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue