From 8b14575d7e8083b0f79fd1dd1eb3eb80d735cba1 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 18 Nov 2013 16:54:52 +0800 Subject: [PATCH] bind gui and studio. --- build/cocos2d-win32.vc2012.sln | 13 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../cocostudio/jsb_cocos2dx_studio_manual.cpp | 14 +- .../javascript/bindings/gui/Android.mk | 30 ++ .../bindings/gui/jsb_cocos2dx_gui_manual.cpp | 317 ++++++++++++++++++ .../bindings/gui/jsb_cocos2dx_gui_manual.h | 16 + .../bindings/gui/libJSBindingForGui.vcxproj | 118 +++++++ .../gui/libJSBindingForGui.vcxproj.filters | 34 ++ .../gui/libJSBindingForGui.vcxproj.user | 6 + cocos/scripting/javascript/script/jsb.js | 2 + .../javascript/script/jsb_cocos2d.js | 28 ++ .../javascript/script/jsb_cocos2d_gui.js | 183 ++++++++++ .../javascript/script/jsb_cocos2d_studio.js | 27 ++ .../TestJavascript/Classes/AppDelegate.cpp | 5 + .../proj.android/jni/Android.mk | 2 + .../proj.win32/TestJavascript.vcxproj | 3 + tools/tojs/cocos2dx_gui.ini | 64 ++++ tools/tojs/cocos2dx_studio.ini | 25 +- tools/tojs/genbindings.sh | 3 + 20 files changed, 873 insertions(+), 21 deletions(-) create mode 100644 cocos/scripting/javascript/bindings/gui/Android.mk create mode 100644 cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp create mode 100644 cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.h create mode 100644 cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj create mode 100644 cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.filters create mode 100644 cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.user create mode 100644 cocos/scripting/javascript/script/jsb_cocos2d_gui.js create mode 100644 cocos/scripting/javascript/script/jsb_cocos2d_studio.js create mode 100644 tools/tojs/cocos2dx_gui.ini diff --git a/build/cocos2d-win32.vc2012.sln b/build/cocos2d-win32.vc2012.sln index c1f930fa51..28792555a1 100644 --- a/build/cocos2d-win32.vc2012.sln +++ b/build/cocos2d-win32.vc2012.sln @@ -63,6 +63,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForChipmunk", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage", "..\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj", "{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForGui", "..\cocos\scripting\javascript\bindings\gui\libJSBindingForGui.vcxproj", "{9A844C88-97E8-4E2D-B09A-E138C67D338B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -189,18 +191,23 @@ Global {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.Build.0 = Debug|Win32 {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.ActiveCfg = Release|Win32 {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.Build.0 = Release|Win32 + {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Debug|Win32.ActiveCfg = Debug|Win32 + {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Debug|Win32.Build.0 = Debug|Win32 + {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.ActiveCfg = Release|Win32 + {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {39379840-825A-45A0-B363-C09FFEF864BD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} - {625F7391-9A91-48A1-8CFC-79508C822637} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} - {3BEC13F5-E227-4D80-BC77-1C857F83BCFC} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {79D34511-E54E-410A-8BBA-EF175AD6C695} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {3BEC13F5-E227-4D80-BC77-1C857F83BCFC} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {625F7391-9A91-48A1-8CFC-79508C822637} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {39379840-825A-45A0-B363-C09FFEF864BD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {21070E58-EEC6-4E16-8B4F-6D083DF55790} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {9A844C88-97E8-4E2D-B09A-E138C67D338B} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 6fdbc42758..692b7ad548 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -e1cdac55b4aa56ff532e0d23fe27272510058a42 \ No newline at end of file +1dbcea49018d245ac72bf4138633f3905ef4dc7f \ No newline at end of file diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index c0057afb57..fe0929b0b5 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -9490bdedbc6e817240a1661c6bcbcafc9095c267 \ No newline at end of file +2461d13fd6f4fadc6ee396109932e50b1de8ed99 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp index 4838fbcab2..4eeff5392e 100644 --- a/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp +++ b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -138,7 +138,8 @@ static JSBool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext * jsval *argv = JS_ARGV(cx, vp); JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); - tmpObj->autorelease(); + cobj->setUserObject(tmpObj); + tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); @@ -162,7 +163,8 @@ static JSBool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, jsval *argv = JS_ARGV(cx, vp); JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); - tmpObj->autorelease(); + cobj->setUserObject(tmpObj); + tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); @@ -188,8 +190,8 @@ static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); - tmpObj->setJSCallbackFunc(argv[2]); - tmpObj->setJSCallbackThis(argv[1]); + tmpObj->setJSCallbackFunc(argv[1]); + tmpObj->setJSCallbackThis(argv[2]); std::string ret; jsval_to_std_string(cx, argv[0], &ret); @@ -205,8 +207,8 @@ static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); - tmpObj->setJSCallbackFunc(argv[4]); - tmpObj->setJSCallbackThis(argv[3]); + tmpObj->setJSCallbackFunc(argv[3]); + tmpObj->setJSCallbackThis(argv[4]); std::string imagePath; jsval_to_std_string(cx ,argv[0] , &imagePath); diff --git a/cocos/scripting/javascript/bindings/gui/Android.mk b/cocos/scripting/javascript/bindings/gui/Android.mk new file mode 100644 index 0000000000..5cc9e3505f --- /dev/null +++ b/cocos/scripting/javascript/bindings/gui/Android.mk @@ -0,0 +1,30 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := jsb_gui_static + +LOCAL_MODULE_FILENAME := libcocos2dxjsbgui + +LOCAL_SRC_FILES := jsb_cocos2dx_gui_manual.cpp \ + ../../../auto-generated/js-bindings/jsb_cocos2dx_gui_auto.cpp + +LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT + +LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT + +LOCAL_C_INCLUDES := $(LOCAL_PATH) \ + $(LOCAL_PATH)/../../../../../extensions \ + $(LOCAL_PATH)/../../../../gui + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) + +LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_gui_static + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,spidermonkey/prebuilt/android) +$(call import-module,scripting/javascript/bindings) +$(call import-module,gui) diff --git a/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp new file mode 100644 index 0000000000..32b4956a16 --- /dev/null +++ b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp @@ -0,0 +1,317 @@ +// +// jsb_cocos2dx_gui_manual.h +// +// Created by LinWenhai on 17/11/13. +// +// +#include "jsb_cocos2dx_gui_manual.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" +#include "gui/CocosGUI.h" + +using namespace gui; + +class JSStudioEventListenerWrapper: public JSCallbackWrapper { +public: + JSStudioEventListenerWrapper(); + virtual ~JSStudioEventListenerWrapper(); + + virtual void setJSCallbackThis(jsval thisObj); + + virtual void eventCallbackFunc(Object*,int); + +private: + bool m_bNeedUnroot; +}; + +JSStudioEventListenerWrapper::JSStudioEventListenerWrapper() + : m_bNeedUnroot(false) +{ + +} + +JSStudioEventListenerWrapper::~JSStudioEventListenerWrapper() +{ + if (m_bNeedUnroot) + { + JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_RemoveObjectRoot(cx, &thisObj); + } +} + +void JSStudioEventListenerWrapper::setJSCallbackThis(jsval jsThisObj) +{ + JSCallbackWrapper::setJSCallbackThis(jsThisObj); + + JSObject *thisObj = JSVAL_TO_OBJECT(jsThisObj); + js_proxy *p = jsb_get_js_proxy(thisObj); + if (!p) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS_AddObjectRoot(cx, &thisObj); + m_bNeedUnroot = true; + } +} + +void JSStudioEventListenerWrapper::eventCallbackFunc(Object* sender,int eventType) +{ + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); + js_proxy_t *proxy = js_get_or_create_proxy(cx, sender); + jsval retval; + if (_jsCallback != JSVAL_VOID) + { + jsval touchVal = INT_TO_JSVAL(eventType); + + jsval valArr[2]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = touchVal; + + JS_AddValueRoot(cx, valArr); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS_CallFunctionValue(cx, thisObj, _jsCallback, 2, valArr, &retval); + JS_RemoveValueRoot(cx, valArr); + } +} + +static JSBool js_cocos2dx_UIWidget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UIWidget* cobj = (gui::UIWidget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + cobj->setUserObject(tmpObj); + tmpObj->release(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->addTouchEventListener(tmpObj, toucheventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_UICheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UICheckBox* cobj = (gui::UICheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + cobj->setUserObject(tmpObj); + tmpObj->release(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->addEventListenerCheckBox(tmpObj, checkboxselectedeventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_UISlider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UISlider* cobj = (gui::UISlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + cobj->setUserObject(tmpObj); + tmpObj->release(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->addEventListenerSlider(tmpObj, sliderpercentchangedselector(JSStudioEventListenerWrapper::eventCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_UITextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UITextField* cobj = (gui::UITextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + cobj->setUserObject(tmpObj); + tmpObj->release(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->addEventListenerTextField(tmpObj, textfieldeventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_UIPageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UIPageView* cobj = (gui::UIPageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + cobj->setUserObject(tmpObj); + tmpObj->release(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->addEventListenerPageView(tmpObj, pagevieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_UIListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UIListView* cobj = (gui::UIListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 2) { + jsval *argv = JS_ARGV(cx, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + cobj->setUserObject(tmpObj); + tmpObj->release(); + + tmpObj->setJSCallbackFunc(argv[0]); + tmpObj->setJSCallbackThis(argv[1]); + + cobj->addEventListenerListView(tmpObj, listvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); + + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UILayoutParameter* cobj = (gui::UILayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 1) { + jsval *argv = JS_ARGV(cx, vp); + + JSObject *tmp; + JS::RootedValue jsleft(cx), jstop(cx),jsright(cx),jsbottom(cx); + double left, top,right,bottom; + JSBool ok = argv[0].isObject() && + JS_ValueToObject(cx, argv[0], &tmp) && + JS_GetProperty(cx, tmp, "left", &jsleft) && + JS_GetProperty(cx, tmp, "top", &jstop) && + JS_GetProperty(cx, tmp, "right", &jsright) && + JS_GetProperty(cx, tmp, "bottom", &jsbottom) && + JS_ValueToNumber(cx, jsleft, &left) && + JS_ValueToNumber(cx, jstop, &top) && + JS_ValueToNumber(cx, jsright, &right) && + JS_ValueToNumber(cx, jsbottom, &bottom); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + cobj->setMargin(gui::UIMargin(left,top,right,bottom)); + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +static JSBool js_cocos2dx_LayoutParameter_getMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + gui::UILayoutParameter* cobj = (gui::UILayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + + if (argc == 0) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JS_FALSE; + gui::UIMargin margin = cobj->getMargin(); + JSBool ok = JS_DefineProperty(cx, tmp, "left", DOUBLE_TO_JSVAL(margin.left), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "top", DOUBLE_TO_JSVAL(margin.top), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "right", DOUBLE_TO_JSVAL(margin.right), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "bottom", DOUBLE_TO_JSVAL(margin.bottom), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) + { + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } + else + { + return JS_FALSE; + } + return JS_TRUE; + } + JS_ReportError(cx, "Invalid number of arguments"); + return JS_FALSE; +} + +extern JSObject* jsb_UIWidget_prototype; +extern JSObject* jsb_UICheckBox_prototype; +extern JSObject* jsb_UISlider_prototype; +extern JSObject* jsb_UITextField_prototype; +extern JSObject* jsb_UILayoutParameter_prototype; +extern JSObject* jsb_UIPageView_prototype; +extern JSObject* jsb_UIListView_prototype; + +void register_all_cocos2dx_gui_manual(JSContext* cx, JSObject* global) +{ + JS_DefineFunction(cx, jsb_UIWidget_prototype, "addTouchEventListener", js_cocos2dx_UIWidget_addTouchEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_UICheckBox_prototype, "addEventListenerCheckBox", js_cocos2dx_UICheckBox_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_UISlider_prototype, "addEventListenerSlider", js_cocos2dx_UISlider_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_UITextField_prototype, "addEventListenerTextField", js_cocos2dx_UITextField_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_UIPageView_prototype, "addEventListenerPageView", js_cocos2dx_UIPageView_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_UIListView_prototype, "addEventListenerListView", js_cocos2dx_UIListView_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_UILayoutParameter_prototype, "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, jsb_UILayoutParameter_prototype, "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_READONLY | JSPROP_PERMANENT); +} \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.h b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.h new file mode 100644 index 0000000000..6a60065a16 --- /dev/null +++ b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.h @@ -0,0 +1,16 @@ +// +// jsb_cocos2dx_gui_manual.h +// +// Created by LinWenhai on 17/11/13. +// +// + +#ifndef __jsb_cocos2dx_gui_manual__ +#define __jsb_cocos2dx_gui_manual__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_all_cocos2dx_gui_manual(JSContext* cx, JSObject* global); + +#endif /* defined(__jsb_cocos2dx_gui_manual__) */ diff --git a/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj b/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj new file mode 100644 index 0000000000..cdb7034ee0 --- /dev/null +++ b/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj @@ -0,0 +1,118 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + {9A844C88-97E8-4E2D-B09A-E138C67D338B} + Win32Proj + libJSBindingForGui + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.filters b/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.filters new file mode 100644 index 0000000000..188570ed48 --- /dev/null +++ b/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.filters @@ -0,0 +1,34 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + generated + + + manual + + + + + generated + + + manual + + + + + generated + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.user b/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/scripting/javascript/script/jsb.js b/cocos/scripting/javascript/script/jsb.js index 7b0e39a256..b1dffd791e 100644 --- a/cocos/scripting/javascript/script/jsb.js +++ b/cocos/scripting/javascript/script/jsb.js @@ -6,6 +6,8 @@ require('jsb_cocos2d_constants.js'); require('jsb_cocos2d.js'); require('jsb_cocos2d_extension.js'); +require('jsb_cocos2d_studio.js'); +require('jsb_cocos2d_gui.js'); require('jsb_chipmunk_constants.js'); require('jsb_chipmunk.js'); require('jsb_opengl_constants.js'); diff --git a/cocos/scripting/javascript/script/jsb_cocos2d.js b/cocos/scripting/javascript/script/jsb_cocos2d.js index 5689a7a51e..5021ed2bf4 100644 --- a/cocos/scripting/javascript/script/jsb_cocos2d.js +++ b/cocos/scripting/javascript/script/jsb_cocos2d.js @@ -4,6 +4,20 @@ var cc = cc || {}; +cc.TARGET_PLATFORM = { + WINDOWS:0, + LINUX:1, + MACOS:2, + ANDROID:3, + IPHONE:4, + IPAD:5, + BLACKBERRY:6, + NACL:7, + EMSCRIPTEN:8, + MOBILE_BROWSER:100, + PC_BROWSER:101 +}; + cc.RESOLUTION_POLICY = { // The entire application is visible in the specified area without trying to preserve the original aspect ratio. // Distortion can occur, and the application may appear stretched or compressed. @@ -202,6 +216,10 @@ cc.pointEqualToPoint = function (point1, point2) { return ((point1.x == point2.x) && (point1.y == point2.y)); }; +cc.PointZero = function () { + return cc.p(0, 0); +}; + // // Grid // @@ -230,6 +248,10 @@ cc.sizeEqualToSize = function (size1, size2) return ((size1.width == size2.width) && (size1.height == size2.height)); }; +cc.SizeZero = function () { + return cc.size(0, 0); +}; + /** * create a cc.rect object * @param {Number|cc.point|cc.rect} [x] a Number value as x or a cc.point object as origin or a cc.rect clone object @@ -338,6 +360,10 @@ cc.rectIntersection = function (rectA, rectB) { return intersection; }; +cc.RectZero = function () { + return cc.rect(0, 0, 0, 0); +}; + // // Array: for cocos2d-html5 compatibility // @@ -586,3 +612,5 @@ cc.Loader.preload = function (resources, selector, target) { this._instance.initWith(resources, selector, target); return this._instance; }; + +cc.LoaderScene = cc.Loader; \ No newline at end of file diff --git a/cocos/scripting/javascript/script/jsb_cocos2d_gui.js b/cocos/scripting/javascript/script/jsb_cocos2d_gui.js new file mode 100644 index 0000000000..7c607082b4 --- /dev/null +++ b/cocos/scripting/javascript/script/jsb_cocos2d_gui.js @@ -0,0 +1,183 @@ +// +// cocos2d gui constants +// +// This helper file should be required after jsb_cocos2d.js +// + +var ccs = ccs || {}; + +ccs.BrightStyle = { + none: -1, + normal: 0, + highlight: 1 +}; + +ccs.WidgetType = { + widget: 0, //control + container: 1 //container +}; + +ccs.TextureResType = { + local: 0, + plist: 1 +}; + +ccs.TouchEventType = { + began: 0, + moved: 1, + ended: 2, + canceled: 3 +}; + +ccs.SizeType = { + absolute: 0, + percent: 1 +}; + +ccs.PositionType = { + absolute: 0, + percent: 1 +}; + +ccs.CheckBoxEventType = { + selected: 0, + unselected: 1 +}; + +ccs.TextFiledEventType = { + attach_with_me: 0, + detach_with_ime: 1, + insert_text: 2, + delete_backward: 3 +}; + +ccs.LayoutBackGroundColorType = { + none: 0, + solid: 1, + gradient: 2 +}; + +ccs.LayoutType = { + absolute: 0, + linearVertical: 1, + linearHorizontal: 2, + relative: 3 +}; + +ccs.UILayoutParameterType = { + none: 0, + linear: 1, + relative: 2 +}; + +ccs.UILinearGravity = { + none: 0, + left: 1, + top: 2, + right: 3, + bottom: 4, + centerVertical: 5, + centerHorizontal: 6 +}; + +ccs.UIRelativeAlign = { + alignNone: 0, + alignParentTopLeft: 1, + alignParentTopCenterHorizontal: 2, + alignParentTopRight: 3, + alignParentLeftCenterVertical: 4, + centerInParent: 5, + alignParentRightCenterVertical: 6, + alignParentLeftBottom: 7, + alignParentBottomCenterHorizontal: 8, + alignParentRightBottom: 9, + locationAboveLeftAlign: 10, + locationAboveCenter: 11, + locationAboveRightAlign: 12, + locationLeftOfTopAlign: 13, + locationLeftOfCenter: 14, + locationLeftOfBottomAlign: 15, + locationRightOfTopAlign: 16, + locationRightOfCenter: 17, + locationRightOfBottomAlign: 18, + locationBelowLeftAlign: 19, + locationBelowCenter: 20, + locationBelowRightAlign: 21 +}; + +ccs.SliderEventType = {percent_changed: 0}; + +ccs.LoadingBarType = { left: 0, right: 1}; + +ccs.ScrollViewDir = { + none: 0, + vertical: 1, + horizontal: 2, + both: 3 +}; + +ccs.ScrollviewEventType = { + scrollToTop: 0, + scrollToBottom: 1, + scrollToLeft: 2, + scrollToRight: 3, + scrolling: 4, + bounceTop: 5, + bounceBottom: 6, + bounceLeft: 7, + bounceRight: 8 +}; + +ccs.ListViewEventType = { + init_child: 0, + update_child: 1 +}; + +ccs.PageViewEventType = { + turning: 0 +}; + +ccs.PVTouchDir = { + touchLeft: 0, + touchRight: 1 +}; + +ccs.UIPanel = ccs.UILayout; +ccs.UITextArea = ccs.UILabel; +ccs.UIContainerWidget = ccs.UILayout; +ccs.UITextButton = ccs.UIButton; +ccs.UINodeContainer = ccs.UIWidget; +ccs.PanelColorType = ccs.LayoutBackGroundColorType; + +ccs.UILayout = ccs.Layout; + +ccs.UIMargin = cc.Class.extend({ + left: 0, + top: 0, + right: 0, + bottom: 0, + ctor: function () { + if (arguments.length == 1) { + var uiMargin = arguments[0]; + this.left = uiMargin.left; + this.top = uiMargin.top; + this.right = uiMargin.right; + this.bottom = uiMargin.bottom; + } + if (arguments.length == 4) { + this.left = arguments[0]; + this.top = arguments[1]; + this.right = arguments[2]; + this.bottom = arguments[3]; + } + }, + setMargin: function (l, t, r, b) { + this.left = l; + this.top = t; + this.right = r; + this.bottom = b; + }, + equals: function (target) { + return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom); + } +}); diff --git a/cocos/scripting/javascript/script/jsb_cocos2d_studio.js b/cocos/scripting/javascript/script/jsb_cocos2d_studio.js new file mode 100644 index 0000000000..fadd914f00 --- /dev/null +++ b/cocos/scripting/javascript/script/jsb_cocos2d_studio.js @@ -0,0 +1,27 @@ +// +// cocos2d studio constants +// +// This helper file should be required after jsb_cocos2d.js +// + +var ccs = ccs || {}; + +//movement event type +ccs.MovementEventType = { + start: 0, + complete: 1, + loopComplete: 2 +}; + +// Armature +if(ccs.Armature){ + ccs.Armature.prototype.setBody = function( body ) { + var b = body; + if( body.handle !== undefined ) + b = body.handle; + return this._setCPBody( b ); + }; + + ccs.ComController.extend = cc.Class.extend; + ccs.Armature.extend = cc.Class.extend; +} diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index 2a26806916..a85f0939c7 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -7,8 +7,10 @@ #include "jsb_cocos2dx_extension_auto.hpp" #include "jsb_cocos2dx_builder_auto.hpp" #include "jsb_cocos2dx_studio_auto.hpp" +#include "jsb_cocos2dx_gui_auto.hpp" #include "extension/jsb_cocos2dx_extension_manual.h" #include "cocostudio/jsb_cocos2dx_studio_manual.h" +#include "gui/jsb_cocos2dx_gui_manual.h" #include "cocos2d_specifics.hpp" #include "cocosbuilder/cocosbuilder_specifics.hpp" #include "chipmunk/js_bindings_chipmunk_registration.h" @@ -47,6 +49,7 @@ bool AppDelegate::applicationDidFinishLaunching() FileUtils::getInstance()->addSearchPath("res"); FileUtils::getInstance()->addSearchPath("script"); + FileUtils::getInstance()->addSearchPath("res/scenetest"); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); @@ -62,6 +65,8 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); + sc->addRegisterCallback(register_all_cocos2dx_gui); + sc->addRegisterCallback(register_all_cocos2dx_gui_manual); sc->addRegisterCallback(register_all_cocos2dx_studio); sc->addRegisterCallback(register_all_cocos2dx_studio_manual); diff --git a/samples/Javascript/TestJavascript/proj.android/jni/Android.mk b/samples/Javascript/TestJavascript/proj.android/jni/Android.mk index 0a9f023dc3..867b8ccdc3 100644 --- a/samples/Javascript/TestJavascript/proj.android/jni/Android.mk +++ b/samples/Javascript/TestJavascript/proj.android/jni/Android.mk @@ -17,6 +17,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES += jsb_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_localstorage_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_network_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_builder_static +LOCAL_WHOLE_STATIC_LIBRARIES += jsb_gui_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_studio_static @@ -30,4 +31,5 @@ $(call import-module,scripting/javascript/bindings/extension) $(call import-module,scripting/javascript/bindings/localstorage) $(call import-module,scripting/javascript/bindings/network) $(call import-module,scripting/javascript/bindings/cocosbuilder) +$(call import-module,scripting/javascript/bindings/gui) $(call import-module,scripting/javascript/bindings/cocostudio) diff --git a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj index f6e517fc8f..bb12af0fb5 100644 --- a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj +++ b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj @@ -225,6 +225,9 @@ xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Y {625f7391-9a91-48a1-8cfc-79508c822637} + + {9a844c88-97e8-4e2d-b09a-e138c67d338b} + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} diff --git a/tools/tojs/cocos2dx_gui.ini b/tools/tojs/cocos2dx_gui.ini new file mode 100644 index 0000000000..ef976a52a5 --- /dev/null +++ b/tools/tojs/cocos2dx_gui.ini @@ -0,0 +1,64 @@ +[cocos2dx_gui] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_gui + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = ccs + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s + +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/gui/CocosGUI.h + +# 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*$". +classes = UIHelper UILayout UIWidget UILayer UIButton UICheckBox UIImageView UILabel UILabelAtlas UILabelBMFont UILoadingBar UISlider UISwitch UITextField UIScrollView UIPageView UIListView UILayoutParameter UILinearLayoutParameter UIRelativeLayoutParameter + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc ccTouch.*], + UIWidget::[(s|g)etUserObject], + UILayer::[getInputManager], + UILayoutParameter::[(s|g)etMargin], + UIImageView::[doubleClickEvent checkDoubleClick] + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = UIHelper + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Object + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = UIHelper + +# 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 + diff --git a/tools/tojs/cocos2dx_studio.ini b/tools/tojs/cocos2dx_studio.ini index 47859dac3f..ca010236bd 100644 --- a/tools/tojs/cocos2dx_studio.ini +++ b/tools/tojs/cocos2dx_studio.ini @@ -5,7 +5,7 @@ prefix = cocos2dx_studio # create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) # all classes will be embedded in that namespace -target_namespace = cc +target_namespace = ccs android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include android_flags = -D_SIZE_T_DEFINED_ @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h # 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*$". -classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -36,29 +36,34 @@ classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = .*Delegate::[*], - .*Loader.*::[*], - *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener], +skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc ccTouch.*], + InputDelegate::[didAccelerate on.*], + GUIReader::[storeFileDesignSize getFileDesignSize], + ComAttribute::[getDict], + BatchNode::[init draw], Armature::[createBone updateBlendType getBody setBody getShapeList .*BlendFunc], Skin::[getSkinData setSkinData], - ArmatureAnimation::[updateHandler updateFrameData frameEvent] + ArmatureAnimation::[updateHandler updateFrameData frameEvent], + ActionManagerEx::[initWithDictionary] -rename_functions = +rename_functions = ActionManagerEx::[shareManager=getInstance purgeActionManager=purge], + SceneReader::[purgeSceneReader=purge], + GUIReader::[shareReader=getInstance purgeGUIReader=purge] -rename_classes = +rename_classes = ActionManagerEx::ActionManager # for all class names, should we remove something when registering in the target VM? remove_prefix = # classes for which there will be no "parent" lookup -classes_have_no_parents = +classes_have_no_parents = InputDelegate SceneReader # base classes which will be skipped when their sub-classes found them. base_classes_to_skip = Object ProcessBase # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = ArmatureDataManager +abstract_classes = ArmatureDataManager ComAttribute InputDelegate ComRender ComAudio InputDelegate ActionManagerEx SceneReader GUIReader BatchNode # 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 diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index 37d07f9d12..fedf3cacd5 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -88,5 +88,8 @@ LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py echo "Generating bindings for cocos2dx_builder..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_builder.ini -s cocos2dx_builder -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_builder_auto +echo "Generating bindings for cocos2dx_gui..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_gui.ini -s cocos2dx_gui -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_gui_auto + echo "Generating bindings for cocos2dx_studio..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto \ No newline at end of file