mirror of https://github.com/axmolengine/axmol.git
Add bindings for AutoPolygon and PolygonInfo
This commit is contained in:
parent
19ef0e0983
commit
032f231ed4
|
@ -5520,6 +5520,429 @@ bool js_cocos2dx_Scene_getPhysics3DWorld(JSContext *cx, uint32_t argc, jsval *vp
|
||||||
}
|
}
|
||||||
#endif //CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS
|
#endif //CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS
|
||||||
|
|
||||||
|
JSClass *jsb_cocos2d_PolygonInfo_class;
|
||||||
|
JSObject *jsb_cocos2d_PolygonInfo_prototype;
|
||||||
|
|
||||||
|
bool js_cocos2dx_PolygonInfo_getArea(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::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL);
|
||||||
|
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getArea : Invalid Native Object");
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
const float ret = cobj->getArea();
|
||||||
|
jsval jsret = JSVAL_NULL;
|
||||||
|
jsret = DOUBLE_TO_JSVAL(ret);
|
||||||
|
args.rval().set(jsret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getArea : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool js_cocos2dx_PolygonInfo_getTriaglesCount(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::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL);
|
||||||
|
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getTriaglesCount : Invalid Native Object");
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
const unsigned int ret = cobj->getTriaglesCount();
|
||||||
|
jsval jsret = JSVAL_NULL;
|
||||||
|
jsret = uint32_to_jsval(cx, ret);
|
||||||
|
args.rval().set(jsret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getTriaglesCount : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool js_cocos2dx_PolygonInfo_getVertCount(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::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL);
|
||||||
|
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getVertCount : Invalid Native Object");
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
const unsigned int ret = cobj->getVertCount();
|
||||||
|
jsval jsret = JSVAL_NULL;
|
||||||
|
jsret = uint32_to_jsval(cx, ret);
|
||||||
|
args.rval().set(jsret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getVertCount : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PolygonInfo.rect
|
||||||
|
bool js_get_PolygonInfo_rect(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::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL);
|
||||||
|
if (cobj)
|
||||||
|
{
|
||||||
|
jsval ret = ccrect_to_jsval(cx, cobj->rect);
|
||||||
|
|
||||||
|
if (ret != JSVAL_NULL)
|
||||||
|
{
|
||||||
|
args.rval().set(ret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CCLOGERROR("js_get_PolygonInfo_rect : Fail to retrieve property from PolygonInfo.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JS_ReportError(cx, "js_get_PolygonInfo_rect : Invalid native object.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool js_set_PolygonInfo_rect(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::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL);
|
||||||
|
if (cobj)
|
||||||
|
{
|
||||||
|
JS::RootedValue jsrect(cx, args.get(0));
|
||||||
|
jsval_to_ccrect(cx, jsrect, &cobj->rect);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
JS_ReportError(cx, "js_set_PolygonInfo_rect : Invalid native object.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PolygonInfo.filename
|
||||||
|
bool js_get_PolygonInfo_filename(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::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL);
|
||||||
|
if (cobj)
|
||||||
|
{
|
||||||
|
jsval ret = std_string_to_jsval(cx, cobj->filename);
|
||||||
|
|
||||||
|
if (ret != JSVAL_NULL)
|
||||||
|
{
|
||||||
|
args.rval().set(ret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CCLOGERROR("js_get_PolygonInfo_filename : Fail to retrieve property from PolygonInfo.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JS_ReportError(cx, "js_get_PolygonInfo_filename : Invalid native object.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool js_set_PolygonInfo_filename(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::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL);
|
||||||
|
if (cobj)
|
||||||
|
{
|
||||||
|
JS::RootedValue jsstr(cx, args.get(0));
|
||||||
|
jsval_to_std_string(cx, jsstr, &cobj->filename);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
JS_ReportError(cx, "js_set_PolygonInfo_filename : Invalid native object.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool js_cocos2dx_PolygonInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
{
|
||||||
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
|
bool ok = true;
|
||||||
|
cocos2d::PolygonInfo* cobj = new (std::nothrow) cocos2d::PolygonInfo();
|
||||||
|
TypeTest<cocos2d::PolygonInfo> 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
|
||||||
|
jsb_new_proxy(cobj, obj);
|
||||||
|
if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok)
|
||||||
|
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void js_cocos2d_PolygonInfo_finalize(JSFreeOp *fop, JSObject *obj) {
|
||||||
|
CCLOGINFO("jsbindings: finalizing JS object %p (PolygonInfo)", obj);
|
||||||
|
js_proxy_t* nproxy;
|
||||||
|
js_proxy_t* jsproxy;
|
||||||
|
jsproxy = jsb_get_js_proxy(obj);
|
||||||
|
if (jsproxy)
|
||||||
|
{
|
||||||
|
nproxy = jsb_get_native_proxy(jsproxy->ptr);
|
||||||
|
|
||||||
|
cocos2d::PolygonInfo *nobj = static_cast<cocos2d::PolygonInfo *>(nproxy->ptr);
|
||||||
|
if (nobj)
|
||||||
|
delete nobj;
|
||||||
|
|
||||||
|
jsb_remove_proxy(nproxy, jsproxy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void js_register_cocos2dx_PolygonInfo(JSContext *cx, JS::HandleObject global)
|
||||||
|
{
|
||||||
|
jsb_cocos2d_PolygonInfo_class = (JSClass *)calloc(1, sizeof(JSClass));
|
||||||
|
jsb_cocos2d_PolygonInfo_class->name = "PolygonInfo";
|
||||||
|
jsb_cocos2d_PolygonInfo_class->addProperty = JS_PropertyStub;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->delProperty = JS_DeletePropertyStub;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->getProperty = JS_PropertyStub;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->setProperty = JS_StrictPropertyStub;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->enumerate = JS_EnumerateStub;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->resolve = JS_ResolveStub;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->convert = JS_ConvertStub;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->finalize = js_cocos2d_PolygonInfo_finalize;
|
||||||
|
jsb_cocos2d_PolygonInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
|
||||||
|
|
||||||
|
static JSPropertySpec properties[] =
|
||||||
|
{
|
||||||
|
JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_PSGS("rect", js_get_PolygonInfo_rect, js_set_PolygonInfo_rect, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_PSGS("filename", js_get_PolygonInfo_filename, js_set_PolygonInfo_filename, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_PS_END
|
||||||
|
};
|
||||||
|
|
||||||
|
static JSFunctionSpec funcs[] =
|
||||||
|
{
|
||||||
|
JS_FN("getArea", js_cocos2dx_PolygonInfo_getArea, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_FN("getTriaglesCount", js_cocos2dx_PolygonInfo_getTriaglesCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_FN("getVertCount", js_cocos2dx_PolygonInfo_getVertCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_FS_END
|
||||||
|
};
|
||||||
|
|
||||||
|
JSFunctionSpec *st_funcs = NULL;
|
||||||
|
|
||||||
|
jsb_cocos2d_PolygonInfo_prototype = JS_InitClass(
|
||||||
|
cx, global,
|
||||||
|
JS::NullPtr(), // parent proto
|
||||||
|
jsb_cocos2d_PolygonInfo_class,
|
||||||
|
js_cocos2dx_PolygonInfo_constructor, 0, // constructor
|
||||||
|
properties,
|
||||||
|
funcs,
|
||||||
|
NULL, // no static properties
|
||||||
|
st_funcs);
|
||||||
|
|
||||||
|
// add the proto and JSClass to the type->js info hash table
|
||||||
|
TypeTest<cocos2d::PolygonInfo> 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_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;
|
||||||
|
JSObject *jsb_cocos2d_AutoPolygon_prototype;
|
||||||
|
|
||||||
|
bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
{
|
||||||
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
|
bool ok = true;
|
||||||
|
if (argc == 1) {
|
||||||
|
std::string arg0;
|
||||||
|
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||||
|
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||||
|
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0));
|
||||||
|
jsval jsret = JSVAL_NULL;
|
||||||
|
do {
|
||||||
|
if (ret) {
|
||||||
|
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||||
|
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||||
|
} else {
|
||||||
|
jsret = JSVAL_NULL;
|
||||||
|
}
|
||||||
|
} while (0);
|
||||||
|
args.rval().set(jsret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (argc == 2) {
|
||||||
|
std::string arg0;
|
||||||
|
cocos2d::Rect arg1;
|
||||||
|
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||||
|
ok &= jsval_to_ccrect(cx, args.get(1), &arg1);
|
||||||
|
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||||
|
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1));
|
||||||
|
jsval jsret = JSVAL_NULL;
|
||||||
|
do {
|
||||||
|
if (ret) {
|
||||||
|
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||||
|
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||||
|
} else {
|
||||||
|
jsret = JSVAL_NULL;
|
||||||
|
}
|
||||||
|
} while (0);
|
||||||
|
args.rval().set(jsret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (argc == 3) {
|
||||||
|
std::string arg0;
|
||||||
|
cocos2d::Rect arg1;
|
||||||
|
double arg2;
|
||||||
|
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||||
|
ok &= jsval_to_ccrect(cx, args.get(1), &arg1);
|
||||||
|
ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2);
|
||||||
|
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||||
|
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2));
|
||||||
|
jsval jsret = JSVAL_NULL;
|
||||||
|
do {
|
||||||
|
if (ret) {
|
||||||
|
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||||
|
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||||
|
} else {
|
||||||
|
jsret = JSVAL_NULL;
|
||||||
|
}
|
||||||
|
} while (0);
|
||||||
|
args.rval().set(jsret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (argc == 4) {
|
||||||
|
std::string arg0;
|
||||||
|
cocos2d::Rect arg1;
|
||||||
|
double arg2;
|
||||||
|
double arg3;
|
||||||
|
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||||
|
ok &= jsval_to_ccrect(cx, args.get(1), &arg1);
|
||||||
|
ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2);
|
||||||
|
ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3);
|
||||||
|
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||||
|
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3));
|
||||||
|
jsval jsret = JSVAL_NULL;
|
||||||
|
do {
|
||||||
|
if (ret) {
|
||||||
|
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||||
|
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||||
|
} else {
|
||||||
|
jsret = JSVAL_NULL;
|
||||||
|
}
|
||||||
|
} while (0);
|
||||||
|
args.rval().set(jsret);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
JS_ReportError(cx, "js_cocos2dx_AutoPolygon_generatePolygon : wrong number of arguments");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool js_cocos2dx_AutoPolygon_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
{
|
||||||
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
|
bool ok = true;
|
||||||
|
std::string arg0;
|
||||||
|
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||||
|
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_constructor : Error processing arguments");
|
||||||
|
cocos2d::AutoPolygon* cobj = new (std::nothrow) cocos2d::AutoPolygon(arg0);
|
||||||
|
TypeTest<cocos2d::AutoPolygon> 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
|
||||||
|
jsb_new_proxy(cobj, obj);
|
||||||
|
if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok)
|
||||||
|
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void js_cocos2d_AutoPolygon_finalize(JSFreeOp *fop, JSObject *obj) {
|
||||||
|
CCLOGINFO("jsbindings: finalizing JS object %p (AutoPolygon)", obj);
|
||||||
|
js_proxy_t* nproxy;
|
||||||
|
js_proxy_t* jsproxy;
|
||||||
|
jsproxy = jsb_get_js_proxy(obj);
|
||||||
|
if (jsproxy) {
|
||||||
|
nproxy = jsb_get_native_proxy(jsproxy->ptr);
|
||||||
|
|
||||||
|
cocos2d::AutoPolygon *nobj = static_cast<cocos2d::AutoPolygon *>(nproxy->ptr);
|
||||||
|
if (nobj)
|
||||||
|
delete nobj;
|
||||||
|
|
||||||
|
jsb_remove_proxy(nproxy, jsproxy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void js_register_cocos2dx_AutoPolygon(JSContext *cx, JS::HandleObject global) {
|
||||||
|
jsb_cocos2d_AutoPolygon_class = (JSClass *)calloc(1, sizeof(JSClass));
|
||||||
|
jsb_cocos2d_AutoPolygon_class->name = "AutoPolygon";
|
||||||
|
jsb_cocos2d_AutoPolygon_class->addProperty = JS_PropertyStub;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->delProperty = JS_DeletePropertyStub;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->getProperty = JS_PropertyStub;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->setProperty = JS_StrictPropertyStub;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->enumerate = JS_EnumerateStub;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->resolve = JS_ResolveStub;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->convert = JS_ConvertStub;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->finalize = js_cocos2d_AutoPolygon_finalize;
|
||||||
|
jsb_cocos2d_AutoPolygon_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
|
||||||
|
|
||||||
|
static JSPropertySpec properties[] = {
|
||||||
|
JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_PS_END
|
||||||
|
};
|
||||||
|
|
||||||
|
static JSFunctionSpec funcs[] = {
|
||||||
|
JS_FS_END
|
||||||
|
};
|
||||||
|
|
||||||
|
static JSFunctionSpec st_funcs[] = {
|
||||||
|
JS_FN("generatePolygon", js_cocos2dx_AutoPolygon_generatePolygon, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||||
|
JS_FS_END
|
||||||
|
};
|
||||||
|
|
||||||
|
jsb_cocos2d_AutoPolygon_prototype = JS_InitClass(
|
||||||
|
cx, global,
|
||||||
|
JS::NullPtr(), // parent proto
|
||||||
|
jsb_cocos2d_AutoPolygon_class,
|
||||||
|
js_cocos2dx_AutoPolygon_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, "AutoPolygon", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
|
||||||
|
|
||||||
|
// add the proto and JSClass to the type->js info hash table
|
||||||
|
TypeTest<cocos2d::AutoPolygon> 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_AutoPolygon_class;
|
||||||
|
p->proto = jsb_cocos2d_AutoPolygon_prototype;
|
||||||
|
p->parentProto = NULL;
|
||||||
|
_js_global_type_map.insert(std::make_pair(typeName, p));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global)
|
void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global)
|
||||||
{
|
{
|
||||||
JS::RootedObject ccObj(cx);
|
JS::RootedObject ccObj(cx);
|
||||||
|
|
|
@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAu
|
||||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||||
|
|
||||||
classes = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode GLProgramState Image .*Light$ AsyncTaskPool Properties Material Technique RenderState Pass PolygonInfo AutoPolygon
|
classes = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode GLProgramState Image .*Light$ AsyncTaskPool Properties Material Technique RenderState Pass
|
||||||
|
|
||||||
classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* GLProgram
|
classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* GLProgram
|
||||||
|
|
||||||
|
@ -136,8 +136,7 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat
|
||||||
BillBoard::[*],
|
BillBoard::[*],
|
||||||
Camera::[unproject isVisibleInFrustum],
|
Camera::[unproject isVisibleInFrustum],
|
||||||
ClippingNode::[init],
|
ClippingNode::[init],
|
||||||
RenderState::[setStateBlock],
|
RenderState::[setStateBlock]
|
||||||
AutoPolygon::[trace reduce expand triangulate calculateUV generateTriangles generatePolygon]
|
|
||||||
|
|
||||||
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
|
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
|
||||||
MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName],
|
MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName],
|
||||||
|
@ -183,7 +182,7 @@ base_classes_to_skip = Ref Clonable
|
||||||
# classes that create no constructor
|
# classes that create no constructor
|
||||||
# Set is special and we will use a hand-written constructor
|
# Set is special and we will use a hand-written constructor
|
||||||
|
|
||||||
abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application GLViewProtocol GLView ComponentContainer SAXParser Configuration EventListener BaseLight AsyncTaskPool PolygonInfo AutoPolygon
|
abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application GLViewProtocol GLView ComponentContainer SAXParser Configuration EventListener BaseLight AsyncTaskPool
|
||||||
|
|
||||||
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||||
script_control_cpp = no
|
script_control_cpp = no
|
||||||
|
|
Loading…
Reference in New Issue