From 04cd6f8ec5611687c531783cc1a6d9abc2673a45 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 17 Sep 2015 12:02:54 +0800 Subject: [PATCH 001/192] Bump external version to 73 --- external/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/config.json b/external/config.json index a653cc9f0d..eed9a33634 100644 --- a/external/config.json +++ b/external/config.json @@ -1,6 +1,6 @@ { - "version":"v3-deps-72", - "zip_file_size":"119277304", + "version":"v3-deps-73", + "zip_file_size":"117989863", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", "move_dirs":{ From c870d1daf13a477f989efbc55de3b8af839327d4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 17 Sep 2015 12:13:10 +0800 Subject: [PATCH 002/192] Update docs and versions for v3.8.1 --- CHANGELOG | 4 +++ CMakeLists.txt | 2 +- cocos/cocos2d.cpp | 2 +- .../js-bindings/manual/ScriptingCore.h | 2 +- .../js-bindings/script/jsb_cocos2d.js | 2 +- docs/RELEASE_NOTES.md | 25 ++++++++++--------- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e6c0c7f48e..4bdff28b7c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +cocos2d-x-3.8.1 September.17 2015 + + [HIGHLIGHT] platform: Supported Xcode 7 for iOS 9 deployment + cocos2d-x-3.8 final September.6 2015 cocos2d-x-3.8 rc0 August.26 2015 cocos2d-x-3.8 beta0 August.14 2015 diff --git a/CMakeLists.txt b/CMakeLists.txt index b7f9fcc2f9..7185404fa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ endif() project (Cocos2d-X) # The version number -set(COCOS2D_X_VERSION 3.8) +set(COCOS2D_X_VERSION 3.8.1) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") include(CocosBuildHelpers) diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index ccc0f8a29a..597afaee84 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -31,7 +31,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "cocos2d-x-3.8"; + return "cocos2d-x-3.8.1"; } NS_CC_END diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 7e2e1df406..e4d6f1d9cf 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -39,7 +39,7 @@ #include #include -#define ENGINE_VERSION "Cocos2d-JS v3.8" +#define ENGINE_VERSION "Cocos2d-JS v3.8.1" void js_log(const char *format, ...); diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index 6adb05e786..fdd14fc4b1 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.8"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.8.1"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 19350b0fc5..656947d906 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -2,7 +2,7 @@ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [Cocos2d-x v3.8 Release Notes](#cocos2d-x-v38-release-notes) +- [Cocos2d-x v3.8.1 Release Notes](#cocos2d-x-v381-release-notes) - [Misc Information](#misc-information) - [Requirements](#requirements) - [Runtime Requirements](#runtime-requirements) @@ -14,8 +14,8 @@ - [Windows](#windows) - [Linux](#linux) - [How to start a new game](#how-to-start-a-new-game) -- [v3.8](#v38) - - [Highlights and API changes of v3.8](#highlights-and-api-changes-of-v38) +- [v3.8.1](#v38) + - [Highlights and API changes of v3.8.1](#highlights-and-api-changes-of-v381) - [Download](#download) - [The main features in detail:](#the-main-features-in-detail) - [3D Module](#3d-module) @@ -29,7 +29,7 @@ -# Cocos2d-x v3.8 Release Notes # +# Cocos2d-x v3.8.1 Release Notes # # Misc Information @@ -150,30 +150,31 @@ Use Cocos Console to create a new game: cocos new -l cpp|js|lua MyNewGame ``` -# v3.8 +# v3.8.1 -## Highlights and API changes of v3.8 +## Highlights and API changes of v3.8.1 As promised, Cocos2d-x v3.8 have greatly improved the stability and API friendliness. On one side, we continue to improve 3D capacity by providing 3D physics collider, skybox background brush and key frame event callback in Animate3D. On another side, we have refined several core modules, including UI system, AudioEngine, FileUtils, Bindings Generator, etc. Here is some highlighted improvments and API changes: -1. 3D Module +1. Xcode 7 support +2. 3D Module - Added 3D physics collider - Supported setting camera background brushes with color/depth/skybox - Added key frame event Callback in Animate3D - Added light map support in Terrain -2. UI System +3. UI System - Reimplemented and enhanced EditBox on Android - Added ScrollViewBar for displaying a scroll bar at the side of ScrollView (JSB/Lua ready) - Added RadioButton widget (JSB/Lua ready) - Added HANYI FullType font support -3. AudioEngine +4. AudioEngine - AudioEngine supported audio preloading - Bound new AudioEngine in JSB -4. FileUtils +5. FileUtils - Added a set of file writing APIs: writeStringToFile, writeDataToFile, writeValueMapToFile, writeValueVectorToFile -5. Others +6. Others - Improved Bindings Generator tool - Merged JSB test project into cocos2d test project - framework: Support generate prebuilt libs of engine with debug mode @@ -181,7 +182,7 @@ Here is some highlighted improvments and API changes: ## Download -[Cocos2d-x v3.8](http://www.cocos2d-x.org/filedown/cocos2d-x-3.8.zip) including : C++, Lua & JS +[Cocos2d-x v3.8.1](http://www.cocos2d-x.org/filedown/cocos2d-x-3.8.1.zip) including : C++, Lua & JS ## The main features in detail: From e74ac2377a27f394d3559347248b5b909994299a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 17 Sep 2015 16:31:17 +0800 Subject: [PATCH 003/192] Fix _hittedByCamera may be null in Widget::isClippingParentContainsPoint Merged from https://github.com/cocos2d/cocos2d-x/pull/13884 --- cocos/ui/UIWidget.cpp | 6 ++++-- .../frameworks/runtime-src/proj.ios_mac/mac/Info.plist | 2 +- tools/simulator/frameworks/runtime-src/proj.win32/game.rc | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index f276cdb07e..b7c623f01a 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -767,8 +767,8 @@ bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent) auto camera = Camera::getVisitingCamera(); if(hitTest(_touchBeganPosition, camera, nullptr)) { - _hittedByCamera = camera; if (isClippingParentContainsPoint(_touchBeganPosition)) { + _hittedByCamera = camera; _hitted = true; } } @@ -971,7 +971,9 @@ bool Widget::isClippingParentContainsPoint(const Vec2 &pt) if (clippingParent) { bool bRet = false; - if (clippingParent->hitTest(pt, _hittedByCamera, nullptr)) + auto camera = Camera::getVisitingCamera(); + // Camera isn't null means in touch begin process, otherwise use _hittedByCamera instead. + if (clippingParent->hitTest(pt, (camera ? camera : _hittedByCamera), nullptr)) { bRet = true; } diff --git a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist index e52344dca3..3fca271a0a 100644 --- a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist +++ b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist @@ -41,7 +41,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.8 + 3.8.1 CFBundleSignature ???? CFBundleVersion diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc index 4733633d7b..6040595fb1 100755 --- a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc +++ b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc @@ -64,7 +64,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "About Simulator" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CTEXT "Version 3.8 (20150227)",IDC_ABOUT_VERSION,35,70,173,17 + CTEXT "Version 3.8.1 (20150917)",IDC_ABOUT_VERSION,35,70,173,17 CTEXT "Cocos Simulator",IDC_ABOUT_TITLE,35,49,173,17 CTEXT "Copyright (C) 2015. All rights reserved.",IDC_STATIC,35,94,173,17 ICON "GLFW_ICON",IDC_STATIC,111,15,20,20 From 4018ce383c91497babbfb2a494c12117c956e135 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 18 Sep 2015 11:06:36 +0800 Subject: [PATCH 004/192] Fix ScrollView clone bug and js templates Mac target version --- cocos/ui/UIScrollView.cpp | 2 +- .../proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj | 2 ++ .../proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 2c23915930..5e41fa75c3 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -1342,8 +1342,8 @@ void ScrollView::copySpecialProperties(Widget *widget) if (scrollView) { Layout::copySpecialProperties(widget); - _innerContainer = scrollView->_innerContainer; setDirection(scrollView->_direction); + setInnerContainerPosition(scrollView->getInnerContainerPosition()); setInnerContainerSize(scrollView->getInnerContainerSize()); _topBoundary = scrollView->_topBoundary; _bottomBoundary = scrollView->_bottomBoundary; diff --git a/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index 939a39c30b..ea3778e07e 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -851,6 +851,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; + MACOSX_DEPLOYMENT_TARGET = 10.8; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../cocos2d-x $(SRCROOT)/../../cocos2d-x/cocos $(SRCROOT)/../../cocos2d-x/cocos/base $(SRCROOT)/../../cocos2d-x/cocos/physics $(SRCROOT)/../../cocos2d-x/cocos/math/kazmath $(SRCROOT)/../../cocos2d-x/cocos/2d $(SRCROOT)/../../cocos2d-x/cocos/gui $(SRCROOT)/../../cocos2d-x/cocos/network $(SRCROOT)/../../cocos2d-x/cocos/audio/include $(SRCROOT)/../../cocos2d-x/cocos/editor-support $(SRCROOT)/../../cocos2d-x/extensions $(SRCROOT)/../../cocos2d-x/external $(SRCROOT)/../../cocos2d-x/external/chipmunk/include/chipmunk $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/auto $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/manual"; @@ -873,6 +874,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; + MACOSX_DEPLOYMENT_TARGET = 10.8; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../cocos2d-x $(SRCROOT)/../../cocos2d-x/cocos $(SRCROOT)/../../cocos2d-x/cocos/base $(SRCROOT)/../../cocos2d-x/cocos/physics $(SRCROOT)/../../cocos2d-x/cocos/math/kazmath $(SRCROOT)/../../cocos2d-x/cocos/2d $(SRCROOT)/../../cocos2d-x/cocos/gui $(SRCROOT)/../../cocos2d-x/cocos/network $(SRCROOT)/../../cocos2d-x/cocos/audio/include $(SRCROOT)/../../cocos2d-x/cocos/editor-support $(SRCROOT)/../../cocos2d-x/extensions $(SRCROOT)/../../cocos2d-x/external $(SRCROOT)/../../cocos2d-x/external/chipmunk/include/chipmunk $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/auto $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/manual"; diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index 733559c7d0..37cc387fd8 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -1090,6 +1090,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; + MACOSX_DEPLOYMENT_TARGET = 10.8; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../cocos2d-x $(SRCROOT)/../../cocos2d-x/cocos $(SRCROOT)/../../cocos2d-x/cocos/base $(SRCROOT)/../../cocos2d-x/cocos/physics $(SRCROOT)/../../cocos2d-x/cocos/math/kazmath $(SRCROOT)/../../cocos2d-x/cocos/2d $(SRCROOT)/../../cocos2d-x/cocos/gui $(SRCROOT)/../../cocos2d-x/cocos/network $(SRCROOT)/../../cocos2d-x/cocos/audio/include $(SRCROOT)/../../cocos2d-x/cocos/editor-support $(SRCROOT)/../../cocos2d-x/extensions $(SRCROOT)/../../cocos2d-x/external $(SRCROOT)/../../cocos2d-x/external/chipmunk/include/chipmunk $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/auto $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/manual"; @@ -1112,6 +1113,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; + MACOSX_DEPLOYMENT_TARGET = 10.8; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../cocos2d-x $(SRCROOT)/../../cocos2d-x/cocos $(SRCROOT)/../../cocos2d-x/cocos/base $(SRCROOT)/../../cocos2d-x/cocos/physics $(SRCROOT)/../../cocos2d-x/cocos/math/kazmath $(SRCROOT)/../../cocos2d-x/cocos/2d $(SRCROOT)/../../cocos2d-x/cocos/gui $(SRCROOT)/../../cocos2d-x/cocos/network $(SRCROOT)/../../cocos2d-x/cocos/audio/include $(SRCROOT)/../../cocos2d-x/cocos/editor-support $(SRCROOT)/../../cocos2d-x/extensions $(SRCROOT)/../../cocos2d-x/external $(SRCROOT)/../../cocos2d-x/external/chipmunk/include/chipmunk $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/auto $(SRCROOT)/../../cocos2d-x/cocos/scripting/js-bindings/manual"; From bc4bd99863e5c934db2d1b3b2c6b55dbc95c863e Mon Sep 17 00:00:00 2001 From: Yukio Murakami Date: Mon, 28 Sep 2015 14:33:17 +0900 Subject: [PATCH 005/192] Support the new line element. Fixed a problem that protrude from the drawing area. --- cocos/ui/UIRichText.cpp | 60 +++++++++++++++++++++++++++++++++++++++++ cocos/ui/UIRichText.h | 38 +++++++++++++++++++++++++- 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index b4091cd323..eeee8eae38 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -112,6 +112,18 @@ bool RichElementCustomNode::init(int tag, const Color3B &color, GLubyte opacity, return false; } +RichElementNewLine* RichElementNewLine::create(int tag, const Color3B& color, GLubyte opacity) +{ + RichElementNewLine* element = new (std::nothrow) RichElementNewLine(); + if (element && element->init(tag, color, opacity)) + { + element->autorelease(); + return element; + } + CC_SAFE_DELETE(element); + return nullptr; +} + RichText::RichText(): _formatTextDirty(true), _leftSpaceWidth(0.0f), @@ -214,6 +226,11 @@ void RichText::formatText() elementRenderer = elmtCustom->_customNode; break; } + case RichElement::Type::NEWLINE: + { + addNewLine(); + break; + } default: break; } @@ -249,6 +266,11 @@ void RichText::formatText() handleCustomRenderer(elmtCustom->_customNode); break; } + case RichElement::Type::NEWLINE: + { + addNewLine(); + break; + } default: break; } @@ -279,6 +301,44 @@ void RichText::handleTextRenderer(const std::string& text, const std::string& fo std::string curText = text; size_t stringLength = StringUtils::getCharacterCountInUTF8String(text); int leftLength = stringLength * (1.0f - overstepPercent); + + // The adjustment of the new line position + auto originalLeftSpaceWidth = _leftSpaceWidth + textRendererWidth; + auto leftStr = Helper::getSubStringOfUTF8String(curText, 0, leftLength); + textRenderer->setString(leftStr); + auto leftWidth = textRenderer->getContentSize().width; + if (originalLeftSpaceWidth < leftWidth) { + // Have protruding + for (;;) { + leftLength--; + leftStr = Helper::getSubStringOfUTF8String(curText, 0, leftLength); + textRenderer->setString(leftStr); + leftWidth = textRenderer->getContentSize().width; + if (leftWidth <= originalLeftSpaceWidth) { + break; + } + else if (leftLength <= 0) { + break; + } + } + } + else if (leftWidth < originalLeftSpaceWidth) { + // A wide margin + for (;;) { + leftLength++; + leftStr = Helper::getSubStringOfUTF8String(curText, 0, leftLength); + textRenderer->setString(leftStr); + leftWidth = textRenderer->getContentSize().width; + if (originalLeftSpaceWidth < leftWidth) { + leftLength--; + break; + } + else if (stringLength <= leftLength) { + break; + } + } + } + //The minimum cut length is 1, otherwise will cause the infinite loop. if (0 == leftLength) leftLength = 1; std::string leftWords = Helper::getSubStringOfUTF8String(curText,0,leftLength); diff --git a/cocos/ui/UIRichText.h b/cocos/ui/UIRichText.h index 00de9b18f2..4b918aac7d 100644 --- a/cocos/ui/UIRichText.h +++ b/cocos/ui/UIRichText.h @@ -50,7 +50,8 @@ public: { TEXT, IMAGE, - CUSTOM + CUSTOM, + NEWLINE }; /** @@ -243,6 +244,41 @@ protected: friend class RichText; }; +/** + *@brief Rich element for new line. + */ +class CC_GUI_DLL RichElementNewLine : public RichElement +{ +public: + + /** + * @brief Default constructor. + * @js ctor + * @lua new + * + */ + RichElementNewLine(){_type = Type::NEWLINE;}; + + /** + * @brief Default destructor. + * @js NA + * @lua NA + */ + virtual ~RichElementNewLine(){}; + + /** + * @brief Create a RichElementNewLine with various arguments. + * + * @param tag A integer tag value. + * @param color A color in Color3B. + * @param opacity A opacity in GLubyte. + * @return A RichElementNewLine instance. + */ + static RichElementNewLine* create(int tag, const Color3B& color, GLubyte opacity); +protected: + friend class RichText; +}; + /** *@brief A container for displaying various RichElements. * We could use it to display texts with images easily. From 2785a4313fcae0b27857fa2d6d9f4cd67f7a6a13 Mon Sep 17 00:00:00 2001 From: dimon4eg Date: Wed, 30 Sep 2015 12:31:33 +0300 Subject: [PATCH 006/192] Set focus for widgets --- cocos/ui/UITextField.cpp | 1 + cocos/ui/UIWidget.cpp | 8 +++++++- cocos/ui/UIWidget.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index 89388b2c95..63d578d1e1 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -536,6 +536,7 @@ bool TextField::onTouchBegan(Touch *touch, Event *unusedEvent) bool pass = Widget::onTouchBegan(touch, unusedEvent); if (_hitted) { + requestFocus(); _textFieldRenderer->attachWithIME(); } else diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index ac4c173e46..0c494db808 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -888,6 +888,12 @@ void Widget::moveEvent() void Widget::releaseUpEvent() { this->retain(); + + if (isFocusEnabled()) + { + requestFocus(); + } + if (_touchEventCallback) { _touchEventCallback(this, TouchEventType::ENDED); @@ -1449,7 +1455,7 @@ void Widget::onFocusChange(Widget* widgetLostFocus, Widget* widgetGetFocus) } } -Widget* Widget::getCurrentFocusedWidget()const +Widget* Widget::getCurrentFocusedWidget() { return _focusedWidget; } diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index d0de0b155c..f625931eed 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -775,7 +775,7 @@ public: * Return a current focused widget in your UI scene. * No matter what widget object you call this method on , it will return you the exact one focused widget. */ - Widget* getCurrentFocusedWidget()const; + static Widget* getCurrentFocusedWidget(); /* * Call this method with parameter true to enable the Android Dpad focus navigation feature From fe8c1a12b558789f0a86f93e707eac897220802f Mon Sep 17 00:00:00 2001 From: dimon4eg Date: Wed, 30 Sep 2015 12:39:44 +0300 Subject: [PATCH 007/192] Fix for text field --- cocos/ui/UITextField.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index 63d578d1e1..dc13ee6b07 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -536,7 +536,11 @@ bool TextField::onTouchBegan(Touch *touch, Event *unusedEvent) bool pass = Widget::onTouchBegan(touch, unusedEvent); if (_hitted) { - requestFocus(); + if (isFocusEnabled()) + { + requestFocus(); + } + _textFieldRenderer->attachWithIME(); } else From bd83fc14740900a5b5f577db51069c4beede8d84 Mon Sep 17 00:00:00 2001 From: Sebastien Flory Date: Thu, 15 Oct 2015 15:48:21 +0200 Subject: [PATCH 008/192] PMA Handling issue Hi, I compared to cocos2D-x v2.x and it seems that there is an issue with the _hasPremultipliedAlpha flag not beeing set correctly for mipmaps and compressed textures. I guess it's a mistake due to the reorganization of the code between the old CCTexture2D and the new one. In our tests, this fixes the issue. Best, Sebastien --- cocos/renderer/CCTexture2D.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index a67d44d38c..e2ef8610e3 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -756,6 +756,9 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format) initWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getRenderFormat(), imageWidth, imageHeight); + // set the premultiplied tag + _hasPremultipliedAlpha = image->hasPremultipliedAlpha(); + return true; } else if (image->isCompressed()) @@ -766,6 +769,10 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format) } initWithData(tempData, tempDataLen, image->getRenderFormat(), imageWidth, imageHeight, imageSize); + + // set the premultiplied tag + _hasPremultipliedAlpha = image->hasPremultipliedAlpha(); + return true; } else From f49d467465e39c4600457c2cad3c9f2bff2460bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=82=A8=EC=A4=80=ED=98=84?= Date: Sat, 17 Oct 2015 04:46:37 +0900 Subject: [PATCH 009/192] Add virtual keyword. --- cocos/platform/ios/CCGLViewImpl-ios.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/platform/ios/CCGLViewImpl-ios.h b/cocos/platform/ios/CCGLViewImpl-ios.h index f7ec641d17..83a7607df8 100644 --- a/cocos/platform/ios/CCGLViewImpl-ios.h +++ b/cocos/platform/ios/CCGLViewImpl-ios.h @@ -58,16 +58,16 @@ public: static int _depthFormat; /** sets the content scale factor */ - bool setContentScaleFactor(float contentScaleFactor) override; + virtual bool setContentScaleFactor(float contentScaleFactor) override; /** returns the content scale factor */ - float getContentScaleFactor() const override; + virtual float getContentScaleFactor() const override; /** returns whether or not the view is in Retina Display mode */ - bool isRetinaDisplay() const override { return getContentScaleFactor() == 2.0; } + virtual bool isRetinaDisplay() const override { return getContentScaleFactor() == 2.0; } /** returns the objective-c CCEAGLView instance */ - void* getEAGLView() const override { return _eaglview; } + virtual void* getEAGLView() const override { return _eaglview; } // overrides virtual bool isOpenGLReady() override; From a09f2af14ca5af08346a678f643f841b58052fcf Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Fri, 28 Aug 2015 14:50:22 +0900 Subject: [PATCH 010/192] PageView - Trivial change on test code --- .../CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index 74bb50eb1f..fe2ccc2778 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -55,11 +55,7 @@ bool UIPageViewTest::init() PageView* pageView = PageView::create(); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); - pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + - (backgroundSize.width - pageView->getContentSize().width) / 2.0f, - (widgetSize.height - backgroundSize.height) / 2.0f + - (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); - + pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); pageView->removeAllPages(); int pageCount = 4; From e567259826d6d7bf07da79681b7ab2877ee6ec0d Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 16 Sep 2015 18:13:58 +0900 Subject: [PATCH 011/192] PageView - Change `PageView` to derive from `ListView` and use `ScrollView::Direction` instead of `PageView::Direction`. --- cocos/ui/UIPageView.cpp | 35 +++++++------------ cocos/ui/UIPageView.h | 35 +++---------------- .../UIPageViewTest/UIPageViewTest.cpp | 1 + 3 files changed, 19 insertions(+), 52 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 51eadb523d..770ea6a881 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -35,7 +35,6 @@ _isAutoScrolling(false), _autoScrollDistance(0.0f), _autoScrollSpeed(0.0f), _autoScrollDirection(AutoScrollDirection::LEFT), -_direction(Direction::HORIZONTAL), _curPageIdx(-1), _touchMoveDirection(TouchDirection::LEFT), _leftBoundaryChild(nullptr), @@ -50,6 +49,7 @@ _pageViewEventSelector(nullptr), _eventCallback(nullptr) { this->setTouchEnabled(true); + setDirection(ScrollView::Direction::HORIZONTAL); } PageView::~PageView() @@ -80,15 +80,17 @@ void PageView::onEnter() } #endif - Layout::onEnter(); + ListView::onEnter(); scheduleUpdate(); } bool PageView::init() { - if (Layout::init()) + if (ListView::init()) { - setClippingEnabled(true); + setDirection(ListView::Direction::HORIZONTAL); + setMagneticType(MagneticType::CENTER); + setScrollBarEnabled(false); return true; } return false; @@ -239,7 +241,7 @@ float PageView::getPositionYByIndex(ssize_t idx)const void PageView::onSizeChanged() { - Layout::onSizeChanged(); + ListView::onSizeChanged(); if (_direction == Direction::HORIZONTAL) { _rightBoundary = getContentSize().width; @@ -343,16 +345,6 @@ void PageView::scrollToPage(ssize_t idx) _autoScrollSpeed = fabs(_autoScrollDistance)/0.2f; _isAutoScrolling = true; } - -void PageView::setDirection(cocos2d::ui::PageView::Direction direction) -{ - this->_direction = direction; -} - -PageView::Direction PageView::getDirection()const -{ - return this->_direction; -} void PageView::update(float dt) { @@ -421,13 +413,13 @@ void PageView::autoScroll(float dt) bool PageView::onTouchBegan(Touch *touch, Event *unusedEvent) { - bool pass = Layout::onTouchBegan(touch, unusedEvent); + bool pass = ListView::onTouchBegan(touch, unusedEvent); return pass; } void PageView::onTouchMoved(Touch *touch, Event *unusedEvent) { - Layout::onTouchMoved(touch, unusedEvent); + ListView::onTouchMoved(touch, unusedEvent); if (!_isInterceptTouch) { handleMoveLogic(touch); @@ -436,7 +428,7 @@ void PageView::onTouchMoved(Touch *touch, Event *unusedEvent) void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) { - Layout::onTouchEnded(touch, unusedEvent); + ListView::onTouchEnded(touch, unusedEvent); if (!_isInterceptTouch) { handleReleaseLogic(touch); @@ -446,7 +438,7 @@ void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) void PageView::onTouchCancelled(Touch *touch, Event *unusedEvent) { - Layout::onTouchCancelled(touch, unusedEvent); + ListView::onTouchCancelled(touch, unusedEvent); if (!_isInterceptTouch) { handleReleaseLogic(touch); @@ -701,7 +693,7 @@ void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch * { if (!_touchEnabled) { - Layout::interceptTouchEvent(event, sender, touch); + ListView::interceptTouchEvent(event, sender, touch); return; } Vec2 touchPoint = touch->getLocation(); @@ -819,14 +811,13 @@ void PageView::copySpecialProperties(Widget *widget) PageView* pageView = dynamic_cast(widget); if (pageView) { - Layout::copySpecialProperties(widget); + ListView::copySpecialProperties(widget); _eventCallback = pageView->_eventCallback; _ccEventCallback = pageView->_ccEventCallback; _pageViewEventListener = pageView->_pageViewEventListener; _pageViewEventSelector = pageView->_pageViewEventSelector; _usingCustomScrollThreshold = pageView->_usingCustomScrollThreshold; _customScrollThreshold = pageView->_customScrollThreshold; - _direction = pageView->_direction; } } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index adfb06de74..86f68c955d 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __UIPAGEVIEW_H__ #define __UIPAGEVIEW_H__ -#include "ui/UILayout.h" +#include "ui/UIListView.h" #include "ui/GUIExport.h" /** @@ -56,7 +56,7 @@ typedef void (Ref::*SEL_PageViewEvent)(Ref*, PageViewEventType); *@brief Layout manager that allows the user to flip left & right and up & down through pages of data. * */ -class CC_GUI_DLL PageView : public Layout +class CC_GUI_DLL PageView : public ListView { DECLARE_CLASS_GUI_INFO @@ -80,15 +80,9 @@ public: UP, DOWN }; - - enum class Direction - { - HORIZONTAL, - VERTICAL - }; - + /** - *PageView page turn event callback. + * PageView page turn event callback. */ typedef std::function ccPageViewCallback; @@ -150,24 +144,6 @@ public: */ void removePageAtIndex(ssize_t index); - /** - * Changes scroll direction of PageView - * - * @see `Direction` - * @param direction Scroll direction enum. - * @since v3.8 - */ - void setDirection(Direction direction); - - /** - * Query scroll direction of PageView. - * - * @see `Direction` - * @since v3.8 - * @return PageView scroll direction. - */ - Direction getDirection()const; - /** * @brief Remove all pages of the PageView. */ @@ -307,8 +283,7 @@ protected: float _autoScrollDistance; float _autoScrollSpeed; AutoScrollDirection _autoScrollDirection; - Direction _direction; - + ssize_t _curPageIdx; Vector _pages; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index fe2ccc2778..d9882e8eae 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -53,6 +53,7 @@ bool UIPageViewTest::init() // Create the page view PageView* pageView = PageView::create(); + pageView->setDirection(PageView::Direction::HORIZONTAL); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); From 97acf52cc85295ccfa511116a27436de30a4a7e0 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 16 Sep 2015 18:59:56 +0900 Subject: [PATCH 012/192] PageView - Replace the legacy methods of `PageView` with the ones of `ListView`. --- cocos/ui/UIListView.cpp | 12 +- cocos/ui/UIListView.h | 9 +- cocos/ui/UIPageView.cpp | 655 +----------------- cocos/ui/UIPageView.h | 118 ++-- .../UIPageViewTest/UIPageViewTest.cpp | 80 ++- .../UIPageViewTest/UIPageViewTest.h | 13 +- 6 files changed, 168 insertions(+), 719 deletions(-) diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index aab0418ff2..7cd55bacc5 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -72,7 +72,7 @@ bool ListView::init() { if (ScrollView::init()) { - setLayoutType(Type::VERTICAL); + setDirection(Direction::VERTICAL); return true; } return false; @@ -365,7 +365,7 @@ void ListView::removeAllItems() removeAllChildren(); } -Widget* ListView::getItem(ssize_t index)const +Widget* ListView::getItem(ssize_t index) const { if (index < 0 || index >= _items.size()) { @@ -748,7 +748,7 @@ static Vec2 calculateItemDestination(const Size& contentSize, Widget* item, cons return -(itemPosition - positionInView); } -void ListView::jumpToItem(int itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) +void ListView::jumpToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) { Widget* item = getItem(itemIndex); if (item == nullptr) @@ -765,12 +765,12 @@ void ListView::jumpToItem(int itemIndex, const Vec2& positionRatioInView, const moveChildrenToPosition(destination); } -void ListView::scrollToItem(int itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) +void ListView::scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) { scrollToItem(itemIndex, positionRatioInView, itemAnchorPoint, DEFAULT_TIME_IN_SEC_FOR_SCROLL_TO_ITEM); } -void ListView::scrollToItem(int itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint, float timeInSec) +void ListView::scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint, float timeInSec) { Widget* item = getItem(itemIndex); if (item == nullptr) @@ -847,7 +847,7 @@ Vec2 ListView::getHowMuchOutOfBoundary(const Vec2& addition) float topBoundary = _topBoundary; float bottomBoundary = _bottomBoundary; { - int lastItemIndex = _items.size() - 1; + ssize_t lastItemIndex = _items.size() - 1; Size contentSize = getContentSize(); Vec2 firstItemAdjustment, lastItemAdjustment; if(_magneticType == MagneticType::CENTER) diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index f37226a4e2..25978f13e5 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -172,8 +172,7 @@ public: * @param index A given index in ssize_t. */ void removeItem(ssize_t index); - - + /** * @brief Remove all items in current ListView. * @@ -326,7 +325,7 @@ public: * @param positionRatioInView Specifies the position with ratio in list view's content size. * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. */ - void jumpToItem(int itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint); + void jumpToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint); /** * @brief Scroll to specific item @@ -334,8 +333,8 @@ public: * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. * @param timeInSec Scroll time */ - void scrollToItem(int itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint); - void scrollToItem(int itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint, float timeInSec); + void scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint); + void scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint, float timeInSec); /** * @brief Query current selected widget's idnex. diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 770ea6a881..00af758c4b 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -31,16 +31,6 @@ namespace ui { IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): -_isAutoScrolling(false), -_autoScrollDistance(0.0f), -_autoScrollSpeed(0.0f), -_autoScrollDirection(AutoScrollDirection::LEFT), -_curPageIdx(-1), -_touchMoveDirection(TouchDirection::LEFT), -_leftBoundaryChild(nullptr), -_rightBoundaryChild(nullptr), -_leftBoundary(0.0f), -_rightBoundary(0.0f), _customScrollThreshold(0.0), _usingCustomScrollThreshold(false), _childFocusCancelOffset(5.0f), @@ -48,8 +38,6 @@ _pageViewEventListener(nullptr), _pageViewEventSelector(nullptr), _eventCallback(nullptr) { - this->setTouchEnabled(true); - setDirection(ScrollView::Direction::HORIZONTAL); } PageView::~PageView() @@ -70,20 +58,6 @@ PageView* PageView::create() return nullptr; } -void PageView::onEnter() -{ -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript) - { - if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter)) - return; - } -#endif - - ListView::onEnter(); - scheduleUpdate(); -} - bool PageView::init() { if (ListView::init()) @@ -98,478 +72,44 @@ bool PageView::init() void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate) { - if (!widget || pageIdx < 0) - { - return; - } - - ssize_t pageCount = this->getPageCount(); - if (pageIdx < 0 || pageIdx >= pageCount) - { - if (forceCreate) - { - if (pageIdx > pageCount) - { - CCLOG("pageIdx is %d, it will be added as page id [%d]",static_cast(pageIdx),static_cast(pageCount)); - } - Layout* newPage = createPage(); - newPage->addChild(widget); - addPage(newPage); - } - } - else - { - Node * page = _pages.at(pageIdx); - page->addChild(widget); - } -} - -Layout* PageView::createPage() -{ - Layout* newPage = Layout::create(); - newPage->setContentSize(getContentSize()); - return newPage; + insertCustomItem(widget, pageIdx); } void PageView::addPage(Layout* page) { - if (!page || _pages.contains(page)) - { - return; - } - - - addChild(page); - _pages.pushBack(page); - if (_curPageIdx == -1) - { - _curPageIdx = 0; - } - _doLayoutDirty = true; + pushBackCustomItem(page); } void PageView::insertPage(Layout* page, int idx) { - if (idx < 0 || !page || _pages.contains(page)) - { - return; - } - - - ssize_t pageCount = this->getPageCount(); - if (idx >= pageCount) - { - addPage(page); - } - else - { - _pages.insert(idx, page); - addChild(page); - if(_curPageIdx == -1) - { - _curPageIdx = 0; - } - } - - _doLayoutDirty = true; + insertCustomItem(page, idx); } - void PageView::removePage(Layout* page) { - if (!page) - { - return; - } - removeChild(page); - _pages.eraseObject(page); - auto pageCount = _pages.size(); - if (_curPageIdx >= pageCount) - { - _curPageIdx = pageCount - 1; - } - - _doLayoutDirty = true; + removeItem(getIndex(page)); } void PageView::removePageAtIndex(ssize_t index) { - if (index < 0 || index >= this->getPages().size()) - { - return; - } - Layout* page = _pages.at(index); - removePage(page); + removeItem(index); } void PageView::removeAllPages() { - for(const auto& node : _pages) - { - removeChild(node); - } - _pages.clear(); - _curPageIdx = -1; -} - -void PageView::updateBoundaryPages() -{ - if (_pages.size() <= 0) - { - _leftBoundaryChild = nullptr; - _rightBoundaryChild = nullptr; - return; - } - _leftBoundaryChild = _pages.at(0); - _rightBoundaryChild = _pages.at(this->getPageCount()-1); -} - -ssize_t PageView::getPageCount()const -{ - return _pages.size(); -} - -float PageView::getPositionXByIndex(ssize_t idx)const -{ - return (getContentSize().width * (idx-_curPageIdx)); -} - -float PageView::getPositionYByIndex(ssize_t idx)const -{ - return (getContentSize().height * (idx-_curPageIdx)); -} - -void PageView::onSizeChanged() -{ - ListView::onSizeChanged(); - if (_direction == Direction::HORIZONTAL) - { - _rightBoundary = getContentSize().width; - } - else - { - _rightBoundary = getContentSize().height; - } - - _doLayoutDirty = true; -} - -void PageView::updateAllPagesSize() -{ - Size selfSize = getContentSize(); - for (auto& page : _pages) - { - page->setContentSize(selfSize); - } -} - -void PageView::updateAllPagesPosition() -{ - ssize_t pageCount = this->getPageCount(); - - if (pageCount <= 0) - { - _curPageIdx = -1; - return; - } - - if (_curPageIdx >= pageCount) - { - _curPageIdx = pageCount-1; - } - // If the layout is dirty, don't trigger auto scroll - _isAutoScrolling = false; - - for (int i=0; isetPosition(newPosition); - } + removeAllItems(); } void PageView::setCurPageIndex( ssize_t index ) { - if (index < 0 || index >= this->getPageCount()) - { - return; - } - _curPageIdx = index; - _doLayoutDirty = true; + jumpToItem(index, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); } void PageView::scrollToPage(ssize_t idx) { - if (idx < 0 || idx >= this->getPageCount()) - { - return; - } - _curPageIdx = idx; - Layout* curPage = _pages.at(idx); - if (_direction == Direction::HORIZONTAL) - { - _autoScrollDistance = -(curPage->getPosition().x); - if (_autoScrollDistance > 0) - { - _autoScrollDirection = AutoScrollDirection::RIGHT; - } - else - { - _autoScrollDirection = AutoScrollDirection::LEFT; - } - } - else if(_direction == Direction::VERTICAL) - { - _autoScrollDistance = -curPage->getPosition().y; - if (_autoScrollDistance > 0) - { - _autoScrollDirection = AutoScrollDirection::DOWN; - } - else - { - _autoScrollDirection = AutoScrollDirection::UP; - } - } - _autoScrollSpeed = fabs(_autoScrollDistance)/0.2f; - _isAutoScrolling = true; + scrollToItem(idx, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); } -void PageView::update(float dt) -{ - if (_isAutoScrolling) - { - this->autoScroll(dt); - } -} - -void PageView::autoScroll(float dt) - { - float step = _autoScrollSpeed*dt; - int sign = 1; - switch (_autoScrollDirection) - { - case AutoScrollDirection::LEFT: - case AutoScrollDirection::UP: - { - if (_autoScrollDistance + step >= 0.0f) - { - step = -_autoScrollDistance; - _isAutoScrolling = false; - _autoScrollDistance = 0.0f; - } - else - { - _autoScrollDistance += step; - } - sign = -1; - break; - } - break; - case AutoScrollDirection::RIGHT: - case AutoScrollDirection::DOWN: - { - if (_autoScrollDistance - step <= 0.0f) - { - step = _autoScrollDistance; - _autoScrollDistance = 0.0f; - _isAutoScrolling = false; - } - else - { - _autoScrollDistance -= step; - } - break; - } - default: - break; - } - - if (_direction == Direction::HORIZONTAL) - { - scrollPages(Vec2(step * sign, 0)); - } - else - { - scrollPages(Vec2(0, step * sign)); - } - - if (!_isAutoScrolling) - { - pageTurningEvent(); - } - } - -bool PageView::onTouchBegan(Touch *touch, Event *unusedEvent) -{ - bool pass = ListView::onTouchBegan(touch, unusedEvent); - return pass; -} - -void PageView::onTouchMoved(Touch *touch, Event *unusedEvent) -{ - ListView::onTouchMoved(touch, unusedEvent); - if (!_isInterceptTouch) - { - handleMoveLogic(touch); - } -} - -void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) -{ - ListView::onTouchEnded(touch, unusedEvent); - if (!_isInterceptTouch) - { - handleReleaseLogic(touch); - } - _isInterceptTouch = false; -} - -void PageView::onTouchCancelled(Touch *touch, Event *unusedEvent) -{ - ListView::onTouchCancelled(touch, unusedEvent); - if (!_isInterceptTouch) - { - handleReleaseLogic(touch); - } - _isInterceptTouch = false; -} - -void PageView::doLayout() -{ - if (!_doLayoutDirty) - { - return; - } - - updateAllPagesPosition(); - updateAllPagesSize(); - updateBoundaryPages(); - - - _doLayoutDirty = false; -} - -void PageView::movePages(Vec2 offset) -{ - for (auto& page : this->getPages()) - { - Vec2 oldPosition = page->getPosition(); - page->setPosition(oldPosition + offset); - } -} - -bool PageView::scrollPages(Vec2 touchOffset) -{ - if (this->getPageCount() <= 0) - { - return false; - } - - if (!_leftBoundaryChild || !_rightBoundaryChild) - { - return false; - } - - Vec2 realOffset = touchOffset; - - switch (_touchMoveDirection) - { - case TouchDirection::LEFT: // left - if (_rightBoundaryChild->getRightBoundary() + touchOffset.x <= _rightBoundary) - { - realOffset.x = _rightBoundary - _rightBoundaryChild->getRightBoundary(); - realOffset.y = 0; - movePages(realOffset); - return false; - } - break; - - case TouchDirection::RIGHT: // right - if (_leftBoundaryChild->getLeftBoundary() + touchOffset.x >= _leftBoundary) - { - realOffset.x = _leftBoundary - _leftBoundaryChild->getLeftBoundary(); - realOffset.y = 0; - movePages(realOffset); - return false; - } - break; - case TouchDirection::UP: - { - if (_rightBoundaryChild->getBottomBoundary() + touchOffset.y >= _leftBoundary) - { - realOffset.y = _leftBoundary - _rightBoundaryChild->getBottomBoundary(); - realOffset.x = 0; - movePages(realOffset); - return false; - } - - }break; - case TouchDirection::DOWN: - { - if (_leftBoundaryChild->getTopBoundary() + touchOffset.y <= _rightBoundary) - { - realOffset.y = _rightBoundary - _leftBoundaryChild->getTopBoundary(); - realOffset.x = 0; - movePages(realOffset); - return false; - } - }break; - default: - break; - } - - movePages(realOffset); - return true; -} - - -void PageView::handleMoveLogic(Touch *touch) -{ - Vec2 touchPoint = touch->getLocation(); - - Vec2 offset; - offset = touchPoint - touch->getPreviousLocation(); - - if (_direction == Direction::HORIZONTAL) - { - if (offset.x < 0) - { - _touchMoveDirection = TouchDirection::LEFT; - } - else if (offset.x > 0) - { - _touchMoveDirection = TouchDirection::RIGHT; - } - offset.y = 0; - } - else - { - offset.x = 0; - if(offset.y > 0) - { - _touchMoveDirection = TouchDirection::UP; - } - else if(offset.y < 0) - { - _touchMoveDirection = TouchDirection::DOWN; - } - } - - scrollPages(offset); -} - void PageView::setCustomScrollThreshold(float threshold) { CCASSERT(threshold > 0, "Invalid threshold!"); @@ -594,149 +134,7 @@ bool PageView::isUsingCustomScrollThreshold()const void PageView::handleReleaseLogic(Touch *touch) { - if (this->getPageCount() <= 0) - { - return; - } - Widget* curPage = dynamic_cast(this->getPages().at(_curPageIdx)); - if (curPage) - { - Vec2 curPagePos = curPage->getPosition(); - ssize_t pageCount = this->getPageCount(); - - auto contentSize = getContentSize(); - - float moveBoundray = 0.0f; - float scrollDistance; - if (_direction == Direction::HORIZONTAL) - { - curPagePos.y = 0; - moveBoundray = curPagePos.x; - scrollDistance = contentSize.width / 2.0; - } - else if(_direction == Direction::VERTICAL) - { - curPagePos.x = 0; - moveBoundray = curPagePos.y; - scrollDistance = contentSize.height / 2.0; - } - - if (!_usingCustomScrollThreshold) - { - _customScrollThreshold = scrollDistance; - } - float boundary = _customScrollThreshold; - - if (_direction == Direction::HORIZONTAL) - { - if (moveBoundray <= -boundary) - { - if (_curPageIdx >= pageCount-1) - { - scrollPages(curPagePos); - } - else - { - scrollToPage(_curPageIdx+1); - } - } - else if (moveBoundray >= boundary) - { - if (_curPageIdx <= 0) - { - scrollPages(curPagePos); - } - else - { - scrollToPage(_curPageIdx-1); - } - } - else - { - scrollToPage(_curPageIdx); - } - } - else if(_direction == Direction::VERTICAL) - { - if (moveBoundray >= boundary) - { - if (_curPageIdx >= pageCount-1) - { - scrollPages(curPagePos); - } - else - { - scrollToPage(_curPageIdx+1); - } - } - else if (moveBoundray <= -boundary) - { - if (_curPageIdx <= 0) - { - scrollPages(curPagePos); - } - else - { - scrollToPage(_curPageIdx-1); - } - } - else - { - scrollToPage(_curPageIdx); - } - } - } -} - - -void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch *touch) -{ - if (!_touchEnabled) - { - ListView::interceptTouchEvent(event, sender, touch); - return; - } - Vec2 touchPoint = touch->getLocation(); - - switch (event) - { - case TouchEventType::BEGAN: - { - _touchBeganPosition = touch->getLocation(); - _isInterceptTouch = true; - } - break; - case TouchEventType::MOVED: - { - float offset = 0; - if (_direction == Direction::HORIZONTAL) - { - offset = fabs(sender->getTouchBeganPosition().x - touchPoint.x); - } - else if(_direction == Direction::VERTICAL) - { - offset = fabs(sender->getTouchBeganPosition().y - touchPoint.y); - } - _touchMovePosition = touch->getLocation(); - if (offset > _childFocusCancelOffset) - { - sender->setHighlighted(false); - handleMoveLogic(touch); - } - } - break; - case TouchEventType::CANCELED: - case TouchEventType::ENDED: - { - _touchEndPosition = touch->getLocation(); - handleReleaseLogic(touch); - if (sender->isSwallowTouches()) - { - _isInterceptTouch = false; - } - } - break; - } + ListView::handleReleaseLogic(touch); } void PageView::pageTurningEvent() @@ -770,21 +168,39 @@ void PageView::addEventListener(const ccPageViewCallback& callback) ssize_t PageView::getCurPageIndex() const { - return _curPageIdx; + Widget* widget = ListView::getCenterItemInCurrentView(); + return getIndex(widget); } Vector& PageView::getPages() { - return _pages; + CCASSERT(false, "This method is obsolete!"); + + // Temporary code to keep backward compatibility. + static Vector pages; + pages.clear(); + for(Widget* widget : getItems()) + { + pages.pushBack(dynamic_cast(widget)); + } + return pages; } - + Layout* PageView::getPage(ssize_t index) { if (index < 0 || index >= this->getPages().size()) { return nullptr; } - return _pages.at(index); + + // Temporary code to keep backward compatibility. + static Vector pages; + pages.clear(); + for(Widget* widget : getItems()) + { + pages.pushBack(dynamic_cast(widget)); + } + return pages.at(index); } std::string PageView::getDescription() const @@ -797,15 +213,6 @@ Widget* PageView::createCloneInstance() return PageView::create(); } -void PageView::copyClonedWidgetChildren(Widget* model) -{ - auto modelPages = static_cast(model)->getPages(); - for (auto& page : modelPages) - { - addPage(static_cast(page->clone())); - } -} - void PageView::copySpecialProperties(Widget *widget) { PageView* pageView = dynamic_cast(widget); diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 86f68c955d..1647bfeac4 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -84,7 +84,7 @@ public: /** * PageView page turn event callback. */ - typedef std::function ccPageViewCallback; + typedef std::function ccPageViewCallback; /** * Default constructor @@ -112,50 +112,63 @@ public: * @param widget Widget to be added to pageview. * @param pageIdx A given index. * @param forceCreate If `forceCreate` is true and `widget` isn't exists, pageview would create a default page and add it. + * + * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. */ - void addWidgetToPage(Widget* widget, ssize_t pageIdx, bool forceCreate); + CC_DEPRECATED_ATTRIBUTE void addWidgetToPage(Widget* widget, ssize_t pageIdx, bool forceCreate); /** * Insert a page into the end of PageView. * * @param page Page to be inserted. + * + * Since v3.9, this is deprecated. Use `ListView::pushBackCustomItem(Widget* item)` instead. */ - void addPage(Layout* page); + CC_DEPRECATED_ATTRIBUTE void addPage(Layout* page); /** * Insert a page into PageView at a given index. * * @param page Page to be inserted. * @param idx A given index. + * + * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. */ - void insertPage(Layout* page, int idx); + CC_DEPRECATED_ATTRIBUTE void insertPage(Layout* page, int idx); /** * Remove a page of PageView. * * @param page Page to be removed. - */ - void removePage(Layout* page); + * + * Since v3.9, this is deprecated. Use `ListView::removeItem(getIndex(item))` instead. + */ + CC_DEPRECATED_ATTRIBUTE void removePage(Layout* page); /** * Remove a page at a given index of PageView. * * @param index A given index. - */ - void removePageAtIndex(ssize_t index); + * + * Since v3.9, this is deprecated. Use `ListView::removeItem(ssize_t index)` instead. + */ + CC_DEPRECATED_ATTRIBUTE void removePageAtIndex(ssize_t index); /** * @brief Remove all pages of the PageView. - */ - void removeAllPages(); + * + * Since v3.9, this is deprecated. Use `ListView::removeAllItems()` instead. + */ + CC_DEPRECATED_ATTRIBUTE void removeAllPages(); /** * Scroll to a page with a given index. * * @param idx A given index in the PageView. Index start from 0 to pageCount -1. - */ - void scrollToPage(ssize_t idx); - + * + * Since v3.9, this is deprecated. Use `ListView::scrollToItem(ssize_t itemIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE)` instead. + */ + CC_DEPRECATED_ATTRIBUTE void scrollToPage(ssize_t idx); /** * Gets current displayed page index. @@ -168,23 +181,28 @@ public: * This is the different between scrollToPage. * * @param index A given index in PageView. Index start from 0 to pageCount -1. - */ - void setCurPageIndex(ssize_t index); - + * + * Since v3.9, this is deprecated. Use `ListView::jumpToItem(ssize_t itemIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE)` instead. + */ + CC_DEPRECATED_ATTRIBUTE void setCurPageIndex(ssize_t index); + /** * @brief Get all the pages in the PageView. * @return A vector of Layout pointers. - */ - Vector& getPages(); - - + * + * Since v3.9, this is obsolete. Use `Vector& ListView::getItems()` instead. + */ + CC_DEPRECATED_ATTRIBUTE Vector& getPages(); + /** * @brief Get a page at a given index * * @param index A given index. * @return A layout pointer in PageView container. - */ - Layout* getPage(ssize_t index); + * + * Since v3.9, this is obsolete. Use `Widget* ListView::getItem(index)` instead. + */ + CC_DEPRECATED_ATTRIBUTE Layout* getPage(ssize_t index); /** * Add a page turn callback to PageView, then when one page is turning, the callback will be called. @@ -203,18 +221,7 @@ public: void addEventListener(const ccPageViewCallback& callback); //override methods - virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; - virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; - virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; - virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override; - virtual void update(float dt) override; - virtual void setLayoutType(Type type) override{}; - virtual Type getLayoutType() const override{return Type::ABSOLUTE;}; virtual std::string getDescription() const override; - /** - * @lua NA - */ - virtual void onEnter() override; /** *@brief If you don't specify the value, the pageView will turn page when scrolling at the half width of a page. @@ -245,55 +252,14 @@ CC_CONSTRUCTOR_ACCESS: virtual bool init() override; protected: - - Layout* createPage(); - float getPositionXByIndex(ssize_t idx)const; - float getPositionYByIndex(ssize_t idx)const; - ssize_t getPageCount()const; - - void updateBoundaryPages(); - virtual bool scrollPages(Vec2 touchOffset); - void movePages(Vec2 offset); void pageTurningEvent(); - void updateAllPagesSize(); - void updateAllPagesPosition(); - void autoScroll(float dt); - virtual void handleMoveLogic(Touch *touch) ; - virtual void handleReleaseLogic(Touch *touch) ; - virtual void interceptTouchEvent(TouchEventType event, Widget* sender,Touch *touch) override; - - - virtual void onSizeChanged() override; + virtual void handleReleaseLogic(Touch *touch) override; + virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; - virtual void copyClonedWidgetChildren(Widget* model) override; - - virtual void doLayout() override; protected: - enum class AutoScrollDirection - { - LEFT, - RIGHT, - UP, - DOWN - }; - bool _isAutoScrolling; - float _autoScrollDistance; - float _autoScrollSpeed; - AutoScrollDirection _autoScrollDirection; - - ssize_t _curPageIdx; - Vector _pages; - - TouchDirection _touchMoveDirection; - - Widget* _leftBoundaryChild; - Widget* _rightBoundaryChild; - - float _leftBoundary; - float _rightBoundary; float _customScrollThreshold; bool _usingCustomScrollThreshold; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index d9882e8eae..cb6cf22144 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -6,6 +6,9 @@ using namespace cocos2d::ui; UIPageViewTests::UIPageViewTests() { + ADD_TEST_CASE(UIPageViewByListViewTest); + + ADD_TEST_CASE(UIPageViewTest); ADD_TEST_CASE(UIPageViewButtonTest); ADD_TEST_CASE(UIPageViewCustomScrollThreshold); @@ -57,7 +60,7 @@ bool UIPageViewTest::init() pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); - pageView->removeAllPages(); + pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) @@ -76,11 +79,11 @@ bool UIPageViewTest::init() label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); - pageView->insertPage(layout,i); + pageView->insertCustomItem(layout, i); } - pageView->removePageAtIndex(0); - pageView->scrollToPage(pageCount-2); + pageView->removeItem(0); + pageView->scrollToItem(pageCount - 2, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); pageView->addEventListener(CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this)); @@ -109,6 +112,73 @@ void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type) } +// UIPageViewByListViewTest +bool UIPageViewByListViewTest::init() +{ + if (!UIScene::init()) + { + return false; + } + + Size widgetSize = _widget->getContentSize(); + + // Add a label in which the dragpanel events will be displayed + auto label = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); + label->setAnchorPoint(Vec2(0.5f, -1.0f)); + label->setPosition(Vec2(widgetSize / 2) + Vec2(0, label->getContentSize().height * 1.5)); + _uiLayer->addChild(label); + + Layout* root = static_cast(_uiLayer->getChildByTag(81)); + Layout* background = dynamic_cast(root->getChildByName("background_Panel")); + + // Create the page view + Size size(240.0f, 130.0f); +// auto pageView = ListView::create(); + auto pageView = PageView::create(); + { + pageView->setDirection(ScrollView::Direction::HORIZONTAL); + pageView->setContentSize(size); + Size backgroundSize = background->getContentSize(); + pageView->setPosition((widgetSize - pageView->getContentSize()) / 2); + _uiLayer->addChild(pageView); + } + + int pageCount = 20; + for (int i = 0; i < pageCount; ++i) + { + Color3B color; + if(i % 3 == 0) + { + color = Color3B::WHITE; + } + else if(i % 3 == 1) + { + color = Color3B::YELLOW; + } + else if(i % 3 == 2) + { + color = Color3B::ORANGE; + } + + Layout* pLayout = Layout::create(); + pLayout->setContentSize(size); + pLayout->setBackGroundColorType(Layout::BackGroundColorType::SOLID); + pLayout->setBackGroundColor(color); + + Button *btn = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); + btn->setName(StringUtils::format("button %d", i)); + btn->setScale9Enabled(true); + btn->setContentSize(size); + btn->setPosition(size / 2); + pLayout->addChild(btn); + + pageView->pushBackCustomItem(pLayout); + } + return true; +} + + // UIPageViewButtonTest UIPageViewButtonTest::UIPageViewButtonTest() : _displayValueLabel(nullptr) @@ -126,7 +196,7 @@ bool UIPageViewButtonTest::init() { Size widgetSize = _widget->getContentSize(); - // Add a label in which the dragpanel events will be displayed + // Add a label in which the drag panel events will be displayed _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index ed2ccb4305..55b22ba3dc 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -37,14 +37,21 @@ public: UIPageViewTest(); ~UIPageViewTest(); virtual bool init() override; - + void pageViewEvent(cocos2d::Ref* sender, cocos2d::ui::PageView::EventType type); - + protected: - + cocos2d::ui::Text* _displayValueLabel; }; +class UIPageViewByListViewTest : public UIScene +{ +public: + CREATE_FUNC(UIPageViewByListViewTest); + virtual bool init() override; +}; + class UIPageViewButtonTest : public UIScene { public: From e67250e162ed97c0c39302fce358e47198256c35 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sat, 19 Sep 2015 22:42:14 +0900 Subject: [PATCH 013/192] ScrollView - Create `moveInnerContainer()` to replace `moveChildren()` and `moveChildrenToPosition()`. All move related logic will be integrated into one. --- cocos/ui/UIScrollView.cpp | 34 +++++++++++++++++----------------- cocos/ui/UIScrollView.h | 5 ++--- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 2cebcfb5df..de5883a0b2 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -319,18 +319,19 @@ Node* ScrollView::getChildByName(const std::string& name)const return _innerContainer->getChildByName(name); } -void ScrollView::moveChildren(float offsetX, float offsetY) +void ScrollView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack) { - Vec2 position = _innerContainer->getPosition() + Vec2(offsetX, offsetY); - moveChildrenToPosition(position); -} - -void ScrollView::moveChildrenToPosition(const Vec2& position) -{ - setInnerContainerPosition(position); - - Vec2 outOfBoundary = getHowMuchOutOfBoundary(Vec2::ZERO); + Vec2 adjustedMove = flattenVectorByDirection(deltaMove); + + setInnerContainerPosition(getInnerContainerPosition() + adjustedMove); + + Vec2 outOfBoundary = getHowMuchOutOfBoundary(); updateScrollBar(outOfBoundary); + + if(_bounceEnabled && canStartBounceBack) + { + startBounceBackIfNeeded(); + } } void ScrollView::updateScrollBar(const Vec2& outOfBoundary) @@ -352,7 +353,7 @@ Vec2 ScrollView::calculateTouchMoveVelocity() const { totalTime += timeDelta; } - if(totalTime == 0 || totalTime >= 0.1f) + if(totalTime == 0 || totalTime >= 0.5f) { return Vec2::ZERO; } @@ -553,15 +554,14 @@ void ScrollView::processAutoScrolling(float deltaTime) reachedEnd = true; } } - - moveChildrenToPosition(newPosition); - + // Finish auto scroll if it ended if(reachedEnd) { _autoScrolling = false; - startBounceBackIfNeeded(); } + + moveInnerContainer(newPosition - getInnerContainerPosition(), reachedEnd); } void ScrollView::jumpToDestination(const Vec2 &des) @@ -576,7 +576,7 @@ void ScrollView::jumpToDestination(const Vec2 &des) { finalOffsetX = MAX(des.x, _contentSize.width - _innerContainer->getContentSize().width); } - moveChildrenToPosition(Vec2(finalOffsetX, finalOffsetY)); + moveInnerContainer(Vec2(finalOffsetX, finalOffsetY) - getInnerContainerPosition(), true); } bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) @@ -646,7 +646,7 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) scrolledToLeft = true; } } - moveChildren(realOffsetX, realOffsetY); + moveInnerContainer(Vec2(realOffsetX, realOffsetY), false); if(realOffsetX != 0 || realOffsetY != 0) { diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index d2177c2d63..cf63f02a2d 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -569,9 +569,8 @@ protected: virtual Vec2 getHowMuchOutOfBoundary(const Vec2& addition = Vec2::ZERO); bool isOutOfBoundary(MoveDirection dir); bool isOutOfBoundary(); - - void moveChildren(float offsetX, float offsetY); - void moveChildrenToPosition(const Vec2& position); + + void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack); bool calculateCurrAndPrevTouchPoints(Touch* touch, Vec3* currPt, Vec3* prevPt); void gatherTouchMove(const Vec2& delta); From 30d39af5fa241a0742963fe1d9cc7bfdd2622135 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sat, 19 Sep 2015 23:16:36 +0900 Subject: [PATCH 014/192] Refactor `jumpTo` methods to use `moveInnerContainer()`. --- cocos/ui/UIListView.cpp | 12 +++++++----- cocos/ui/UIScrollView.cpp | 13 ++----------- cocos/ui/UIScrollView.h | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index 7cd55bacc5..a50804045c 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -758,11 +758,13 @@ void ListView::jumpToItem(ssize_t itemIndex, const Vec2& positionRatioInView, co doLayout(); Vec2 destination = calculateItemDestination(getContentSize(), item, positionRatioInView, itemAnchorPoint); - destination = flattenVectorByDirection(destination); - Vec2 delta = destination - getInnerContainerPosition(); - Vec2 outOfBoundary = getHowMuchOutOfBoundary(delta); - destination += outOfBoundary; - moveChildrenToPosition(destination); + if(!_bounceEnabled) + { + Vec2 delta = destination - getInnerContainerPosition(); + Vec2 outOfBoundary = getHowMuchOutOfBoundary(delta); + destination += outOfBoundary; + } + jumpToDestination(destination); } void ListView::scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index de5883a0b2..557a9dbbd2 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -566,17 +566,8 @@ void ScrollView::processAutoScrolling(float deltaTime) void ScrollView::jumpToDestination(const Vec2 &des) { - float finalOffsetX = des.x; - float finalOffsetY = des.y; - if (des.y <= 0 && _direction != Direction::HORIZONTAL) - { - finalOffsetY = MAX(des.y, _contentSize.height - _innerContainer->getContentSize().height); - } - if (des.x <= 0 && _direction != Direction::VERTICAL) - { - finalOffsetX = MAX(des.x, _contentSize.width - _innerContainer->getContentSize().width); - } - moveInnerContainer(Vec2(finalOffsetX, finalOffsetY) - getInnerContainerPosition(), true); + _autoScrolling = false; + moveInnerContainer(des - getInnerContainerPosition(), true); } bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index cf63f02a2d..9f4896485e 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -571,7 +571,7 @@ protected: bool isOutOfBoundary(); void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack); - + bool calculateCurrAndPrevTouchPoints(Touch* touch, Vec3* currPt, Vec3* prevPt); void gatherTouchMove(const Vec2& delta); Vec2 calculateTouchMoveVelocity() const; From 5de6aa78ec99f1fdd5c06a131d79be4c848af9ba Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 20 Sep 2015 08:57:59 +0900 Subject: [PATCH 015/192] ScrollView - Remove the return value of `scrollChildren()`. --- cocos/ui/UIScrollView.cpp | 6 +----- cocos/ui/UIScrollView.h | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 557a9dbbd2..51e49e9ade 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -570,7 +570,7 @@ void ScrollView::jumpToDestination(const Vec2 &des) moveInnerContainer(des - getInnerContainerPosition(), true); } -bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) +void ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) { touchOffsetX = (_direction == Direction::VERTICAL ? 0 : touchOffsetX); touchOffsetY = (_direction == Direction::HORIZONTAL ? 0 : touchOffsetY); @@ -659,10 +659,6 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) { processScrollEvent(MoveDirection::RIGHT, false); } - - bool scrollEnabledUpDown = (!scrolledToBottom && !scrolledToTop); - bool scrollEnabledLeftRight = (!scrolledToLeft && !scrolledToRight); - return scrollEnabledUpDown || scrollEnabledLeftRight; } void ScrollView::scrollToBottom(float timeInSec, bool attenuated) diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 9f4896485e..912b447a9a 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -588,7 +588,7 @@ protected: void jumpToDestination(const Vec2& des); - virtual bool scrollChildren(float touchOffsetX, float touchOffsetY); + virtual void scrollChildren(float touchOffsetX, float touchOffsetY); virtual void handlePressLogic(Touch *touch); virtual void handleMoveLogic(Touch *touch); From 84d0625b9330d4fc43eaa4aa4c731d1326bf79cd Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 20 Sep 2015 09:01:10 +0900 Subject: [PATCH 016/192] ScrollView - Remove redundant codes. --- cocos/ui/UIScrollView.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 51e49e9ade..ae86a34056 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -176,23 +176,6 @@ void ScrollView::setInnerContainerSize(const Size &size) } _innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight)); - // move children appropriately - { - Size newInnerSize = _innerContainer->getContentSize(); - float offsetY = originalInnerSize.height - newInnerSize.height; - float offsetX = 0; - if (_innerContainer->getRightBoundary() <= _contentSize.width) - { - offsetX = originalInnerSize.width - newInnerSize.width; - } - if(offsetX != 0 || offsetY != 0) - { - Vec2 position = _innerContainer->getPosition() + Vec2(offsetX, offsetY); - setInnerContainerPosition(position); - } - } - - // Calculate and set the position of the inner container. Vec2 pos = _innerContainer->getPosition(); if (_innerContainer->getLeftBoundary() > 0.0f) From 46c0a43105ee71e6f3986612a73e9b82aaa2fd7b Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 20 Sep 2015 09:14:13 +0900 Subject: [PATCH 017/192] ScrollView - Use a vector in `scrollChildren()` instead of two floats. --- cocos/ui/UIScrollView.cpp | 47 ++++++++++++++------------------------- cocos/ui/UIScrollView.h | 2 +- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index ae86a34056..d2238966f4 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -553,76 +553,63 @@ void ScrollView::jumpToDestination(const Vec2 &des) moveInnerContainer(des - getInnerContainerPosition(), true); } -void ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) +void ScrollView::scrollChildren(const Vec2& deltaMove) { - touchOffsetX = (_direction == Direction::VERTICAL ? 0 : touchOffsetX); - touchOffsetY = (_direction == Direction::HORIZONTAL ? 0 : touchOffsetY); + Vec2 realMove = deltaMove; if(_bounceEnabled) { // If the position of the inner container is out of the boundary, the offsets should be divided by two. Vec2 outOfBoundary = getHowMuchOutOfBoundary(); - touchOffsetX *= (outOfBoundary.x == 0 ? 1 : 0.5f); - touchOffsetY *= (outOfBoundary.y == 0 ? 1 : 0.5f); + realMove.x *= (outOfBoundary.x == 0 ? 1 : 0.5f); + realMove.y *= (outOfBoundary.y == 0 ? 1 : 0.5f); } - float realOffsetX = touchOffsetX; - float realOffsetY = touchOffsetY; - if(!_bounceEnabled) { - Vec2 outOfBoundary = getHowMuchOutOfBoundary(Vec2(realOffsetX, realOffsetY)); - realOffsetX += outOfBoundary.x; - realOffsetY += outOfBoundary.y; + Vec2 outOfBoundary = getHowMuchOutOfBoundary(realMove); + realMove += outOfBoundary; } bool scrolledToLeft = false; bool scrolledToRight = false; bool scrolledToTop = false; bool scrolledToBottom = false; - if (realOffsetY > 0.0f) // up + if (realMove.y > 0.0f) // up { float icBottomPos = _innerContainer->getBottomBoundary(); - if (icBottomPos + realOffsetY >= _bottomBoundary) + if (icBottomPos + realMove.y >= _bottomBoundary) { scrolledToBottom = true; } } - else if (realOffsetY < 0.0f) // down + else if (realMove.y < 0.0f) // down { float icTopPos = _innerContainer->getTopBoundary(); - if (icTopPos + realOffsetY <= _topBoundary) + if (icTopPos + realMove.y <= _topBoundary) { scrolledToTop = true; } } - if (realOffsetX < 0.0f) // left + if (realMove.x < 0.0f) // left { float icRightPos = _innerContainer->getRightBoundary(); - if (icRightPos + realOffsetX <= _rightBoundary) + if (icRightPos + realMove.x <= _rightBoundary) { - if(!_bounceEnabled) - { - realOffsetX = _rightBoundary - icRightPos; - } scrolledToRight = true; } } - else if (realOffsetX > 0.0f) // right + else if (realMove.x > 0.0f) // right { float icLeftPos = _innerContainer->getLeftBoundary(); - if (icLeftPos + realOffsetX >= _leftBoundary) + if (icLeftPos + realMove.x >= _leftBoundary) { - if(!_bounceEnabled) - { - realOffsetX = _leftBoundary - icLeftPos; - } scrolledToLeft = true; } } - moveInnerContainer(Vec2(realOffsetX, realOffsetY), false); + moveInnerContainer(realMove, false); - if(realOffsetX != 0 || realOffsetY != 0) + if(realMove.x != 0 || realMove.y != 0) { processScrollingEvent(); } @@ -875,7 +862,7 @@ void ScrollView::handleMoveLogic(Touch *touch) } Vec3 delta3 = currPt - prevPt; Vec2 delta(delta3.x, delta3.y); - scrollChildren(delta.x, delta.y); + scrollChildren(delta); // Gather touch move information for speed calculation gatherTouchMove(delta); diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 912b447a9a..839fac3c1f 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -588,7 +588,7 @@ protected: void jumpToDestination(const Vec2& des); - virtual void scrollChildren(float touchOffsetX, float touchOffsetY); + virtual void scrollChildren(const Vec2& deltaMove); virtual void handlePressLogic(Touch *touch); virtual void handleMoveLogic(Touch *touch); From b9a4449494346185005d640e81164ad33d1858f6 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 20 Sep 2015 15:55:24 +0900 Subject: [PATCH 018/192] PageView - Add `handleReleaseLogic()` for page view. --- cocos/ui/UIPageView.cpp | 26 ++++++- .../UIPageViewTest/UIPageViewTest.cpp | 77 +------------------ .../UIPageViewTest/UIPageViewTest.h | 7 -- 3 files changed, 29 insertions(+), 81 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 00af758c4b..e2bc62eaa2 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -134,7 +134,31 @@ bool PageView::isUsingCustomScrollThreshold()const void PageView::handleReleaseLogic(Touch *touch) { - ListView::handleReleaseLogic(touch); + // Use `ScrollView` method instead of `ListView` to + ScrollView::handleReleaseLogic(touch); + + static const float THRESHOLD = 5000; + Vec2 touchMoveVelocity = flattenVectorByDirection(calculateTouchMoveVelocity()); + CCLOG("handleReleaseLogic() touchMoveVelocity.length()=%.2f", touchMoveVelocity.length()); + if(touchMoveVelocity.length() < THRESHOLD) + { + startMagneticScroll(); + } + else + { + ssize_t currentIndex = getIndex(getCenterItemInCurrentView()); + if(touchMoveVelocity.x < 0 || touchMoveVelocity.y > 0) + { + ++currentIndex; + } + else + { + --currentIndex; + } + currentIndex = MIN(currentIndex, _items.size()); + currentIndex = MAX(currentIndex, 0); + scrollToItem(currentIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); + } } void PageView::pageTurningEvent() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index cb6cf22144..f96c071f49 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -6,9 +6,6 @@ using namespace cocos2d::ui; UIPageViewTests::UIPageViewTests() { - ADD_TEST_CASE(UIPageViewByListViewTest); - - ADD_TEST_CASE(UIPageViewTest); ADD_TEST_CASE(UIPageViewButtonTest); ADD_TEST_CASE(UIPageViewCustomScrollThreshold); @@ -55,9 +52,10 @@ bool UIPageViewTest::init() Layout* background = dynamic_cast(root->getChildByName("background_Panel")); // Create the page view + Size size(240, 130); PageView* pageView = PageView::create(); pageView->setDirection(PageView::Direction::HORIZONTAL); - pageView->setContentSize(Size(240.0f, 130.0f)); + pageView->setContentSize(size); Size backgroundSize = background->getContentSize(); pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); pageView->removeAllItems(); @@ -66,11 +64,11 @@ bool UIPageViewTest::init() for (int i = 0; i < pageCount; ++i) { Layout* layout = Layout::create(); - layout->setContentSize(Size(240.0f, 130.0f)); + layout->setContentSize(size); ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); - imageView->setContentSize(Size(240, 130)); + imageView->setContentSize(size); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); @@ -112,73 +110,6 @@ void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type) } -// UIPageViewByListViewTest -bool UIPageViewByListViewTest::init() -{ - if (!UIScene::init()) - { - return false; - } - - Size widgetSize = _widget->getContentSize(); - - // Add a label in which the dragpanel events will be displayed - auto label = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); - label->setAnchorPoint(Vec2(0.5f, -1.0f)); - label->setPosition(Vec2(widgetSize / 2) + Vec2(0, label->getContentSize().height * 1.5)); - _uiLayer->addChild(label); - - Layout* root = static_cast(_uiLayer->getChildByTag(81)); - Layout* background = dynamic_cast(root->getChildByName("background_Panel")); - - // Create the page view - Size size(240.0f, 130.0f); -// auto pageView = ListView::create(); - auto pageView = PageView::create(); - { - pageView->setDirection(ScrollView::Direction::HORIZONTAL); - pageView->setContentSize(size); - Size backgroundSize = background->getContentSize(); - pageView->setPosition((widgetSize - pageView->getContentSize()) / 2); - _uiLayer->addChild(pageView); - } - - int pageCount = 20; - for (int i = 0; i < pageCount; ++i) - { - Color3B color; - if(i % 3 == 0) - { - color = Color3B::WHITE; - } - else if(i % 3 == 1) - { - color = Color3B::YELLOW; - } - else if(i % 3 == 2) - { - color = Color3B::ORANGE; - } - - Layout* pLayout = Layout::create(); - pLayout->setContentSize(size); - pLayout->setBackGroundColorType(Layout::BackGroundColorType::SOLID); - pLayout->setBackGroundColor(color); - - Button *btn = Button::create("cocosui/animationbuttonnormal.png", - "cocosui/animationbuttonpressed.png"); - btn->setName(StringUtils::format("button %d", i)); - btn->setScale9Enabled(true); - btn->setContentSize(size); - btn->setPosition(size / 2); - pLayout->addChild(btn); - - pageView->pushBackCustomItem(pLayout); - } - return true; -} - - // UIPageViewButtonTest UIPageViewButtonTest::UIPageViewButtonTest() : _displayValueLabel(nullptr) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 55b22ba3dc..3354bf8cb5 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -45,13 +45,6 @@ protected: cocos2d::ui::Text* _displayValueLabel; }; -class UIPageViewByListViewTest : public UIScene -{ -public: - CREATE_FUNC(UIPageViewByListViewTest); - virtual bool init() override; -}; - class UIPageViewButtonTest : public UIScene { public: From a2bc0d4859d63c836f871b072659f423a35e2cd4 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 20 Sep 2015 23:39:41 +0900 Subject: [PATCH 019/192] ScrollViewBar - Change wording in comment. --- cocos/ui/UIScrollViewBar.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UIScrollViewBar.h b/cocos/ui/UIScrollViewBar.h index 8b466466da..f0120a04f8 100644 --- a/cocos/ui/UIScrollViewBar.h +++ b/cocos/ui/UIScrollViewBar.h @@ -59,8 +59,8 @@ public: virtual ~ScrollViewBar(); /** - * Create a ScrollView with its parent ScrollView and direction. - * @return A ScrollViewBar instance. + * Create a scroll bar with its parent scroll view and direction. + * @return A scroll bar instance. */ static ScrollViewBar* create(ScrollView* parent, ScrollView::Direction direction); From 76acb91861de4bcf0411649304575bc52e92cab5 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 16:31:01 +0900 Subject: [PATCH 020/192] Move `createSpriteFromBase64()` from `UIScrollViewBar.cpp` to `ccUtils.h` in order to use it in other places. --- cocos/base/ccUtils.cpp | 23 +++++++++++++++++++++++ cocos/base/ccUtils.h | 10 ++++++++++ cocos/ui/UIScrollViewBar.cpp | 27 +++------------------------ 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/cocos/base/ccUtils.cpp b/cocos/base/ccUtils.cpp index c303472d5f..9a9e1304ae 100644 --- a/cocos/base/ccUtils.cpp +++ b/cocos/base/ccUtils.cpp @@ -30,10 +30,12 @@ THE SOFTWARE. #include "base/CCDirector.h" #include "base/CCAsyncTaskPool.h" #include "base/CCEventDispatcher.h" +#include "base/base64.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCRenderer.h" #include "platform/CCImage.h" #include "platform/CCFileUtils.h" +#include "2d/CCSprite.h" NS_CC_BEGIN @@ -263,7 +265,28 @@ Rect getCascadeBoundingBox(Node *node) return cbb; } + +Sprite* createSpriteFromBase64(const char* base64String) +{ + unsigned char* decoded; + int length = base64Decode((const unsigned char*) base64String, (unsigned int) strlen(base64String), &decoded); + + Image *image = new Image(); + bool imageResult = image->initWithImageData(decoded, length); + CCASSERT(imageResult, "Failed to create image from base64!"); + free(decoded); + + Texture2D *texture = new Texture2D(); + texture->initWithImage(image); + texture->setAliasTexParameters(); + image->release(); + + Sprite* sprite = Sprite::createWithTexture(texture); + texture->release(); + return sprite; +} + } NS_CC_END diff --git a/cocos/base/ccUtils.h b/cocos/base/ccUtils.h index 4740f17240..eb7aee6d6f 100644 --- a/cocos/base/ccUtils.h +++ b/cocos/base/ccUtils.h @@ -52,6 +52,8 @@ Examples: int ccNextPOT(int value); +class Sprite; + namespace utils { /** Capture the entire screen. @@ -100,6 +102,14 @@ namespace utils * @return Returns unionof bounding box of a node and its children. */ Rect CC_DLL getCascadeBoundingBox(Node *node); + + /** + * Create a sprite instance from base64 encoded image. + + * @return Returns an instance of sprite + */ + Sprite* CC_DLL createSpriteFromBase64(const char* base64String); + } NS_CC_END diff --git a/cocos/ui/UIScrollViewBar.cpp b/cocos/ui/UIScrollViewBar.cpp index d4682d9451..7d4be10d7a 100644 --- a/cocos/ui/UIScrollViewBar.cpp +++ b/cocos/ui/UIScrollViewBar.cpp @@ -25,7 +25,7 @@ THE SOFTWARE. #include "UIScrollViewBar.h" #include "CCImage.h" #include "2d/CCSprite.h" -#include "base/base64.h" +#include "base/ccUtils.h" NS_CC_BEGIN @@ -39,27 +39,6 @@ static const float DEFAULT_MARGIN = 20; static const float DEFAULT_AUTO_HIDE_TIME = 0.2f; static const float DEFAULT_SCROLLBAR_OPACITY = 0.4f; -static Sprite* createSpriteFromBase64(const char* base64String) -{ - unsigned char* decoded; - int length = base64Decode((const unsigned char*) base64String, (unsigned int) strlen(base64String), &decoded); - - Image *image = new Image(); - bool imageResult = image->initWithImageData(decoded, length); - CCASSERT(imageResult, "Failed to create image from base64!"); - free(decoded); - - Texture2D *texture = new Texture2D(); - texture->initWithImage(image); - texture->setAliasTexParameters(); - image->release(); - - Sprite* sprite = Sprite::createWithTexture(texture); - texture->release(); - - return sprite; -} - ScrollViewBar::ScrollViewBar(ScrollView* parent, ScrollView::Direction direction): _parent(parent), _direction(direction), @@ -103,7 +82,7 @@ bool ScrollViewBar::init() return false; } - _upperHalfCircle = createSpriteFromBase64(HALF_CIRCLE_IMAGE); + _upperHalfCircle = utils::createSpriteFromBase64(HALF_CIRCLE_IMAGE); _upperHalfCircle->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM); addProtectedChild(_upperHalfCircle); @@ -112,7 +91,7 @@ bool ScrollViewBar::init() _lowerHalfCircle->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM); addProtectedChild(_lowerHalfCircle); - _body = createSpriteFromBase64(BODY_IMAGE_1_PIXEL_HEIGHT); + _body = utils::createSpriteFromBase64(BODY_IMAGE_1_PIXEL_HEIGHT); _body->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM); addProtectedChild(_body); From 30e2e46f20b7ada10fe99d7695deae5bcf1028cd Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 20 Sep 2015 21:29:11 +0900 Subject: [PATCH 021/192] PageView - Add `PageViewIndicator` which indicates current page among total pages. --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 +++++ cocos/ui/UIPageViewIndicator.cpp | 43 +++++++++++++++++ cocos/ui/UIPageViewIndicator.h | 50 ++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 cocos/ui/UIPageViewIndicator.cpp create mode 100644 cocos/ui/UIPageViewIndicator.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 398c2b04af..ff1db71763 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -2068,6 +2068,10 @@ B5668D7E1B3838E4003CBD5E /* UIScrollViewBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5668D7B1B3838E4003CBD5E /* UIScrollViewBar.cpp */; }; B5668D7F1B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; }; B5668D801B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; }; + B5A738961BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; settings = {ASSET_TAGS = (); }; }; + B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; settings = {ASSET_TAGS = (); }; }; + B5A738981BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; settings = {ASSET_TAGS = (); }; }; + B5A738991BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; settings = {ASSET_TAGS = (); }; }; B5CE6DBE1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; }; B5CE6DBF1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; }; B5CE6DC01B3BF2B1002B0419 /* UIAbstractCheckButton.h in Headers */ = {isa = PBXBuildFile; fileRef = B5CE6DBD1B3BF2B1002B0419 /* UIAbstractCheckButton.h */; }; @@ -4799,6 +4803,8 @@ B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = ""; }; B5668D7B1B3838E4003CBD5E /* UIScrollViewBar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScrollViewBar.cpp; sourceTree = ""; }; B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollViewBar.h; sourceTree = ""; }; + B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIPageViewIndicator.cpp; sourceTree = ""; }; + B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIPageViewIndicator.h; sourceTree = ""; }; B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIAbstractCheckButton.cpp; sourceTree = ""; }; B5CE6DBD1B3BF2B1002B0419 /* UIAbstractCheckButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIAbstractCheckButton.h; sourceTree = ""; }; B5CE6DC61B3C05BA002B0419 /* UIRadioButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIRadioButton.cpp; sourceTree = ""; }; @@ -6956,6 +6962,8 @@ 2905FA0118CF08D000240AA3 /* UILoadingBar.h */, 2905FA0218CF08D000240AA3 /* UIPageView.cpp */, 2905FA0318CF08D000240AA3 /* UIPageView.h */, + B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */, + B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */, 2905FA0418CF08D000240AA3 /* UIRichText.cpp */, 2905FA0518CF08D000240AA3 /* UIRichText.h */, 2905FA0718CF08D000240AA3 /* UIScrollView.cpp */, @@ -9464,6 +9472,7 @@ B665E3F41AA80A6600DDB1C5 /* CCPUSlaveEmitter.h in Headers */, 15AE1B6919AADA9900C27E9E /* UIDeprecated.h in Headers */, 1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, + B5A738981BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */, B6CAB53F1AF9AA1A00B9B856 /* cl_platform.h in Headers */, 15AE1A8319AAD40300C27E9E /* b2GearJoint.h in Headers */, 15AE1BD519AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */, @@ -10966,6 +10975,7 @@ B665E2951AA80A6500DDB1C5 /* CCPUEmitter.h in Headers */, B6CAB3BE1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.h in Headers */, B6CAB3521AF9AA1A00B9B856 /* gim_geometry.h in Headers */, + B5A738991BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */, 15AE1BED19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */, 15AE195019AAD35100C27E9E /* CCDatas.h in Headers */, 15AE18B319AAD33D00C27E9E /* CCBReader.h in Headers */, @@ -11151,6 +11161,7 @@ ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */, 15AE1A2C19AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */, B665E36A1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.cpp in Sources */, + B5A738961BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */, B665E3961AA80A6500DDB1C5 /* CCPUPointEmitter.cpp in Sources */, 15AE184019AAD2F700C27E9E /* CCSprite3D.cpp in Sources */, B6CAB2E51AF9AA1A00B9B856 /* btSphereShape.cpp in Sources */, @@ -12625,6 +12636,7 @@ B665E1FB1AA80A6500DDB1C5 /* CCPUAffectorTranslator.cpp in Sources */, B665E3931AA80A6500DDB1C5 /* CCPUPlaneColliderTranslator.cpp in Sources */, 382383F71A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */, + B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */, B665E24B1AA80A6500DDB1C5 /* CCPUColorAffector.cpp in Sources */, B665E20F1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */, 15AE1B7419AADA9A00C27E9E /* UILoadingBar.cpp in Sources */, diff --git a/cocos/ui/UIPageViewIndicator.cpp b/cocos/ui/UIPageViewIndicator.cpp new file mode 100644 index 0000000000..ce8cc639b7 --- /dev/null +++ b/cocos/ui/UIPageViewIndicator.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +Copyright (c) 2015 Neo Kim (neo.kim@neofect.com) + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#include "UIPageViewIndicator.h" + +NS_CC_BEGIN + +namespace ui { + +UIPageViewIndicator::UIPageViewIndicator() +{ + +} + +UIPageViewIndicator::~UIPageViewIndicator() +{ + +} + +} + +NS_CC_END diff --git a/cocos/ui/UIPageViewIndicator.h b/cocos/ui/UIPageViewIndicator.h new file mode 100644 index 0000000000..bf7e8d85e5 --- /dev/null +++ b/cocos/ui/UIPageViewIndicator.h @@ -0,0 +1,50 @@ +/**************************************************************************** +Copyright (c) 2015 Neo Kim (neo.kim@neofect.com) + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#ifndef __UIPAGEVIEWINDICATOR_H__ +#define __UIPAGEVIEWINDICATOR_H__ + +NS_CC_BEGIN +/** + * @addtogroup ui + * @{ + */ + +namespace ui { + +class UIPageViewIndicator +{ + +public: + UIPageViewIndicator(); + virtual ~UIPageViewIndicator(); + +}; + +} +// end of ui group +/// @} +NS_CC_END + +#endif /* defined(__UIPAGEVIEWINDICATOR_H__) */ From 0ee09fcfcecc9761ddab1372e56cf144a6f17427 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 16:50:18 +0900 Subject: [PATCH 022/192] PageView - Implement the page indicator --- cocos/ui/UIPageView.cpp | 11 +++ cocos/ui/UIPageView.h | 5 ++ cocos/ui/UIPageViewIndicator.cpp | 113 ++++++++++++++++++++++++++++++- cocos/ui/UIPageViewIndicator.h | 28 +++++++- 4 files changed, 152 insertions(+), 5 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index e2bc62eaa2..17c9870eb7 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "ui/UIPageView.h" +#include "ui/UIPageViewIndicator.h" NS_CC_BEGIN @@ -31,6 +32,7 @@ namespace ui { IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): +_indicator(nullptr), _customScrollThreshold(0.0), _usingCustomScrollThreshold(false), _childFocusCancelOffset(5.0f), @@ -62,6 +64,9 @@ bool PageView::init() { if (ListView::init()) { + _indicator = PageViewIndicator::create(); + addProtectedChild(_indicator); + setDirection(ListView::Direction::HORIZONTAL); setMagneticType(MagneticType::CENTER); setScrollBarEnabled(false); @@ -132,6 +137,12 @@ bool PageView::isUsingCustomScrollThreshold()const return _usingCustomScrollThreshold; } +void PageView::onSizeChanged() +{ + ListView::onSizeChanged(); + _indicator->setPosition(getContentSize() / 2); +} + void PageView::handleReleaseLogic(Touch *touch) { // Use `ScrollView` method instead of `ListView` to diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 1647bfeac4..8c26ad7fe5 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -36,6 +36,8 @@ NS_CC_BEGIN namespace ui { +class PageViewIndicator; + /** *PageView page turn event type. *@deprecated Use `PageView::EventType` instead. @@ -254,12 +256,15 @@ CC_CONSTRUCTOR_ACCESS: protected: void pageTurningEvent(); + virtual void onSizeChanged() override; virtual void handleReleaseLogic(Touch *touch) override; virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: + PageViewIndicator* _indicator; + float _customScrollThreshold; bool _usingCustomScrollThreshold; diff --git a/cocos/ui/UIPageViewIndicator.cpp b/cocos/ui/UIPageViewIndicator.cpp index ce8cc639b7..ad51eea6d6 100644 --- a/cocos/ui/UIPageViewIndicator.cpp +++ b/cocos/ui/UIPageViewIndicator.cpp @@ -23,19 +23,128 @@ THE SOFTWARE. ****************************************************************************/ #include "UIPageViewIndicator.h" +#include "2d/CCSprite.h" +#include "base/ccUtils.h" + +static const char* CIRCLE_IMAGE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAATlBMVEX///////////////////////////////////////////////////////////////////////////////////////////////////////+QPFRFAAAAGXRSTlMAFBYXUFVWf4GEhYjNz9DR0u/x8vP09fj+spJk/AAAAGFJREFUeNptzkkOgCAMQNGCgoAToEz3v6iVNNoY364/aQF+CbOltEwCyBhaF0aaayO1FxHbI95bpjEOw8qDx1B4KN9wYti/K5aHGYNkzx4SkHo/pqDTJ13UQAbrc/ZugD8XjW0OTSlBlOwAAAAASUVORK5CYII="; NS_CC_BEGIN +static const float SPACE_BETWEEN_INDEX_NODES_DEFAULT = 23; + namespace ui { -UIPageViewIndicator::UIPageViewIndicator() +PageViewIndicator* PageViewIndicator::create() { + PageViewIndicator* node = new (std::nothrow) PageViewIndicator(); + if (node && node->init()) + { + node->autorelease(); + return node; + } + CC_SAFE_DELETE(node); + return nullptr; +} + +PageViewIndicator::PageViewIndicator() +: _currentIndexNode(nullptr) +, _spaceBetweenIndexNodes(SPACE_BETWEEN_INDEX_NODES_DEFAULT) +{ +} + +PageViewIndicator::~PageViewIndicator() +{ +} + +bool PageViewIndicator::init() +{ + _currentIndexNode = (Node*) utils::createSpriteFromBase64(CIRCLE_IMAGE); + _currentIndexNode->setVisible(false); + addProtectedChild(_currentIndexNode); + return true; +} + +void PageViewIndicator::indicate(int index) +{ + CCASSERT(index >= 0 && index < _indexNodes.size(), ""); + _currentIndexNode->setPosition(_indexNodes.at(index)->getPosition()); +} + +void PageViewIndicator::rearrange() +{ + if(_indexNodes.empty()) + { + return; + } + +// bool bHorizon = m_eContainerDirection == CONTAINER_HORIZONTAL; + bool horizontal = true; + + // Positions + Size indexNodeSize = _indexNodes.at(0)->getContentSize(); + float sizeValue = (horizontal ? indexNodeSize.width : indexNodeSize.height); + + float posValue = -sizeValue / 2; + for(auto indexNode : _indexNodes) { + posValue += sizeValue + _spaceBetweenIndexNodes; + Vec2 position; + if(horizontal) + { + position = Vec2(posValue, indexNodeSize.height / 2.0f); + } + else + { + position = Vec2(indexNodeSize.width / 2.0f, posValue); + } + indexNode->setPosition(position); + } } -UIPageViewIndicator::~UIPageViewIndicator() +void PageViewIndicator::setSpaceBetweenIndexNodes(float spaceBetweenIndexNodes) { + if(_spaceBetweenIndexNodes == spaceBetweenIndexNodes) + { + return; + } + _spaceBetweenIndexNodes = spaceBetweenIndexNodes; + rearrange(); +} +void PageViewIndicator::increaseNumberOfPages() +{ + Sprite* indexNode = utils::createSpriteFromBase64(CIRCLE_IMAGE); + indexNode->setOpacity(255 * 0.3f); + addProtectedChild(indexNode); + _indexNodes.pushBack(indexNode); + rearrange(); + + if(_indexNodes.size() == 1) { + _currentIndexNode->setVisible(true); + indicate(0); + } +} + +void PageViewIndicator::decreaseNumberOfPages() +{ + (*(_indexNodes.end() - 1))->removeFromParent(); + _indexNodes.erase(_indexNodes.end() - 1); + rearrange(); + + if(_indexNodes.empty()) + { + _currentIndexNode->setVisible(false); + } +} + +void PageViewIndicator::clear() +{ + for(auto indexNode : _indexNodes) + { + removeProtectedChild(indexNode); + } + _indexNodes.clear(); + _currentIndexNode->setVisible(false); } } diff --git a/cocos/ui/UIPageViewIndicator.h b/cocos/ui/UIPageViewIndicator.h index bf7e8d85e5..66b1f0d12e 100644 --- a/cocos/ui/UIPageViewIndicator.h +++ b/cocos/ui/UIPageViewIndicator.h @@ -25,6 +25,8 @@ THE SOFTWARE. #ifndef __UIPAGEVIEWINDICATOR_H__ #define __UIPAGEVIEWINDICATOR_H__ +#include "2d/CCProtectedNode.h" + NS_CC_BEGIN /** * @addtogroup ui @@ -33,12 +35,32 @@ NS_CC_BEGIN namespace ui { -class UIPageViewIndicator +class PageViewIndicator : public ProtectedNode { public: - UIPageViewIndicator(); - virtual ~UIPageViewIndicator(); + /** + * Create a page view indicator with its parent page view. + * @return A page view indicator instance. + */ + static PageViewIndicator* create(); + + PageViewIndicator(); + virtual ~PageViewIndicator(); + + void indicate(int index); + void increaseNumberOfPages(); + void decreaseNumberOfPages(); + void clear(); + void setSpaceBetweenIndexNodes(float fSpaceBetweenIndexNodes); + +protected: + bool init() override; + void rearrange(); + + Vector _indexNodes; + Node* _currentIndexNode; + float _spaceBetweenIndexNodes; }; From 4dbfb791107a85c7955926ae080868ac734139e4 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 19:40:30 +0900 Subject: [PATCH 023/192] Add `onItemListChanged()`method. --- cocos/ui/UIListView.cpp | 19 ++++++++++++------- cocos/ui/UIListView.h | 4 +++- cocos/ui/UIPageView.cpp | 7 +++++++ cocos/ui/UIPageView.h | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index a50804045c..b08ee6f751 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -100,6 +100,11 @@ void ListView::handleReleaseLogic(Touch *touch) } } +void ListView::onItemListChanged() +{ + _outOfBoundaryAmountDirty = true; +} + void ListView::updateInnerContainerSize() { switch (_direction) @@ -263,7 +268,7 @@ void ListView::addChild(cocos2d::Node *child, int zOrder, int tag) if (nullptr != widget) { _items.pushBack(widget); - _outOfBoundaryAmountDirty = true; + onItemListChanged(); } } @@ -285,7 +290,7 @@ void ListView::addChild(Node* child, int zOrder, const std::string &name) if (nullptr != widget) { _items.pushBack(widget); - _outOfBoundaryAmountDirty = true; + onItemListChanged(); } } @@ -307,7 +312,7 @@ void ListView::removeChild(cocos2d::Node *child, bool cleaup) } } _items.eraseObject(widget); - _outOfBoundaryAmountDirty = true; + onItemListChanged(); } ScrollView::removeChild(child, cleaup); @@ -321,9 +326,9 @@ void ListView::removeAllChildren() void ListView::removeAllChildrenWithCleanup(bool cleanup) { ScrollView::removeAllChildrenWithCleanup(cleanup); - _items.clear(); _curSelectedIndex = -1; - _outOfBoundaryAmountDirty = true; + _items.clear(); + onItemListChanged(); } void ListView::insertCustomItem(Widget* item, ssize_t index) @@ -336,8 +341,8 @@ void ListView::insertCustomItem(Widget* item, ssize_t index) } } _items.insert(index, item); - _outOfBoundaryAmountDirty = true; - + onItemListChanged(); + ScrollView::addChild(item); remedyLayoutParameter(item); diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 25978f13e5..3acfd20da8 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -387,7 +387,9 @@ CC_CONSTRUCTOR_ACCESS: protected: virtual void handleReleaseLogic(Touch *touch) override; - + + virtual void onItemListChanged(); + void updateInnerContainerSize(); void remedyLayoutParameter(Widget* item); void remedyVerticalLayoutParameter(LinearLayoutParameter* layoutParameter, ssize_t itemIndex); diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 17c9870eb7..fa241ee05c 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -137,6 +137,13 @@ bool PageView::isUsingCustomScrollThreshold()const return _usingCustomScrollThreshold; } +void PageView::onItemListChanged() +{ + ListView::onItemListChanged(); + ssize_t index = getIndex(getCenterItemInCurrentView()); + _indicator->reset(_items.size(), index); +} + void PageView::onSizeChanged() { ListView::onSizeChanged(); diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 8c26ad7fe5..a7343a13aa 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -256,6 +256,7 @@ CC_CONSTRUCTOR_ACCESS: protected: void pageTurningEvent(); + virtual void onItemListChanged() override; virtual void onSizeChanged() override; virtual void handleReleaseLogic(Touch *touch) override; From c684016ee6875dd895c104fd8b97ad2e7b774971 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 19:42:48 +0900 Subject: [PATCH 024/192] PageView - Implementing page view indicator --- cocos/ui/UIPageView.cpp | 4 +-- cocos/ui/UIPageViewIndicator.cpp | 45 ++++++++++++++++++++------------ cocos/ui/UIPageViewIndicator.h | 7 ++--- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index fa241ee05c..7a43f0fcfc 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -65,7 +65,7 @@ bool PageView::init() if (ListView::init()) { _indicator = PageViewIndicator::create(); - addProtectedChild(_indicator); + addProtectedChild(_indicator, 10000); setDirection(ListView::Direction::HORIZONTAL); setMagneticType(MagneticType::CENTER); @@ -147,7 +147,7 @@ void PageView::onItemListChanged() void PageView::onSizeChanged() { ListView::onSizeChanged(); - _indicator->setPosition(getContentSize() / 2); + _indicator->setPosition(Vec2(getContentSize() / 2) + Vec2(0, -50)); } void PageView::handleReleaseLogic(Touch *touch) diff --git a/cocos/ui/UIPageViewIndicator.cpp b/cocos/ui/UIPageViewIndicator.cpp index ad51eea6d6..900b21fa6d 100644 --- a/cocos/ui/UIPageViewIndicator.cpp +++ b/cocos/ui/UIPageViewIndicator.cpp @@ -64,9 +64,27 @@ bool PageViewIndicator::init() return true; } -void PageViewIndicator::indicate(int index) +void PageViewIndicator::reset(ssize_t numberOfTotalPages, ssize_t currentIndex) { - CCASSERT(index >= 0 && index < _indexNodes.size(), ""); + while(_indexNodes.size() < numberOfTotalPages) + { + increaseNumberOfPages(); + } + while(_indexNodes.size() > numberOfTotalPages) + { + decreaseNumberOfPages(); + } + rearrange(); + indicate(currentIndex); + _currentIndexNode->setVisible(!_indexNodes.empty()); +} + +void PageViewIndicator::indicate(ssize_t index) +{ + if (index < 0 || index >= _indexNodes.size()) + { + return; + } _currentIndexNode->setPosition(_indexNodes.at(index)->getPosition()); } @@ -80,13 +98,15 @@ void PageViewIndicator::rearrange() // bool bHorizon = m_eContainerDirection == CONTAINER_HORIZONTAL; bool horizontal = true; - // Positions + // Calculate total size Size indexNodeSize = _indexNodes.at(0)->getContentSize(); float sizeValue = (horizontal ? indexNodeSize.width : indexNodeSize.height); - float posValue = -sizeValue / 2; + ssize_t numberOfItems = _indexNodes.size(); + float totalSizeValue = sizeValue * numberOfItems + _spaceBetweenIndexNodes * (numberOfItems - 1); + + float posValue = -(totalSizeValue / 2) + (sizeValue / 2); for(auto indexNode : _indexNodes) { - posValue += sizeValue + _spaceBetweenIndexNodes; Vec2 position; if(horizontal) { @@ -97,6 +117,7 @@ void PageViewIndicator::rearrange() position = Vec2(indexNodeSize.width / 2.0f, posValue); } indexNode->setPosition(position); + posValue += sizeValue + _spaceBetweenIndexNodes; } } @@ -117,24 +138,16 @@ void PageViewIndicator::increaseNumberOfPages() indexNode->setOpacity(255 * 0.3f); addProtectedChild(indexNode); _indexNodes.pushBack(indexNode); - rearrange(); - - if(_indexNodes.size() == 1) { - _currentIndexNode->setVisible(true); - indicate(0); - } } void PageViewIndicator::decreaseNumberOfPages() { - (*(_indexNodes.end() - 1))->removeFromParent(); - _indexNodes.erase(_indexNodes.end() - 1); - rearrange(); - if(_indexNodes.empty()) { - _currentIndexNode->setVisible(false); + return; } + removeProtectedChild(*_indexNodes.begin()); + _indexNodes.erase(_indexNodes.begin()); } void PageViewIndicator::clear() diff --git a/cocos/ui/UIPageViewIndicator.h b/cocos/ui/UIPageViewIndicator.h index 66b1f0d12e..20beb26be0 100644 --- a/cocos/ui/UIPageViewIndicator.h +++ b/cocos/ui/UIPageViewIndicator.h @@ -48,14 +48,15 @@ public: PageViewIndicator(); virtual ~PageViewIndicator(); - void indicate(int index); - void increaseNumberOfPages(); - void decreaseNumberOfPages(); + void reset(ssize_t numberOfTotalPages, ssize_t currentIndex); + void indicate(ssize_t index); void clear(); void setSpaceBetweenIndexNodes(float fSpaceBetweenIndexNodes); protected: bool init() override; + void increaseNumberOfPages(); + void decreaseNumberOfPages(); void rearrange(); Vector _indexNodes; From b3f33de07161d9d81c9dd7692508dfaee7f224bb Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 21:44:49 +0900 Subject: [PATCH 025/192] ListView - Change `calculateItemDestination()` to a class method. --- cocos/ui/UIListView.cpp | 7 ++++--- cocos/ui/UIListView.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index b08ee6f751..96795f7cbc 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -743,8 +743,9 @@ void ListView::jumpToPercentBothDirection(const Vec2& percent) ScrollView::jumpToPercentBothDirection(percent); } -static Vec2 calculateItemDestination(const Size& contentSize, Widget* item, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) +Vec2 ListView::calculateItemDestination(const Vec2& positionRatioInView, Widget* item, const Vec2& itemAnchorPoint) { + const Size& contentSize = getContentSize(); Vec2 positionInView; positionInView.x += contentSize.width * positionRatioInView.x; positionInView.y += contentSize.height * positionRatioInView.y; @@ -762,7 +763,7 @@ void ListView::jumpToItem(ssize_t itemIndex, const Vec2& positionRatioInView, co } doLayout(); - Vec2 destination = calculateItemDestination(getContentSize(), item, positionRatioInView, itemAnchorPoint); + Vec2 destination = calculateItemDestination(positionRatioInView, item, itemAnchorPoint); if(!_bounceEnabled) { Vec2 delta = destination - getInnerContainerPosition(); @@ -784,7 +785,7 @@ void ListView::scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, { return; } - Vec2 destination = calculateItemDestination(getContentSize(), item, positionRatioInView, itemAnchorPoint); + Vec2 destination = calculateItemDestination(positionRatioInView, item, itemAnchorPoint); startAutoScrollToDestination(destination, timeInSec, true); } diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 3acfd20da8..09d5313099 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -407,6 +407,7 @@ protected: virtual void startAttenuatingAutoScroll(const Vec2& deltaMove, const Vec2& initialVelocity) override; void startMagneticScroll(); + Vec2 calculateItemDestination(const Vec2& positionRatioInView, Widget* item, const Vec2& itemAnchorPoint); protected: Widget* _model; From b19ed5a3b5cdb44c001acafa4929aa48d186cf51 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 21:45:22 +0900 Subject: [PATCH 026/192] ScrollView - Change `moveInnerContainer()` to virtual method. --- cocos/ui/UIScrollView.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 839fac3c1f..01edbdaea9 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -570,7 +570,7 @@ protected: bool isOutOfBoundary(MoveDirection dir); bool isOutOfBoundary(); - void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack); + virtual void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack); bool calculateCurrAndPrevTouchPoints(Touch* touch, Vec3* currPt, Vec3* prevPt); void gatherTouchMove(const Vec2& delta); From fc0fe976f724ddc31fede6bcc9948c7bad7560de Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 21:46:10 +0900 Subject: [PATCH 027/192] PageView - Complete `handleReleaseLogic()` method. --- cocos/ui/UIPageView.cpp | 51 +++++++++++++++++++++++++++++++++-------- cocos/ui/UIPageView.h | 25 +++++++++++++++++--- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 7a43f0fcfc..a29b503dd9 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -33,6 +33,7 @@ IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): _indicator(nullptr), +_currentPageIndex(-1), _customScrollThreshold(0.0), _usingCustomScrollThreshold(false), _childFocusCancelOffset(5.0f), @@ -107,7 +108,12 @@ void PageView::removeAllPages() void PageView::setCurPageIndex( ssize_t index ) { - jumpToItem(index, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); + setCurrentPageIndex(index); +} + +void PageView::setCurrentPageIndex(ssize_t index) +{ + jumpToItem(index, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); } void PageView::scrollToPage(ssize_t idx) @@ -137,6 +143,13 @@ bool PageView::isUsingCustomScrollThreshold()const return _usingCustomScrollThreshold; } +void PageView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack) +{ + ListView::moveInnerContainer(deltaMove, canStartBounceBack); + _currentPageIndex = getIndex(getCenterItemInCurrentView()); + _indicator->indicate(_currentPageIndex); +} + void PageView::onItemListChanged() { ListView::onItemListChanged(); @@ -152,11 +165,17 @@ void PageView::onSizeChanged() void PageView::handleReleaseLogic(Touch *touch) { - // Use `ScrollView` method instead of `ListView` to + // Use `ScrollView` method in order to avoid `startMagneticScroll()` by `ListView`. ScrollView::handleReleaseLogic(touch); - static const float THRESHOLD = 5000; + if(_items.empty()) + { + return; + } + Vec2 touchMoveVelocity = flattenVectorByDirection(calculateTouchMoveVelocity()); + + static const float THRESHOLD = 500; CCLOG("handleReleaseLogic() touchMoveVelocity.length()=%.2f", touchMoveVelocity.length()); if(touchMoveVelocity.length() < THRESHOLD) { @@ -164,18 +183,30 @@ void PageView::handleReleaseLogic(Touch *touch) } else { - ssize_t currentIndex = getIndex(getCenterItemInCurrentView()); - if(touchMoveVelocity.x < 0 || touchMoveVelocity.y > 0) + Widget* currentPage = getItem(_currentPageIndex); + Vec2 destination = calculateItemDestination(Vec2::ANCHOR_MIDDLE, currentPage, Vec2::ANCHOR_MIDDLE); + Vec2 deltaToCurrentpage; + deltaToCurrentpage = destination - getInnerContainerPosition(); + deltaToCurrentpage = flattenVectorByDirection(deltaToCurrentpage); + + if(touchMoveVelocity.x * deltaToCurrentpage.x > 0 || touchMoveVelocity.y * deltaToCurrentpage.y > 0) { - ++currentIndex; + startMagneticScroll(); } else { - --currentIndex; + if(touchMoveVelocity.x < 0 || touchMoveVelocity.y > 0) + { + ++_currentPageIndex; + } + else + { + --_currentPageIndex; + } + _currentPageIndex = MIN(_currentPageIndex, _items.size()); + _currentPageIndex = MAX(_currentPageIndex, 0); + scrollToItem(_currentPageIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); } - currentIndex = MIN(currentIndex, _items.size()); - currentIndex = MAX(currentIndex, 0); - scrollToItem(currentIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); } } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index a7343a13aa..a6dadae26f 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -175,8 +175,16 @@ public: /** * Gets current displayed page index. * @return current page index. + * + * Since v3.9, this is deprecated. Use `getCurrentPageIndex()` instead. */ - ssize_t getCurPageIndex() const; + CC_DEPRECATED_ATTRIBUTE ssize_t getCurPageIndex() const; + + /** + * Gets current displayed page index. + * @return current page index. + */ + ssize_t getCurrentPageIndex() const { return _currentPageIndex; } /** * Jump to a page with a given index without scrolling. @@ -184,9 +192,17 @@ public: * * @param index A given index in PageView. Index start from 0 to pageCount -1. * - * Since v3.9, this is deprecated. Use `ListView::jumpToItem(ssize_t itemIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE)` instead. + * Since v3.9, this is deprecated. Use `setCurrentPageIndex()` instead. */ - CC_DEPRECATED_ATTRIBUTE void setCurPageIndex(ssize_t index); + CC_DEPRECATED_ATTRIBUTE void setCurPageIndex(ssize_t index); + + /** + * Jump to a page with a given index without scrolling. + * This is the different between scrollToPage. + * + * @param index A given index in PageView. Index start from 0 to pageCount -1. + */ + void setCurrentPageIndex(ssize_t index); /** * @brief Get all the pages in the PageView. @@ -256,6 +272,7 @@ CC_CONSTRUCTOR_ACCESS: protected: void pageTurningEvent(); + virtual void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack) override; virtual void onItemListChanged() override; virtual void onSizeChanged() override; virtual void handleReleaseLogic(Touch *touch) override; @@ -266,6 +283,8 @@ protected: protected: PageViewIndicator* _indicator; + ssize_t _currentPageIndex; + float _customScrollThreshold; bool _usingCustomScrollThreshold; From 368a3048c44a8698f1bac263e658c50f7bd9b337 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 22:03:05 +0900 Subject: [PATCH 028/192] PageView - Add `setIndicatorPosition()`. --- cocos/ui/UIPageView.cpp | 37 ++++++++++++++++++++++++++++++++++++- cocos/ui/UIPageView.h | 11 +++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index a29b503dd9..b641d90b72 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -33,6 +33,7 @@ IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): _indicator(nullptr), +_indicatorPositionAsAnchorPoint(Vec2::ANCHOR_MIDDLE), _currentPageIndex(-1), _customScrollThreshold(0.0), _usingCustomScrollThreshold(false), @@ -69,6 +70,8 @@ bool PageView::init() addProtectedChild(_indicator, 10000); setDirection(ListView::Direction::HORIZONTAL); + _indicatorPositionAsAnchorPoint = Vec2(0.5f, 0.1f); + setMagneticType(MagneticType::CENTER); setScrollBarEnabled(false); return true; @@ -160,7 +163,15 @@ void PageView::onItemListChanged() void PageView::onSizeChanged() { ListView::onSizeChanged(); - _indicator->setPosition(Vec2(getContentSize() / 2) + Vec2(0, -50)); + refreshIndicatorPosition(); +} + +void PageView::refreshIndicatorPosition() +{ + const Size& contentSize = getContentSize(); + float posX = contentSize.width * _indicatorPositionAsAnchorPoint.x; + float posY = contentSize.height * _indicatorPositionAsAnchorPoint.y; + _indicator->setPosition(Vec2(posX, posY)); } void PageView::handleReleaseLogic(Touch *touch) @@ -301,6 +312,30 @@ void PageView::copySpecialProperties(Widget *widget) } } +void PageView::setIndicatorPositionAsAnchorPoint(const Vec2& positionAsAnchorPoint) +{ + _indicatorPositionAsAnchorPoint = positionAsAnchorPoint; + refreshIndicatorPosition(); +} + +const Vec2& PageView::getIndicatorPositionAsAnchorPoint() const +{ + return _indicatorPositionAsAnchorPoint; +} + +void PageView::setIndicatorPosition(const Vec2& position) +{ + const Size& contentSize = getContentSize(); + _indicatorPositionAsAnchorPoint.x = position.x / contentSize.width; + _indicatorPositionAsAnchorPoint.y = position.y / contentSize.height; + _indicator->setPosition(position); +} + +const Vec2& PageView::getIndicatorPosition() const +{ + return _indicator->getPosition(); +} + } NS_CC_END diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index a6dadae26f..492e1c0a14 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -241,6 +241,14 @@ public: //override methods virtual std::string getDescription() const override; + + void setIndicatorPositionAsAnchorPoint(const Vec2& positionAsAnchorPoint); + const Vec2& getIndicatorPositionAsAnchorPoint() const; + + void setIndicatorPosition(const Vec2& position); + const Vec2& getIndicatorPosition() const; + + /** *@brief If you don't specify the value, the pageView will turn page when scrolling at the half width of a page. *@param threshold A threshold in float. @@ -280,8 +288,11 @@ protected: virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + void refreshIndicatorPosition(); + protected: PageViewIndicator* _indicator; + Vec2 _indicatorPositionAsAnchorPoint; ssize_t _currentPageIndex; From eefdffc032bd0c17d9944ba037b3fda19ec9a9b2 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 22:11:42 +0900 Subject: [PATCH 029/192] PageViewIndicator - Add `setDirection()` method. --- cocos/ui/UIPageViewIndicator.cpp | 12 +++++++++--- cocos/ui/UIPageViewIndicator.h | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cocos/ui/UIPageViewIndicator.cpp b/cocos/ui/UIPageViewIndicator.cpp index 900b21fa6d..c468b02a4e 100644 --- a/cocos/ui/UIPageViewIndicator.cpp +++ b/cocos/ui/UIPageViewIndicator.cpp @@ -47,7 +47,8 @@ PageViewIndicator* PageViewIndicator::create() } PageViewIndicator::PageViewIndicator() -: _currentIndexNode(nullptr) +: _direction(PageView::Direction::HORIZONTAL) +, _currentIndexNode(nullptr) , _spaceBetweenIndexNodes(SPACE_BETWEEN_INDEX_NODES_DEFAULT) { } @@ -64,6 +65,12 @@ bool PageViewIndicator::init() return true; } +void PageViewIndicator::setDirection(PageView::Direction direction) +{ + _direction = direction; + rearrange(); +} + void PageViewIndicator::reset(ssize_t numberOfTotalPages, ssize_t currentIndex) { while(_indexNodes.size() < numberOfTotalPages) @@ -95,8 +102,7 @@ void PageViewIndicator::rearrange() return; } -// bool bHorizon = m_eContainerDirection == CONTAINER_HORIZONTAL; - bool horizontal = true; + bool horizontal = (_direction == PageView::Direction::HORIZONTAL); // Calculate total size Size indexNodeSize = _indexNodes.at(0)->getContentSize(); diff --git a/cocos/ui/UIPageViewIndicator.h b/cocos/ui/UIPageViewIndicator.h index 20beb26be0..f68300301c 100644 --- a/cocos/ui/UIPageViewIndicator.h +++ b/cocos/ui/UIPageViewIndicator.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __UIPAGEVIEWINDICATOR_H__ #define __UIPAGEVIEWINDICATOR_H__ -#include "2d/CCProtectedNode.h" +#include "UIPageView.h" NS_CC_BEGIN /** @@ -48,6 +48,7 @@ public: PageViewIndicator(); virtual ~PageViewIndicator(); + void setDirection(PageView::Direction direction); void reset(ssize_t numberOfTotalPages, ssize_t currentIndex); void indicate(ssize_t index); void clear(); @@ -59,6 +60,7 @@ protected: void decreaseNumberOfPages(); void rearrange(); + PageView::Direction _direction; Vector _indexNodes; Node* _currentIndexNode; float _spaceBetweenIndexNodes; From 1897051664db68933ae9fe895f82232b12e90609 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 22:12:25 +0900 Subject: [PATCH 030/192] PageView - Add `setDirection()` and `setIndicatorEnabled()` methods. --- cocos/ui/UIPageView.cpp | 26 +++++++++++++++++++++++--- cocos/ui/UIPageView.h | 13 ++++++++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index b641d90b72..3cb44460e3 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -32,6 +32,7 @@ namespace ui { IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): +_indicatorEnabled(false), _indicator(nullptr), _indicatorPositionAsAnchorPoint(Vec2::ANCHOR_MIDDLE), _currentPageIndex(-1), @@ -69,9 +70,7 @@ bool PageView::init() _indicator = PageViewIndicator::create(); addProtectedChild(_indicator, 10000); - setDirection(ListView::Direction::HORIZONTAL); - _indicatorPositionAsAnchorPoint = Vec2(0.5f, 0.1f); - + setDirection(Direction::HORIZONTAL); setMagneticType(MagneticType::CENTER); setScrollBarEnabled(false); return true; @@ -79,6 +78,21 @@ bool PageView::init() return false; } +void PageView::setDirection(PageView::Direction direction) +{ + ListView::setDirection(direction); + if(direction == Direction::HORIZONTAL) + { + _indicatorPositionAsAnchorPoint = Vec2(0.5f, 0.1f); + } + else if(direction == Direction::VERTICAL) + { + _indicatorPositionAsAnchorPoint = Vec2(0.1f, 0.5f); + } + _indicator->setDirection(direction); + refreshIndicatorPosition(); +} + void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate) { insertCustomItem(widget, pageIdx); @@ -312,6 +326,12 @@ void PageView::copySpecialProperties(Widget *widget) } } +void PageView::setIndicatorEnabled(bool enabled) +{ + _indicatorEnabled = enabled; + _indicator->setVisible(_indicatorEnabled); +} + void PageView::setIndicatorPositionAsAnchorPoint(const Vec2& positionAsAnchorPoint) { _indicatorPositionAsAnchorPoint = positionAsAnchorPoint; diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 492e1c0a14..1d89bdf6b5 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -107,7 +107,14 @@ public: *@return A PageView instance. */ static PageView* create(); - + + /** + * Changes direction + * Direction Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll. + * @param direction Set the page view's scroll direction. + */ + virtual void setDirection(Direction direction) override; + /** * Add a widget as a page of PageView in a given index. * @@ -241,6 +248,9 @@ public: //override methods virtual std::string getDescription() const override; + void setIndicatorEnabled(bool enabled); + + bool getIndicatorEnabled() const { return _indicatorEnabled; } void setIndicatorPositionAsAnchorPoint(const Vec2& positionAsAnchorPoint); const Vec2& getIndicatorPositionAsAnchorPoint() const; @@ -291,6 +301,7 @@ protected: void refreshIndicatorPosition(); protected: + bool _indicatorEnabled; PageViewIndicator* _indicator; Vec2 _indicatorPositionAsAnchorPoint; From 2d2d17172cb85d76d57bd65624e7d89fb6486c98 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 22:20:36 +0900 Subject: [PATCH 031/192] PageViewIndicator - Fix that indexes were upside down in vertical view. --- cocos/ui/UIPageViewIndicator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIPageViewIndicator.cpp b/cocos/ui/UIPageViewIndicator.cpp index c468b02a4e..81b56db5b4 100644 --- a/cocos/ui/UIPageViewIndicator.cpp +++ b/cocos/ui/UIPageViewIndicator.cpp @@ -120,7 +120,7 @@ void PageViewIndicator::rearrange() } else { - position = Vec2(indexNodeSize.width / 2.0f, posValue); + position = Vec2(indexNodeSize.width / 2.0f, -posValue); } indexNode->setPosition(position); posValue += sizeValue + _spaceBetweenIndexNodes; From 8abd1ab600441c6a07a7ea88a96d7a244e633940 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 21 Sep 2015 22:21:28 +0900 Subject: [PATCH 032/192] PageView - The indicator should be created before `ListView::init()` --- cocos/ui/UIPageView.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 3cb44460e3..ed2bfc64dc 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -34,7 +34,7 @@ IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): _indicatorEnabled(false), _indicator(nullptr), -_indicatorPositionAsAnchorPoint(Vec2::ANCHOR_MIDDLE), +_indicatorPositionAsAnchorPoint(Vec2(0.5f, 0.1f)), _currentPageIndex(-1), _customScrollThreshold(0.0), _usingCustomScrollThreshold(false), @@ -65,11 +65,11 @@ PageView* PageView::create() bool PageView::init() { + _indicator = PageViewIndicator::create(); + addProtectedChild(_indicator, 10000); + if (ListView::init()) { - _indicator = PageViewIndicator::create(); - addProtectedChild(_indicator, 10000); - setDirection(Direction::HORIZONTAL); setMagneticType(MagneticType::CENTER); setScrollBarEnabled(false); @@ -200,9 +200,8 @@ void PageView::handleReleaseLogic(Touch *touch) Vec2 touchMoveVelocity = flattenVectorByDirection(calculateTouchMoveVelocity()); - static const float THRESHOLD = 500; - CCLOG("handleReleaseLogic() touchMoveVelocity.length()=%.2f", touchMoveVelocity.length()); - if(touchMoveVelocity.length() < THRESHOLD) + static const float DEFAULT_THRESHOLD = 500; + if(touchMoveVelocity.length() < DEFAULT_THRESHOLD) { startMagneticScroll(); } From e3fcd6722acb88fcfa8fabecf30ffa42d2dd1894 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Tue, 22 Sep 2015 11:06:18 +0900 Subject: [PATCH 033/192] PageViewIndicator - Add some getter and setters. --- cocos/ui/UIPageView.cpp | 20 ++++++++++++++++++++ cocos/ui/UIPageView.h | 7 ++++++- cocos/ui/UIPageViewIndicator.cpp | 6 +++--- cocos/ui/UIPageViewIndicator.h | 5 ++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index ed2bfc64dc..f06f0001ef 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -355,6 +355,26 @@ const Vec2& PageView::getIndicatorPosition() const return _indicator->getPosition(); } +void PageView::setIndicatorSpaceBetweenIndexNodes(float spaceBetweenIndexNodes) +{ + _indicator->setSpaceBetweenIndexNodes(spaceBetweenIndexNodes); +} +float PageView::getIndicatorSpaceBetweenIndexNodes() const +{ + return _indicator->getSpaceBetweenIndexNodes(); +} + +void PageView::setIndicatorSelectedIndexColor(const Color3B& color) +{ + _indicator->setSelectedIndexColor(color); +} + +const Color3B& PageView::getIndicatorSelectedIndexColor() const +{ + return _indicator->getSelectedIndexColor(); +} + + } NS_CC_END diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 1d89bdf6b5..2eba7771b0 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -258,8 +258,13 @@ public: void setIndicatorPosition(const Vec2& position); const Vec2& getIndicatorPosition() const; + void setIndicatorSpaceBetweenIndexNodes(float spaceBetweenIndexNodes); + float getIndicatorSpaceBetweenIndexNodes() const; - /** + void setIndicatorSelectedIndexColor(const Color3B& color); + const Color3B& getIndicatorSelectedIndexColor() const; + + /** *@brief If you don't specify the value, the pageView will turn page when scrolling at the half width of a page. *@param threshold A threshold in float. */ diff --git a/cocos/ui/UIPageViewIndicator.cpp b/cocos/ui/UIPageViewIndicator.cpp index 81b56db5b4..1389a3002a 100644 --- a/cocos/ui/UIPageViewIndicator.cpp +++ b/cocos/ui/UIPageViewIndicator.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include "2d/CCSprite.h" #include "base/ccUtils.h" -static const char* CIRCLE_IMAGE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAATlBMVEX///////////////////////////////////////////////////////////////////////////////////////////////////////+QPFRFAAAAGXRSTlMAFBYXUFVWf4GEhYjNz9DR0u/x8vP09fj+spJk/AAAAGFJREFUeNptzkkOgCAMQNGCgoAToEz3v6iVNNoY364/aQF+CbOltEwCyBhaF0aaayO1FxHbI95bpjEOw8qDx1B4KN9wYti/K5aHGYNkzx4SkHo/pqDTJ13UQAbrc/ZugD8XjW0OTSlBlOwAAAAASUVORK5CYII="; +static const char* CIRCLE_IMAGE = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAA8ElEQVRIx62VyRGCQBBF+6gWRCEmYDIQkhiBCgHhSclC8YqWzOV5oVzKAYZp3r1/9fpbxAIBMTsKrjx5cqVgR0wgLhCRUWOjJiPqD56xoaGPhpRZV/iSEy6crHmw5oIrF9b/lVeMofrJgjlnxlIy/wik+JB+mme8BExbBhm+5CJC2LE2LtSEQoyGWDioBA5CoRIohJtK4CYDxzNEM4GAugR1E9VjVC+SZpXvhCJCrjomESLvc17pDGX7bWmlh6UtpjPVCWy9zaJ0TD7qfm3pwERMz2trRVZk3K3BD/L34AY+dEDCniMVBkPFkT2J/b2/AIV+dRpFLOYoAAAAAElFTkSuQmCC"; NS_CC_BEGIN @@ -61,7 +61,7 @@ bool PageViewIndicator::init() { _currentIndexNode = (Node*) utils::createSpriteFromBase64(CIRCLE_IMAGE); _currentIndexNode->setVisible(false); - addProtectedChild(_currentIndexNode); + addProtectedChild(_currentIndexNode, 1); return true; } @@ -141,7 +141,7 @@ void PageViewIndicator::setSpaceBetweenIndexNodes(float spaceBetweenIndexNodes) void PageViewIndicator::increaseNumberOfPages() { Sprite* indexNode = utils::createSpriteFromBase64(CIRCLE_IMAGE); - indexNode->setOpacity(255 * 0.3f); +// indexNode->setOpacity(255 * 0.3f); addProtectedChild(indexNode); _indexNodes.pushBack(indexNode); } diff --git a/cocos/ui/UIPageViewIndicator.h b/cocos/ui/UIPageViewIndicator.h index f68300301c..c72688bd2e 100644 --- a/cocos/ui/UIPageViewIndicator.h +++ b/cocos/ui/UIPageViewIndicator.h @@ -52,7 +52,10 @@ public: void reset(ssize_t numberOfTotalPages, ssize_t currentIndex); void indicate(ssize_t index); void clear(); - void setSpaceBetweenIndexNodes(float fSpaceBetweenIndexNodes); + void setSpaceBetweenIndexNodes(float spaceBetweenIndexNodes); + float getSpaceBetweenIndexNodes() const { return _spaceBetweenIndexNodes; } + void setSelectedIndexColor(const Color3B& color) { _currentIndexNode->setColor(color); } + const Color3B& getSelectedIndexColor() const { return _currentIndexNode->getColor(); } protected: bool init() override; From b72e4118f0fe7d87da733f46f7dde71e3d9f7e1e Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Tue, 22 Sep 2015 20:23:15 +0900 Subject: [PATCH 034/192] PageViewIndicator - Add `PageViewIndicator.cpp` to build configuration files. --- cocos/2d/libcocos2d.vcxproj | 1 + cocos/2d/libcocos2d.vcxproj.filters | 3 +++ .../libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems | 1 + .../libcocos2d_8_1.Shared.vcxitems.filters | 3 +++ cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 1 + cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters | 3 +++ cocos/ui/Android.mk | 1 + cocos/ui/CMakeLists.txt | 1 + cocos/ui/proj.win32/libui.vcxproj | 1 + cocos/ui/proj.win32/libui.vcxproj.filters | 3 +++ templates/cocos2dx_files.json | 2 ++ 11 files changed, 20 insertions(+) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 387c3bd9e7..7f4b973e6d 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -652,6 +652,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index b80fd19400..d664d13291 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -934,6 +934,9 @@ ui\UIWidgets\ScrollWidget + + ui\UIWidgets\ScrollWidget + ui\UIWidgets\ScrollWidget diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index eb4ce9b0bb..30e180737a 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -1151,6 +1151,7 @@ + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index adc600998b..5556ab9e1d 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -2322,6 +2322,9 @@ ui\UIWidgets\ScrollWidget + + ui\UIWidgets\ScrollWidget + ui\UIWidgets\ScrollWidget diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index 70f9ea5aa2..f3f7c8cad8 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -652,6 +652,7 @@ + diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters index 29bd6e52d1..78056c6b4d 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters @@ -1686,6 +1686,9 @@ ui\UIWidgets\ScrollWidget + + ui\UIWidgets\ScrollWidget + ui\UIWidgets\ScrollWidget diff --git a/cocos/ui/Android.mk b/cocos/ui/Android.mk index 4031741943..710bb7ac79 100644 --- a/cocos/ui/Android.mk +++ b/cocos/ui/Android.mk @@ -18,6 +18,7 @@ CocosGUI.cpp \ UIHelper.cpp \ UIListView.cpp \ UIPageView.cpp \ +UIPageViewIndicator.cpp \ UIScrollView.cpp \ UIScrollViewBar.cpp \ UIButton.cpp \ diff --git a/cocos/ui/CMakeLists.txt b/cocos/ui/CMakeLists.txt index 0fb18b8496..876487760c 100644 --- a/cocos/ui/CMakeLists.txt +++ b/cocos/ui/CMakeLists.txt @@ -38,6 +38,7 @@ set(COCOS_UI_SRC ui/UIListView.cpp ui/UILoadingBar.cpp ui/UIPageView.cpp + ui/UIPageViewIndicator.cpp ui/UIRelativeBox.cpp ui/UIRichText.cpp ui/UIScale9Sprite.cpp diff --git a/cocos/ui/proj.win32/libui.vcxproj b/cocos/ui/proj.win32/libui.vcxproj index 0cb39b29cf..7401576f2e 100644 --- a/cocos/ui/proj.win32/libui.vcxproj +++ b/cocos/ui/proj.win32/libui.vcxproj @@ -62,6 +62,7 @@ + diff --git a/cocos/ui/proj.win32/libui.vcxproj.filters b/cocos/ui/proj.win32/libui.vcxproj.filters index 000ab33b24..81014a0d00 100644 --- a/cocos/ui/proj.win32/libui.vcxproj.filters +++ b/cocos/ui/proj.win32/libui.vcxproj.filters @@ -131,6 +131,9 @@ UIWidgets\ScrollWidget + + UIWidgets\ScrollWidget + UIWidgets diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 17ccf1a17e..0fbe822417 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -1255,6 +1255,8 @@ "cocos/ui/UILoadingBar.h", "cocos/ui/UIPageView.cpp", "cocos/ui/UIPageView.h", + "cocos/ui/UIPageViewIndicator.cpp", + "cocos/ui/UIPageViewIndicator.h", "cocos/ui/UIRadioButton.cpp", "cocos/ui/UIRadioButton.h", "cocos/ui/UIRelativeBox.cpp", From 9ed617c97814c51ad794b11b95e0ed57205e3858 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 28 Oct 2015 16:06:53 +0900 Subject: [PATCH 035/192] PageView - Add API descriptions --- cocos/ui/UIPageView.h | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 2eba7771b0..f5d0192a2e 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -248,20 +248,74 @@ public: //override methods virtual std::string getDescription() const override; + /** + * @brief Toggle page indicator enabled. + * + * @param enabled True if enable page indicator, false otherwise. + */ void setIndicatorEnabled(bool enabled); + /** + * @brief Query page indicator state. + * + * @return True if page indicator is enabled, false otherwise. + */ bool getIndicatorEnabled() const { return _indicatorEnabled; } + /** + * @brief Set the page indicator's position using anchor point. + * + * @param positionAsAnchorPoint The position as anchor point. + */ void setIndicatorPositionAsAnchorPoint(const Vec2& positionAsAnchorPoint); + + /** + * @brief Get the page indicator's position as anchor point. + * + * @return positionAsAnchorPoint + */ const Vec2& getIndicatorPositionAsAnchorPoint() const; + /** + * @brief Set the page indicator's position in page view. + * + * @param position The position in page view + */ void setIndicatorPosition(const Vec2& position); + + /** + * @brief Get the page indicator's position. + * + * @return positionAsAnchorPoint + */ const Vec2& getIndicatorPosition() const; + /** + * @brief Set space between page indicator's index nodes. + * + * @param spaceBetweenIndexNodes Space between nodes in pixel. + */ void setIndicatorSpaceBetweenIndexNodes(float spaceBetweenIndexNodes); + + /** + * @brief Get the space between page indicator's index nodes. + * + * @return spaceBetweenIndexNodes + */ float getIndicatorSpaceBetweenIndexNodes() const; + /** + * @brief Set color of page indicator's selected index. + * + * @param spaceBetweenIndexNodes Space between nodes in pixel. + */ void setIndicatorSelectedIndexColor(const Color3B& color); + + /** + * @brief Get the color of page indicator's selected index. + * + * @return color + */ const Color3B& getIndicatorSelectedIndexColor() const; /** From 69b794d2845c3413e66a35754d56035263218b4f Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 28 Oct 2015 16:34:30 +0900 Subject: [PATCH 036/192] PageView - Remove `_indicatorEnabled` flag. Null `_indicator` means that it is disabled. --- cocos/ui/UIPageView.cpp | 76 ++++++++++++++++++++++++++++++----------- cocos/ui/UIPageView.h | 3 +- 2 files changed, 57 insertions(+), 22 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index f06f0001ef..2a40fca9a4 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -32,7 +32,6 @@ namespace ui { IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): -_indicatorEnabled(false), _indicator(nullptr), _indicatorPositionAsAnchorPoint(Vec2(0.5f, 0.1f)), _currentPageIndex(-1), @@ -65,9 +64,6 @@ PageView* PageView::create() bool PageView::init() { - _indicator = PageViewIndicator::create(); - addProtectedChild(_indicator, 10000); - if (ListView::init()) { setDirection(Direction::HORIZONTAL); @@ -89,8 +85,12 @@ void PageView::setDirection(PageView::Direction direction) { _indicatorPositionAsAnchorPoint = Vec2(0.1f, 0.5f); } - _indicator->setDirection(direction); - refreshIndicatorPosition(); + + if(_indicator != nullptr) + { + _indicator->setDirection(direction); + refreshIndicatorPosition(); + } } void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate) @@ -164,14 +164,20 @@ void PageView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack { ListView::moveInnerContainer(deltaMove, canStartBounceBack); _currentPageIndex = getIndex(getCenterItemInCurrentView()); - _indicator->indicate(_currentPageIndex); + if(_indicator != nullptr) + { + _indicator->indicate(_currentPageIndex); + } } void PageView::onItemListChanged() { ListView::onItemListChanged(); ssize_t index = getIndex(getCenterItemInCurrentView()); - _indicator->reset(_items.size(), index); + if(_indicator != nullptr) + { + _indicator->reset(_items.size(), index); + } } void PageView::onSizeChanged() @@ -182,10 +188,13 @@ void PageView::onSizeChanged() void PageView::refreshIndicatorPosition() { - const Size& contentSize = getContentSize(); - float posX = contentSize.width * _indicatorPositionAsAnchorPoint.x; - float posY = contentSize.height * _indicatorPositionAsAnchorPoint.y; - _indicator->setPosition(Vec2(posX, posY)); + if(_indicator != nullptr) + { + const Size& contentSize = getContentSize(); + float posX = contentSize.width * _indicatorPositionAsAnchorPoint.x; + float posY = contentSize.height * _indicatorPositionAsAnchorPoint.y; + _indicator->setPosition(Vec2(posX, posY)); + } } void PageView::handleReleaseLogic(Touch *touch) @@ -327,8 +336,23 @@ void PageView::copySpecialProperties(Widget *widget) void PageView::setIndicatorEnabled(bool enabled) { - _indicatorEnabled = enabled; - _indicator->setVisible(_indicatorEnabled); + if(enabled == (_indicator != nullptr)) + { + return; + } + + if(!enabled) + { + removeProtectedChild(_indicator); + _indicator = nullptr; + } + else + { + _indicator = PageViewIndicator::create(); + addProtectedChild(_indicator, 10000); + setIndicatorSelectedIndexColor(Color3B(100, 100, 255)); + refreshIndicatorPosition(); + } } void PageView::setIndicatorPositionAsAnchorPoint(const Vec2& positionAsAnchorPoint) @@ -344,33 +368,45 @@ const Vec2& PageView::getIndicatorPositionAsAnchorPoint() const void PageView::setIndicatorPosition(const Vec2& position) { - const Size& contentSize = getContentSize(); - _indicatorPositionAsAnchorPoint.x = position.x / contentSize.width; - _indicatorPositionAsAnchorPoint.y = position.y / contentSize.height; - _indicator->setPosition(position); + if(_indicator != nullptr) + { + const Size& contentSize = getContentSize(); + _indicatorPositionAsAnchorPoint.x = position.x / contentSize.width; + _indicatorPositionAsAnchorPoint.y = position.y / contentSize.height; + _indicator->setPosition(position); + } } const Vec2& PageView::getIndicatorPosition() const { + CCASSERT(_indicator != nullptr, ""); return _indicator->getPosition(); } void PageView::setIndicatorSpaceBetweenIndexNodes(float spaceBetweenIndexNodes) { - _indicator->setSpaceBetweenIndexNodes(spaceBetweenIndexNodes); + if(_indicator != nullptr) + { + _indicator->setSpaceBetweenIndexNodes(spaceBetweenIndexNodes); + } } float PageView::getIndicatorSpaceBetweenIndexNodes() const { + CCASSERT(_indicator != nullptr, ""); return _indicator->getSpaceBetweenIndexNodes(); } void PageView::setIndicatorSelectedIndexColor(const Color3B& color) { - _indicator->setSelectedIndexColor(color); + if(_indicator != nullptr) + { + _indicator->setSelectedIndexColor(color); + } } const Color3B& PageView::getIndicatorSelectedIndexColor() const { + CCASSERT(_indicator != nullptr, ""); return _indicator->getSelectedIndexColor(); } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index f5d0192a2e..6c41a15aa8 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -260,7 +260,7 @@ public: * * @return True if page indicator is enabled, false otherwise. */ - bool getIndicatorEnabled() const { return _indicatorEnabled; } + bool getIndicatorEnabled() const { return _indicator != nullptr; } /** * @brief Set the page indicator's position using anchor point. @@ -360,7 +360,6 @@ protected: void refreshIndicatorPosition(); protected: - bool _indicatorEnabled; PageViewIndicator* _indicator; Vec2 _indicatorPositionAsAnchorPoint; From e59b7b74be3053a3e3f55c15e8227578ac3a0d57 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 28 Oct 2015 16:54:39 +0900 Subject: [PATCH 037/192] PageView - Add `scrollToItem()` having only one parameter. --- cocos/ui/UIPageView.cpp | 9 +++++++-- cocos/ui/UIPageView.h | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 2a40fca9a4..7a65a0143c 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -135,7 +135,12 @@ void PageView::setCurrentPageIndex(ssize_t index) void PageView::scrollToPage(ssize_t idx) { - scrollToItem(idx, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); + scrollToItem(idx); +} + +void PageView::scrollToItem(ssize_t itemIndex) +{ + ListView::scrollToItem(itemIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); } void PageView::setCustomScrollThreshold(float threshold) @@ -238,7 +243,7 @@ void PageView::handleReleaseLogic(Touch *touch) } _currentPageIndex = MIN(_currentPageIndex, _items.size()); _currentPageIndex = MAX(_currentPageIndex, 0); - scrollToItem(_currentPageIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); + scrollToItem(_currentPageIndex); } } } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 6c41a15aa8..1a90bca135 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -179,6 +179,13 @@ public: */ CC_DEPRECATED_ATTRIBUTE void scrollToPage(ssize_t idx); + /** + * Scroll to a page with a given index. + * + * @param idx A given index in the PageView. Index start from 0 to pageCount -1. + */ + void scrollToItem(ssize_t itemIndex); + /** * Gets current displayed page index. * @return current page index. From abc309edb24eaedc427ad49abf36f2a8afe0dc7f Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 28 Oct 2015 16:55:39 +0900 Subject: [PATCH 038/192] PageView - Replace the deprecated APIs with new ones. --- .../UIPageViewTest/UIPageViewTest.cpp | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index f96c071f49..d8757d73b8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -59,6 +59,7 @@ bool UIPageViewTest::init() Size backgroundSize = background->getContentSize(); pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); pageView->removeAllItems(); + pageView->setIndicatorEnabled(true); int pageCount = 4; for (int i = 0; i < pageCount; ++i) @@ -81,8 +82,7 @@ bool UIPageViewTest::init() } pageView->removeItem(0); - pageView->scrollToItem(pageCount - 2, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE); - + pageView->scrollToItem(pageCount - 2); pageView->addEventListener(CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this)); _uiLayer->addChild(pageView); @@ -100,7 +100,7 @@ void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type) { PageView* pageView = dynamic_cast(pSender); - _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurPageIndex() + 1)); + _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; @@ -154,7 +154,7 @@ bool UIPageViewButtonTest::init() (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); - pageView->removeAllPages(); + pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) @@ -182,10 +182,10 @@ bool UIPageViewButtonTest::init() } - pageView->insertPage(outerBox,i); + pageView->insertCustomItem(outerBox, i); } - pageView->removePageAtIndex(0); + pageView->removeItem(0); pageView->addEventListener(CC_CALLBACK_2(UIPageViewButtonTest::pageViewEvent, this)); @@ -210,7 +210,7 @@ void UIPageViewButtonTest::pageViewEvent(Ref *pSender, PageView::EventType type) { PageView* pageView = dynamic_cast(pSender); - _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurPageIndex() + 1)); + _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; @@ -281,7 +281,7 @@ bool UIPageViewCustomScrollThreshold::init() label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); - pageView->insertPage(layout,i); + pageView->insertCustomItem(layout, i); } _uiLayer->addChild(pageView); @@ -389,7 +389,7 @@ bool UIPageViewTouchPropagationTest::init() } - pageView->insertPage(outerBox,i); + pageView->insertCustomItem(outerBox, i); } pageView->addEventListener(CC_CALLBACK_2(UIPageViewTouchPropagationTest::pageViewEvent, this)); @@ -506,7 +506,7 @@ void UIPageViewTouchPropagationTest::pageViewEvent(Ref *pSender, PageView::Event { PageView* pageView = dynamic_cast(pSender); - _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurPageIndex() + 1)); + _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; @@ -586,7 +586,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init() } - pageView->insertPage(outerBox,i); + pageView->insertCustomItem(outerBox, i); } pageView->addEventListener(CC_CALLBACK_2(UIPageViewDynamicAddAndRemoveTest::pageViewEvent, this)); @@ -622,9 +622,9 @@ bool UIPageViewDynamicAddAndRemoveTest::init() outerBox->addChild(innerBox); } - pageView->addPage(outerBox); - _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getPages().size())); - CCLOG("current page index = %zd", pageView->getCurPageIndex()); + pageView->pushBackCustomItem(outerBox); + _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getItems().size())); + CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button); @@ -636,16 +636,16 @@ bool UIPageViewDynamicAddAndRemoveTest::init() button2->setTitleColor(Color3B::RED); button2->addClickEventListener([=](Ref* sender) { - if (pageView->getPages().size() > 0) + if (pageView->getItems().size() > 0) { - pageView->removePageAtIndex(pageView->getPages().size()-1); + pageView->removeItem(pageView->getItems().size()-1); } else { CCLOG("There is no page to remove!"); } - _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getPages().size())); - CCLOG("current page index = %zd", pageView->getCurPageIndex()); + _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getItems().size())); + CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button2); @@ -658,9 +658,9 @@ bool UIPageViewDynamicAddAndRemoveTest::init() button3->setTitleColor(Color3B::RED); button3->addClickEventListener([=](Ref* sender) { - pageView->removeAllPages(); - _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getPages().size())); - CCLOG("current page index = %zd", pageView->getCurPageIndex()); + pageView->removeAllItems(); + _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getItems().size())); + CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button3); @@ -669,8 +669,8 @@ bool UIPageViewDynamicAddAndRemoveTest::init() button4->setTitleText("Scroll to Page4"); button4->setNormalizedPosition(Vec2(0.85,0.5)); button4->addClickEventListener([=](Ref* sender){ - pageView->scrollToPage(3); - CCLOG("current page index = %zd", pageView->getCurPageIndex()); + pageView->scrollToItem(3); + CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button4); @@ -688,7 +688,7 @@ void UIPageViewDynamicAddAndRemoveTest::pageViewEvent(Ref *pSender, PageView::Ev { PageView* pageView = dynamic_cast(pSender); - _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurPageIndex() + 1)); + _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; @@ -716,7 +716,7 @@ bool UIPageViewJumpToPageTest::init() Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed - _displayValueLabel = Text::create("setCurPageIndex API Test", "fonts/Marker Felt.ttf", 32); + _displayValueLabel = Text::create("setCurrentPageIndex API Test", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + @@ -742,7 +742,7 @@ bool UIPageViewJumpToPageTest::init() (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); - pageView->removeAllPages(); + pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) @@ -761,10 +761,10 @@ bool UIPageViewJumpToPageTest::init() label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); - pageView->insertPage(layout,i); + pageView->insertCustomItem(layout, i); } - pageView->setCurPageIndex(1); + pageView->setCurrentPageIndex(1); //add buttons to jump to specific page auto button1 = ui::Button::create(); @@ -773,7 +773,7 @@ bool UIPageViewJumpToPageTest::init() CCLOG("button1 content Size = %f, %f", button1->getContentSize().width, button1->getContentSize().height); button1->addClickEventListener([=](Ref*){ - pageView->setCurPageIndex(0); + pageView->setCurrentPageIndex(0); }); _uiLayer->addChild(button1); @@ -783,7 +783,7 @@ bool UIPageViewJumpToPageTest::init() CCLOG("button2 content Size = %f, %f", button2->getContentSize().width, button2->getContentSize().height); button2->addClickEventListener([=](Ref*){ - pageView->setCurPageIndex(1); + pageView->setCurrentPageIndex(1); }); _uiLayer->addChild(button2); @@ -791,7 +791,7 @@ bool UIPageViewJumpToPageTest::init() button3->setTitleText("Jump to Page3"); button3->setNormalizedPosition(Vec2(0.9, 0.75)); button3->addClickEventListener([=](Ref*){ - pageView->setCurPageIndex(2); + pageView->setCurrentPageIndex(2); }); _uiLayer->addChild(button3); @@ -799,7 +799,7 @@ bool UIPageViewJumpToPageTest::init() button4->setTitleText("Jump to Page4"); button4->setNormalizedPosition(Vec2(0.9, 0.65)); button4->addClickEventListener([=](Ref*){ - pageView->setCurPageIndex(3); + pageView->setCurrentPageIndex(3); }); _uiLayer->addChild(button4); _uiLayer->addChild(pageView); @@ -854,7 +854,7 @@ bool UIPageViewVerticalTest::init() (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); - pageView->removeAllPages(); + pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) @@ -873,7 +873,7 @@ bool UIPageViewVerticalTest::init() label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); - pageView->insertPage(layout,i); + pageView->insertCustomItem(layout, i); } pageView->addEventListener(CC_CALLBACK_2(UIPageViewVerticalTest::pageViewEvent, this)); @@ -893,7 +893,7 @@ void UIPageViewVerticalTest::pageViewEvent(Ref *pSender, PageView::EventType typ { PageView* pageView = dynamic_cast(pSender); - _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurPageIndex() + 1)); + _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; @@ -947,7 +947,7 @@ bool UIPageViewDisableTouchTest::init() (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setTouchEnabled(false); - pageView->removeAllPages(); + pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) @@ -966,7 +966,7 @@ bool UIPageViewDisableTouchTest::init() label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); - pageView->insertPage(layout,i); + pageView->insertCustomItem(layout, i); } _uiLayer->addChild(pageView); From 543fff63fb486e1b6a46c266df967c637ea169d6 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 28 Oct 2015 17:22:06 +0900 Subject: [PATCH 039/192] PageView - Add indicators to some test cases --- .../UIPageViewTest/UIPageViewTest.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index d8757d73b8..a14b712cf3 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -259,11 +259,8 @@ bool UIPageViewCustomScrollThreshold::init() PageView* pageView = PageView::create(); pageView->setContentSize(Size(240.0f, 100.0f)); Size backgroundSize = background->getContentSize(); - pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + - (backgroundSize.width - pageView->getContentSize().width) / 2.0f, - (widgetSize.height - backgroundSize.height) / 2.0f + - (backgroundSize.height - pageView->getContentSize().height) / 2.0f + 20)); - + pageView->setPosition(Vec2(widgetSize - pageView->getContentSize()) / 2.0f + Vec2(0, 20)); + int pageCount = 4; for (int i = 0; i < pageCount; ++i) { @@ -273,12 +270,12 @@ bool UIPageViewCustomScrollThreshold::init() ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); imageView->setContentSize(Size(240, 130)); - imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); + imageView->setPosition(layout->getContentSize() / 2.0f); layout->addChild(imageView); Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); label->setColor(Color3B(192, 192, 192)); - label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); + label->setPosition(layout->getContentSize() / 2.0f); layout->addChild(label); pageView->insertCustomItem(layout, i); @@ -558,6 +555,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init() pageView->setPosition(Vec2(widgetSize.width / 2.0f ,widgetSize.height / 2.0f)); pageView->setBackGroundColor(Color3B::GREEN); pageView->setBackGroundColorType(Layout::BackGroundColorType::SOLID); + pageView->setIndicatorEnabled(true); int pageCount = 4; for (int i = 0; i < pageCount; ++i) @@ -741,7 +739,7 @@ bool UIPageViewJumpToPageTest::init() (backgroundSize.width - pageView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); - + pageView->setIndicatorEnabled(true); pageView->removeAllItems(); int pageCount = 4; @@ -846,6 +844,7 @@ bool UIPageViewVerticalTest::init() // Create the page view PageView* pageView = PageView::create(); + pageView->setIndicatorEnabled(true); pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); @@ -853,7 +852,6 @@ bool UIPageViewVerticalTest::init() (backgroundSize.width - pageView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); - pageView->removeAllItems(); int pageCount = 4; From 04fa7a8902ef039a357c07cf90581aa5da898154 Mon Sep 17 00:00:00 2001 From: Filipe Lemos Date: Wed, 28 Oct 2015 17:57:57 +0000 Subject: [PATCH 040/192] Added Application::getVersion() to get the app version. --- cocos/platform/CCApplicationProtocol.h | 7 +++++++ .../android/CCApplication-android.cpp | 5 +++++ .../platform/android/CCApplication-android.h | 5 +++++ .../src/org/cocos2dx/lib/Cocos2dxHelper.java | 9 +++++++++ .../Java_org_cocos2dx_lib_Cocos2dxHelper.cpp | 13 ++++++++++++ .../Java_org_cocos2dx_lib_Cocos2dxHelper.h | 1 + cocos/platform/ios/CCApplication-ios.h | 5 +++++ cocos/platform/ios/CCApplication-ios.mm | 8 ++++++++ cocos/platform/linux/CCApplication-linux.cpp | 5 +++++ cocos/platform/linux/CCApplication-linux.h | 5 +++++ cocos/platform/mac/CCApplication-mac.h | 5 +++++ cocos/platform/mac/CCApplication-mac.mm | 8 ++++++++ cocos/platform/win32/CCApplication-win32.cpp | 5 +++++ cocos/platform/win32/CCApplication-win32.h | 5 +++++ cocos/platform/winrt/CCApplication.cpp | 20 +++++++++++++++++++ cocos/platform/winrt/CCApplication.h | 5 +++++ 16 files changed, 111 insertions(+) diff --git a/cocos/platform/CCApplicationProtocol.h b/cocos/platform/CCApplicationProtocol.h index 2b78c0b92f..9ac60baa2b 100644 --- a/cocos/platform/CCApplicationProtocol.h +++ b/cocos/platform/CCApplicationProtocol.h @@ -136,6 +136,13 @@ public: */ virtual Platform getTargetPlatform() = 0; + /** + @brief Get application version. + * @js NA + * @lua NA + */ + virtual std::string getVersion() = 0; + /** @brief Open url in default browser. @param String with url to open. diff --git a/cocos/platform/android/CCApplication-android.cpp b/cocos/platform/android/CCApplication-android.cpp index 8d802a1814..b3f0d18bef 100644 --- a/cocos/platform/android/CCApplication-android.cpp +++ b/cocos/platform/android/CCApplication-android.cpp @@ -200,6 +200,11 @@ Application::Platform Application::getTargetPlatform() return Platform::OS_ANDROID; } +std::string Application::getVersion() +{ + return getVersionJNI(); +} + bool Application::openURL(const std::string &url) { return openURLJNI(url.c_str()); diff --git a/cocos/platform/android/CCApplication-android.h b/cocos/platform/android/CCApplication-android.h index d1f8c47c48..3783868235 100644 --- a/cocos/platform/android/CCApplication-android.h +++ b/cocos/platform/android/CCApplication-android.h @@ -84,6 +84,11 @@ public: */ virtual Platform getTargetPlatform(); + /** + @brief Get application version. + */ + virtual std::string getVersion(); + /** @brief Open url in default browser @param String with url to open. diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 8bd35f4980..bee8144410 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -212,6 +212,15 @@ public class Cocos2dxHelper { sVibrateService.vibrate((long)(duration * 1000)); } + public static String getVersion() { + try { + String version = Cocos2dxActivity.getContext().getPackageManager().getPackageInfo(Cocos2dxActivity.getContext().getPackageName(), 0).versionName; + return version; + } catch(Exception e) { + return "-"; + } + } + public static boolean openURL(String url) { boolean ret = false; try { diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index cbd1285e05..4a6b0a39e4 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -205,6 +205,19 @@ void vibrateJni(float duration) { } } +std::string getVersionJNI() { + JniMethodInfo t; + std::string ret(""); + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getVersion", "()Ljava/lang/String;")) { + jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); + t.env->DeleteLocalRef(t.classID); + ret = JniHelper::jstring2string(str); + t.env->DeleteLocalRef(str); + } + return ret; +} + extern bool openURLJNI(const char* url) { JniMethodInfo t; diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h index 534a35669c..c9f50994cc 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h @@ -40,6 +40,7 @@ extern void disableAccelerometerJni(); extern void setAccelerometerIntervalJni(float interval); extern void setKeepScreenOnJni(bool value); extern void vibrateJni(float duration); +extern std::string getVersionJNI(); extern bool openURLJNI(const char* url); // functions for UserDefault extern bool getBoolForKeyJNI(const char* key, bool defaultValue); diff --git a/cocos/platform/ios/CCApplication-ios.h b/cocos/platform/ios/CCApplication-ios.h index ae93c83d4d..63b3884369 100644 --- a/cocos/platform/ios/CCApplication-ios.h +++ b/cocos/platform/ios/CCApplication-ios.h @@ -86,6 +86,11 @@ public: */ virtual Platform getTargetPlatform(); + /** + @brief Get application version. + */ + virtual std::string getVersion(); + /** @brief Open url in default browser @param String with url to open. diff --git a/cocos/platform/ios/CCApplication-ios.mm b/cocos/platform/ios/CCApplication-ios.mm index 7411478060..69bc93c895 100644 --- a/cocos/platform/ios/CCApplication-ios.mm +++ b/cocos/platform/ios/CCApplication-ios.mm @@ -139,6 +139,14 @@ Application::Platform Application::getTargetPlatform() } } +std::string Application::getVersion() { + NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; + if (version) { + return [version UTF8String]; + } + return ""; +} + bool Application::openURL(const std::string &url) { NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding]; diff --git a/cocos/platform/linux/CCApplication-linux.cpp b/cocos/platform/linux/CCApplication-linux.cpp index 12f1e89228..8f19a553fb 100644 --- a/cocos/platform/linux/CCApplication-linux.cpp +++ b/cocos/platform/linux/CCApplication-linux.cpp @@ -136,6 +136,11 @@ Application::Platform Application::getTargetPlatform() return Platform::OS_LINUX; } +std::string Application::getVersion() +{ + return ""; +} + bool Application::openURL(const std::string &url) { std::string op = std::string("open ").append(url); diff --git a/cocos/platform/linux/CCApplication-linux.h b/cocos/platform/linux/CCApplication-linux.h index c827023af1..7342269028 100644 --- a/cocos/platform/linux/CCApplication-linux.h +++ b/cocos/platform/linux/CCApplication-linux.h @@ -78,6 +78,11 @@ public: */ virtual const char * getCurrentLanguageCode(); + /** + @brief Get application version + */ + virtual std::string getVersion(); + /** @brief Open url in default browser @param String with url to open. diff --git a/cocos/platform/mac/CCApplication-mac.h b/cocos/platform/mac/CCApplication-mac.h index 2a243a7624..bf20f5c1e6 100644 --- a/cocos/platform/mac/CCApplication-mac.h +++ b/cocos/platform/mac/CCApplication-mac.h @@ -91,6 +91,11 @@ public: */ virtual Platform getTargetPlatform(); + /** + @brief Get application version. + */ + virtual std::string getVersion(); + /** @brief Open url in default browser @param String with url to open. diff --git a/cocos/platform/mac/CCApplication-mac.mm b/cocos/platform/mac/CCApplication-mac.mm index 1666776a5c..47c55a8b07 100644 --- a/cocos/platform/mac/CCApplication-mac.mm +++ b/cocos/platform/mac/CCApplication-mac.mm @@ -118,6 +118,14 @@ Application::Platform Application::getTargetPlatform() return Platform::OS_MAC; } +std::string Application::getVersion() { + NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; + if (version) { + return [version UTF8String]; + } + return ""; +} + ///////////////////////////////////////////////////////////////////////////////////////////////// // static member function ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/cocos/platform/win32/CCApplication-win32.cpp b/cocos/platform/win32/CCApplication-win32.cpp index 9ee4b56f3f..1c752094ef 100644 --- a/cocos/platform/win32/CCApplication-win32.cpp +++ b/cocos/platform/win32/CCApplication-win32.cpp @@ -217,6 +217,11 @@ Application::Platform Application::getTargetPlatform() return Platform::OS_WINDOWS; } +std::string Application::getVersion() +{ + return ""; +} + bool Application::openURL(const std::string &url) { WCHAR *temp = new WCHAR[url.size() + 1]; diff --git a/cocos/platform/win32/CCApplication-win32.h b/cocos/platform/win32/CCApplication-win32.h index 71013eca9e..455e6d5b89 100644 --- a/cocos/platform/win32/CCApplication-win32.h +++ b/cocos/platform/win32/CCApplication-win32.h @@ -75,6 +75,11 @@ public: */ virtual Platform getTargetPlatform(); + /** + @brief Get application version + */ + virtual std::string getVersion(); + /** @brief Open url in default browser @param String with url to open. diff --git a/cocos/platform/winrt/CCApplication.cpp b/cocos/platform/winrt/CCApplication.cpp index 374445a554..65a583994a 100644 --- a/cocos/platform/winrt/CCApplication.cpp +++ b/cocos/platform/winrt/CCApplication.cpp @@ -36,6 +36,7 @@ using namespace Windows::Foundation; #include "platform/CCFileUtils.h" #include "CCWinRTUtils.h" #include "platform/CCApplication.h" +#include "tinyxml2/tinyxml2.h" /** @brief This function change the PVRFrame show/hide setting in register. @@ -225,6 +226,25 @@ Application::Platform Application::getTargetPlatform() } } +std::string Application::getVersion() +{ + std::string r(""); + std::string s = FileUtils::getInstance()->getStringFromFile("WMAppManifest.xml"); + if (!s.empty()) { + tinyxml2::XMLDocument doc; + if (!doc.Parse(s.c_str())) { + tinyxml2::XMLElement *app = doc.RootElement()->FirstChildElement("App"); + if (app) { + const char* version = app->Attribute("Version"); + if (version) { + r = version; + } + } + } + } + return r; +} + bool Application::openURL(const std::string &url) { #if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT diff --git a/cocos/platform/winrt/CCApplication.h b/cocos/platform/winrt/CCApplication.h index 453aa196fa..f2e9856ecb 100644 --- a/cocos/platform/winrt/CCApplication.h +++ b/cocos/platform/winrt/CCApplication.h @@ -63,6 +63,11 @@ public: @brief Get target platform */ virtual Platform getTargetPlatform() override; + + /** + @brief Get application version + */ + virtual std::string getVersion() override; /** @brief Open url in default browser From ccf4cb5a74699bc2815f5ad657dd25f5059a3a70 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 29 Oct 2015 10:41:58 +0800 Subject: [PATCH 041/192] improve scale9sprite --- cocos/2d/CCAutoPolygon.cpp | 11 + cocos/2d/CCAutoPolygon.h | 11 +- cocos/2d/CCSprite.cpp | 2 +- cocos/2d/CCSprite.h | 27 +- cocos/ui/UIScale9Sprite.cpp | 1027 ++++++++++------------------------- cocos/ui/UIScale9Sprite.h | 80 +-- 6 files changed, 345 insertions(+), 813 deletions(-) diff --git a/cocos/2d/CCAutoPolygon.cpp b/cocos/2d/CCAutoPolygon.cpp index a1e40ef77c..2781894b9a 100644 --- a/cocos/2d/CCAutoPolygon.cpp +++ b/cocos/2d/CCAutoPolygon.cpp @@ -87,6 +87,17 @@ void PolygonInfo::setQuad(V3F_C4B_T2F_Quad *quad) triangles.verts = (V3F_C4B_T2F*)quad; } +void PolygonInfo::setTriangles(TrianglesCommand::Triangles other) +{ + this->releaseVertsAndIndices(); + isVertsOwner = false; + + this->triangles.vertCount = other.vertCount; + this->triangles.indexCount = other.indexCount; + this->triangles.verts = other.verts; + this->triangles.indices = other.indices; +} + void PolygonInfo::releaseVertsAndIndices() { if(isVertsOwner) diff --git a/cocos/2d/CCAutoPolygon.h b/cocos/2d/CCAutoPolygon.h index 0190ade06b..7dc7a17749 100644 --- a/cocos/2d/CCAutoPolygon.h +++ b/cocos/2d/CCAutoPolygon.h @@ -89,6 +89,14 @@ public: */ void setQuad(V3F_C4B_T2F_Quad *quad); + /** + * set the data to be a pointer to a triangles + * the member verts will not be released when this PolygonInfo destructs + * as the verts memory are managed by other objects + * @param triangles a pointer to the TrianglesCommand::Triangles object + */ + void setTriangles(TrianglesCommand::Triangles triangles); + /** * get vertex count * @return number of vertices @@ -110,7 +118,6 @@ public: Rect rect; std::string filename; TrianglesCommand::Triangles triangles; - protected: bool isVertsOwner; @@ -267,4 +274,4 @@ protected: NS_CC_END -#endif // #ifndef COCOS_2D_CCAUTOPOLYGON_H__ \ No newline at end of file +#endif // #ifndef COCOS_2D_CCAUTOPOLYGON_H__ diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 04366bd4d1..d89b1d6811 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -1135,7 +1135,7 @@ std::string Sprite::getDescription() const return StringUtils::format("", _tag, texture_id ); } -PolygonInfo Sprite::getPolygonInfo() const +PolygonInfo& Sprite::getPolygonInfo() { return _polyInfo; } diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 555fb0a5e3..bcb5655b67 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -403,6 +403,19 @@ public: */ CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flippedY) { setFlippedY(flippedY); }; + /** + * returns a reference of the polygon information associated with this sprite + * + * @return a copy of PolygonInfo + */ + PolygonInfo& getPolygonInfo(); + + /** + * set the sprite to use this new PolygonInfo + * + * @param PolygonInfo the polygon information object + */ + void setPolygonInfo(const PolygonInfo& info); // // Overrides // @@ -564,20 +577,6 @@ CC_CONSTRUCTOR_ACCESS: */ virtual bool initWithFile(const std::string& filename, const Rect& rect); - /** - * returns a copy of the polygon information associated with this sprite - * because this is a copy process it is slower than getting the reference, so use wisely - * - * @return a copy of PolygonInfo - */ - PolygonInfo getPolygonInfo() const; - - /** - * set the sprite to use this new PolygonInfo - * - * @param PolygonInfo the polygon information object - */ - void setPolygonInfo(const PolygonInfo& info); protected: void updateColor() override; diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 55712920fa..213038086e 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -39,17 +39,7 @@ namespace ui { Scale9Sprite::Scale9Sprite() : _spritesGenerated(false) , _spriteFrameRotated(false) - , _positionsAreDirty(true) , _scale9Image(nullptr) - , _topLeftSprite(nullptr) - , _topSprite(nullptr) - , _topRightSprite(nullptr) - , _leftSprite(nullptr) - , _centerSprite(nullptr) - , _rightSprite(nullptr) - , _bottomLeftSprite(nullptr) - , _bottomSprite(nullptr) - , _bottomRightSprite(nullptr) , _scale9Enabled(true) , _insetLeft(0) , _insetTop(0) @@ -59,7 +49,9 @@ namespace ui { ,_flippedY(false) ,_isPatch9(false) ,_brightState(State::NORMAL) - + ,_sliceVertices(nullptr) + ,_sliceIndices(nullptr) + ,_nonSliceSpriteAnchor(Vec2::ANCHOR_MIDDLE) { this->setAnchorPoint(Vec2(0.5,0.5)); } @@ -333,58 +325,8 @@ namespace ui { void Scale9Sprite::cleanupSlicedSprites() { - if (_topLeftSprite && _topLeftSprite->isRunning()) - { - _topLeftSprite->onExit(); - } - if (_topSprite && _topSprite->isRunning()) - { - _topSprite->onExit(); - } - if (_topRightSprite && _topRightSprite->isRunning()) - { - _topRightSprite->onExit(); - } - - if (_leftSprite && _leftSprite->isRunning()) - { - _leftSprite->onExit(); - } - - if (_centerSprite && _centerSprite->isRunning()) - { - _centerSprite->onExit(); - } - - if (_rightSprite && _rightSprite->isRunning()) - { - _rightSprite->onExit(); - } - - if (_bottomLeftSprite && _bottomLeftSprite->isRunning()) - { - _bottomLeftSprite->onExit(); - } - - if (_bottomRightSprite && _bottomRightSprite->isRunning()) - { - _bottomRightSprite->onExit(); - } - - if (_bottomSprite && _bottomSprite->isRunning()) - { - _bottomSprite->onExit(); - } - - CC_SAFE_RELEASE_NULL(_topLeftSprite); - CC_SAFE_RELEASE_NULL(_topSprite); - CC_SAFE_RELEASE_NULL(_topRightSprite); - CC_SAFE_RELEASE_NULL(_leftSprite); - CC_SAFE_RELEASE_NULL(_centerSprite); - CC_SAFE_RELEASE_NULL(_rightSprite); - CC_SAFE_RELEASE_NULL(_bottomLeftSprite); - CC_SAFE_RELEASE_NULL(_bottomSprite); - CC_SAFE_RELEASE_NULL(_bottomRightSprite); + CC_SAFE_DELETE_ARRAY(_sliceIndices); + CC_SAFE_DELETE_ARRAY(_sliceVertices); } @@ -418,24 +360,6 @@ namespace ui { { if(_scale9Image) _scale9Image->setBlendFunc(_blendFunc); - if(_topLeftSprite) - _topLeftSprite->setBlendFunc(_blendFunc); - if(_topSprite) - _topSprite->setBlendFunc(_blendFunc); - if(_topRightSprite) - _topRightSprite->setBlendFunc(_blendFunc); - if(_leftSprite) - _leftSprite->setBlendFunc(_blendFunc); - if(_centerSprite) - _centerSprite->setBlendFunc(_blendFunc); - if(_rightSprite) - _rightSprite->setBlendFunc(_blendFunc); - if(_bottomLeftSprite) - _bottomLeftSprite->setBlendFunc(_blendFunc); - if(_bottomSprite) - _bottomSprite->setBlendFunc(_blendFunc); - if(_bottomRightSprite) - _bottomRightSprite->setBlendFunc(_blendFunc); } bool Scale9Sprite::updateWithBatchNode(cocos2d::SpriteBatchNode *batchnode, @@ -460,22 +384,6 @@ namespace ui { return updateWithSprite(sprite, rect, rotated, Vec2::ZERO, rect.size, capInsets); } - static Rect intersectRect(const Rect &first, const Rect &second) - { - Rect ret; - ret.origin.x = std::max(first.origin.x,second.origin.x); - ret.origin.y = std::max(first.origin.y,second.origin.y); - - float rightRealPoint = std::min(first.origin.x + first.size.width, - second.origin.x + second.size.width); - float bottomRealPoint = std::min(first.origin.y + first.size.height, - second.origin.y + second.size.height); - - ret.size.width = std::max(rightRealPoint - ret.origin.x, 0.0f); - ret.size.height = std::max(bottomRealPoint - ret.origin.y, 0.0f); - return ret; - } - bool Scale9Sprite::updateWithSprite(Sprite* sprite, const Rect& textureRect, bool rotated, @@ -488,7 +396,6 @@ namespace ui { // Release old sprites this->cleanupSlicedSprites(); - _protectedChildren.clear(); updateBlendFunc(sprite?sprite->getTexture():nullptr); @@ -514,7 +421,9 @@ namespace ui { { return false; } - + _scale9Image->setAnchorPoint(Vec2::ZERO); + _scale9Image->setPosition(Vec2::ZERO); + SpriteFrame *spriteFrame = _scale9Image->getSpriteFrame(); if (!spriteFrame) @@ -525,8 +434,6 @@ namespace ui { Rect rect(textureRect); Size size(originalSize); - _capInsets = capInsets; - // If there is no given rect if ( rect.equals(Rect::ZERO) ) { @@ -543,7 +450,6 @@ namespace ui { // Set the given rect's size as original size _spriteRect = rect; - _offset = offset; _spriteFrameRotated = rotated; _originalSize = size; _preferredSize = size; @@ -577,474 +483,62 @@ namespace ui { void Scale9Sprite::createSlicedSprites() { - float width = _originalSize.width; - float height = _originalSize.height; - - Vec2 offsetPosition(floor(_offset.x + (_originalSize.width - _spriteRect.size.width) / 2), - floor(_offset.y + (_originalSize.height - _spriteRect.size.height) / 2)); - - // If there is no specified center region - if ( _capInsetsInternal.equals(Rect::ZERO) ) + //todo create sliced sprite + if (_scale9Enabled) { - // log("... cap insets not specified : using default cap insets ..."); - _capInsetsInternal = Rect(width /3, height /3, width /3, height /3); - } - - Rect originalRect=_spriteRect; - if(_spriteFrameRotated) - originalRect = Rect(_spriteRect.origin.x - offsetPosition.y, - _spriteRect.origin.y - offsetPosition.x, - _originalSize.width, _originalSize.height); - else - originalRect = Rect(_spriteRect.origin.x - offsetPosition.x, - _spriteRect.origin.y - offsetPosition.y, - _originalSize.width, _originalSize.height); - - float leftWidth = _capInsetsInternal.origin.x; - float centerWidth = _capInsetsInternal.size.width; - float rightWidth = originalRect.size.width - (leftWidth + centerWidth); - - float topHeight = _capInsetsInternal.origin.y; - float centerHeight = _capInsetsInternal.size.height; - float bottomHeight = originalRect.size.height - (topHeight + centerHeight); - - // calculate rects - - // ... top row - float x = 0.0; - float y = 0.0; - //why do we need pixelRect? - Rect pixelRect = Rect(offsetPosition.x, offsetPosition.y, - _spriteRect.size.width, _spriteRect.size.height); - - // top left - Rect leftTopBoundsOriginal = Rect(x, y, leftWidth, topHeight); - Rect leftTopBounds = leftTopBoundsOriginal; - - // top center - x += leftWidth; - Rect centerTopBounds = Rect(x, y, centerWidth, topHeight); - - // top right - x += centerWidth; - Rect rightTopBounds = Rect(x, y, rightWidth, topHeight); - - // ... center row - x = 0.0; - y = 0.0; - y += topHeight; - - // center left - Rect leftCenterBounds = Rect(x, y, leftWidth, centerHeight); - - // center center - x += leftWidth; - Rect centerBoundsOriginal = Rect(x, y, centerWidth, centerHeight); - Rect centerBounds = centerBoundsOriginal; - - // center right - x += centerWidth; - Rect rightCenterBounds = Rect(x, y, rightWidth, centerHeight); - - // ... bottom row - x = 0.0; - y = 0.0; - y += topHeight; - y += centerHeight; - - // bottom left - Rect leftBottomBounds = Rect(x, y, leftWidth, bottomHeight); - - // bottom center - x += leftWidth; - Rect centerBottomBounds = Rect(x, y, centerWidth, bottomHeight); - - // bottom right - x += centerWidth; - Rect rightBottomBoundsOriginal = Rect(x, y, rightWidth, bottomHeight); - Rect rightBottomBounds = rightBottomBoundsOriginal; - - if((_capInsetsInternal.origin.x + _capInsetsInternal.size.width) <= _originalSize.width - || (_capInsetsInternal.origin.y + _capInsetsInternal.size.height) <= _originalSize.height) - //in general case it is error but for legacy support we will check it - { - leftTopBounds = intersectRect(leftTopBounds, pixelRect); - centerTopBounds = intersectRect(centerTopBounds, pixelRect); - rightTopBounds = intersectRect(rightTopBounds, pixelRect); - leftCenterBounds = intersectRect(leftCenterBounds, pixelRect); - centerBounds = intersectRect(centerBounds, pixelRect); - rightCenterBounds = intersectRect(rightCenterBounds, pixelRect); - leftBottomBounds = intersectRect(leftBottomBounds, pixelRect); - centerBottomBounds = intersectRect(centerBottomBounds, pixelRect); - rightBottomBounds = intersectRect(rightBottomBounds, pixelRect); - } - else - //it is error but for legacy turn off clip system - CCLOG("Scale9Sprite capInsetsInternal > originalSize"); - - Rect rotatedLeftTopBoundsOriginal = leftTopBoundsOriginal; - Rect rotatedCenterBoundsOriginal = centerBoundsOriginal; - Rect rotatedRightBottomBoundsOriginal = rightBottomBoundsOriginal; - - Rect rotatedCenterBounds = centerBounds; - Rect rotatedRightBottomBounds = rightBottomBounds; - Rect rotatedLeftBottomBounds = leftBottomBounds; - Rect rotatedRightTopBounds = rightTopBounds; - Rect rotatedLeftTopBounds = leftTopBounds; - Rect rotatedRightCenterBounds = rightCenterBounds; - Rect rotatedLeftCenterBounds = leftCenterBounds; - Rect rotatedCenterBottomBounds = centerBottomBounds; - Rect rotatedCenterTopBounds = centerTopBounds; - - if (!_spriteFrameRotated) - { - - AffineTransform t = AffineTransform::IDENTITY; - t = AffineTransformTranslate(t, originalRect.origin.x, originalRect.origin.y); - - rotatedLeftTopBoundsOriginal = RectApplyAffineTransform(rotatedLeftTopBoundsOriginal, t); - rotatedCenterBoundsOriginal = RectApplyAffineTransform(rotatedCenterBoundsOriginal, t); - rotatedRightBottomBoundsOriginal = RectApplyAffineTransform(rotatedRightBottomBoundsOriginal, t); - - rotatedCenterBounds = RectApplyAffineTransform(rotatedCenterBounds, t); - rotatedRightBottomBounds = RectApplyAffineTransform(rotatedRightBottomBounds, t); - rotatedLeftBottomBounds = RectApplyAffineTransform(rotatedLeftBottomBounds, t); - rotatedRightTopBounds = RectApplyAffineTransform(rotatedRightTopBounds, t); - rotatedLeftTopBounds = RectApplyAffineTransform(rotatedLeftTopBounds, t); - rotatedRightCenterBounds = RectApplyAffineTransform(rotatedRightCenterBounds, t); - rotatedLeftCenterBounds = RectApplyAffineTransform(rotatedLeftCenterBounds, t); - rotatedCenterBottomBounds = RectApplyAffineTransform(rotatedCenterBottomBounds, t); - rotatedCenterTopBounds = RectApplyAffineTransform(rotatedCenterTopBounds, t); - - - } - else - { - // set up transformation of coordinates - // to handle the case where the sprite is stored rotated - // in the spritesheet - // log("rotated"); - - AffineTransform t = AffineTransform::IDENTITY; - - t = AffineTransformTranslate(t, originalRect.size.height+originalRect.origin.x, originalRect.origin.y); - t = AffineTransformRotate(t, 1.57079633f); - - leftTopBoundsOriginal = RectApplyAffineTransform(leftTopBoundsOriginal, t); - centerBoundsOriginal = RectApplyAffineTransform(centerBoundsOriginal, t); - rightBottomBoundsOriginal = RectApplyAffineTransform(rightBottomBoundsOriginal, t); - - centerBounds = RectApplyAffineTransform(centerBounds, t); - rightBottomBounds = RectApplyAffineTransform(rightBottomBounds, t); - leftBottomBounds = RectApplyAffineTransform(leftBottomBounds, t); - rightTopBounds = RectApplyAffineTransform(rightTopBounds, t); - leftTopBounds = RectApplyAffineTransform(leftTopBounds, t); - rightCenterBounds = RectApplyAffineTransform(rightCenterBounds, t); - leftCenterBounds = RectApplyAffineTransform(leftCenterBounds, t); - centerBottomBounds = RectApplyAffineTransform(centerBottomBounds, t); - centerTopBounds = RectApplyAffineTransform(centerTopBounds, t); - - rotatedLeftTopBoundsOriginal.origin = leftTopBoundsOriginal.origin; - rotatedCenterBoundsOriginal.origin = centerBoundsOriginal.origin; - rotatedRightBottomBoundsOriginal.origin = rightBottomBoundsOriginal.origin; - - rotatedCenterBounds.origin = centerBounds.origin; - rotatedRightBottomBounds.origin = rightBottomBounds.origin; - rotatedLeftBottomBounds.origin = leftBottomBounds.origin; - rotatedRightTopBounds.origin = rightTopBounds.origin; - rotatedLeftTopBounds.origin = leftTopBounds.origin; - rotatedRightCenterBounds.origin = rightCenterBounds.origin; - rotatedLeftCenterBounds.origin = leftCenterBounds.origin; - rotatedCenterBottomBounds.origin = centerBottomBounds.origin; - rotatedCenterTopBounds.origin = centerTopBounds.origin; - - - } - - _topLeftSize = rotatedLeftTopBoundsOriginal.size; - _centerSize = rotatedCenterBoundsOriginal.size; - _bottomRightSize = rotatedRightBottomBoundsOriginal.size; - if(_isPatch9) - { - _topLeftSize.width = _topLeftSize.width - 1; - _topLeftSize.height = _topLeftSize.height - 1; - _bottomRightSize.width = _bottomRightSize.width - 1; - _bottomRightSize.height = _bottomRightSize.height - 1; - } - - if(_spriteFrameRotated) - { - float offsetX = (rotatedCenterBounds.origin.x + rotatedCenterBounds.size.height/2) - - (rotatedCenterBoundsOriginal.origin.x + rotatedCenterBoundsOriginal.size.height/2); - float offsetY = (rotatedCenterBoundsOriginal.origin.y + rotatedCenterBoundsOriginal.size.width/2) - - (rotatedCenterBounds.origin.y + rotatedCenterBounds.size.width/2); - _centerOffset.x = -offsetY; - _centerOffset.y = offsetX; - } - else - { - float offsetX = (rotatedCenterBounds.origin.x + rotatedCenterBounds.size.width/2) - - (rotatedCenterBoundsOriginal.origin.x + rotatedCenterBoundsOriginal.size.width/2); - float offsetY = (rotatedCenterBoundsOriginal.origin.y + rotatedCenterBoundsOriginal.size.height/2) - - (rotatedCenterBounds.origin.y + rotatedCenterBounds.size.height/2); - _centerOffset.x = offsetX; - _centerOffset.y = offsetY; - } - - //shrink the image size when it is 9-patch - if(_isPatch9) - { - float offset = 1.0f; - //Top left - if(!_spriteFrameRotated) + Texture2D *tex = _scale9Image ? _scale9Image->getTexture() : nullptr; + + if (tex == nullptr) { - rotatedLeftTopBounds.origin.x+=offset; - rotatedLeftTopBounds.origin.y+=offset; - rotatedLeftTopBounds.size.width-=offset; - rotatedLeftTopBounds.size.height-=offset; - //Center left - rotatedLeftCenterBounds.origin.x+=offset; - rotatedLeftCenterBounds.size.width-=offset; - //Bottom left - rotatedLeftBottomBounds.origin.x+=offset; - rotatedLeftBottomBounds.size.width-=offset; - rotatedLeftBottomBounds.size.height-=offset; - //Top center - rotatedCenterTopBounds.size.height-=offset; - rotatedCenterTopBounds.origin.y+=offset; - //Bottom center - rotatedCenterBottomBounds.size.height-=offset; - //Top right - rotatedRightTopBounds.size.width-=offset; - rotatedRightTopBounds.size.height-=offset; - rotatedRightTopBounds.origin.y+=offset; - //Center right - rotatedRightCenterBounds.size.width-=offset; - //Bottom right - rotatedRightBottomBounds.size.width-=offset; - rotatedRightBottomBounds.size.height-=offset; + return; } - else + + auto capInsets = CC_RECT_POINTS_TO_PIXELS(_capInsetsInternal); + auto textureRect = CC_RECT_POINTS_TO_PIXELS(_spriteRect); + auto spriteRectSize = CC_SIZE_POINTS_TO_PIXELS(_originalSize); + + //handle .9.png + if (_isPatch9) { - //Top left - rotatedLeftTopBounds.size.width-=offset; - rotatedLeftTopBounds.size.height-=offset; - rotatedLeftTopBounds.origin.y+=offset; - //Center left - rotatedLeftCenterBounds.origin.y+=offset; - rotatedLeftCenterBounds.size.width-=offset; - //Bottom left - rotatedLeftBottomBounds.origin.x+=offset; - rotatedLeftBottomBounds.origin.y+=offset; - rotatedLeftBottomBounds.size.width-=offset; - rotatedLeftBottomBounds.size.height-=offset; - //Top center - rotatedCenterTopBounds.size.height-=offset; - //Bottom center - rotatedCenterBottomBounds.size.height-=offset; - rotatedCenterBottomBounds.origin.x+=offset; - //Top right - rotatedRightTopBounds.size.width-=offset; - rotatedRightTopBounds.size.height-=offset; - //Center right - rotatedRightCenterBounds.size.width-=offset; - //Bottom right - rotatedRightBottomBounds.size.width-=offset; - rotatedRightBottomBounds.size.height-=offset; - rotatedRightBottomBounds.origin.x+=offset; + spriteRectSize = Size(spriteRectSize.width - 2, spriteRectSize.height-2); } - } - - // Centre - if(rotatedCenterBounds.size.width > 0 && rotatedCenterBounds.size.height > 0 ) - { - _centerSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedCenterBounds, - _spriteFrameRotated); - _centerSprite->retain(); - this->addProtectedChild(_centerSprite); - } - - // Top - if(rotatedCenterTopBounds.size.width > 0 && rotatedCenterTopBounds.size.height > 0 ) - { - _topSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedCenterTopBounds, - _spriteFrameRotated); - _topSprite->retain(); - this->addProtectedChild(_topSprite); - } - - // Bottom - if(rotatedCenterBottomBounds.size.width > 0 && rotatedCenterBottomBounds.size.height > 0 ) - { - _bottomSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedCenterBottomBounds, - _spriteFrameRotated); - _bottomSprite->retain(); - this->addProtectedChild(_bottomSprite); - } - - // Left - if(rotatedLeftCenterBounds.size.width > 0 && rotatedLeftCenterBounds.size.height > 0 ) - { - _leftSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedLeftCenterBounds, - _spriteFrameRotated); - _leftSprite->retain(); - this->addProtectedChild(_leftSprite); - } - - // Right - if(rotatedRightCenterBounds.size.width > 0 && rotatedRightCenterBounds.size.height > 0 ) - { - _rightSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedRightCenterBounds, - _spriteFrameRotated); - _rightSprite->retain(); - this->addProtectedChild(_rightSprite); - } - - // Top left - if(rotatedLeftTopBounds.size.width > 0 && rotatedLeftTopBounds.size.height > 0 ) - { - _topLeftSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedLeftTopBounds, - _spriteFrameRotated); - _topLeftSprite->retain(); - this->addProtectedChild(_topLeftSprite); - } - - // Top right - if(rotatedRightTopBounds.size.width > 0 && rotatedRightTopBounds.size.height > 0 ) - { - _topRightSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedRightTopBounds, - _spriteFrameRotated); - _topRightSprite->retain(); - this->addProtectedChild(_topRightSprite); - } - - // Bottom left - if(rotatedLeftBottomBounds.size.width > 0 && rotatedLeftBottomBounds.size.height > 0 ) - { - _bottomLeftSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedLeftBottomBounds, - _spriteFrameRotated); - _bottomLeftSprite->retain(); - this->addProtectedChild(_bottomLeftSprite); - } - - // Bottom right - if(rotatedRightBottomBounds.size.width > 0 && rotatedRightBottomBounds.size.height > 0 ) - { - _bottomRightSprite = Sprite::createWithTexture(_scale9Image->getTexture(), - rotatedRightBottomBounds, - _spriteFrameRotated); - _bottomRightSprite->retain(); - this->addProtectedChild(_bottomRightSprite); + + + if(capInsets.equals(Rect::ZERO)) + { + capInsets = Rect(spriteRectSize.width/3, spriteRectSize.height/3, + spriteRectSize.width/3, spriteRectSize.height/3); + } + + auto uv = this->calculateUV(tex, capInsets, spriteRectSize); + auto vertices = this->calculateVertices(capInsets, spriteRectSize); + auto triangles = this->calculateTriangles(uv, vertices); + + _scale9Image->getPolygonInfo().setTriangles(triangles); } } void Scale9Sprite::setContentSize(const Size &size) { + if (_contentSize.equals(size)) + { + return; + } Node::setContentSize(size); - this->_positionsAreDirty = true; + _preferredSize = size; + this->createSlicedSprites(); + this->adjustScale9ImagePosition(); } - void Scale9Sprite::updatePositions() - { - Size size = this->_contentSize; - - float sizableWidth = size.width - _topLeftSize.width - _bottomRightSize.width; - float sizableHeight = size.height - _topLeftSize.height - _bottomRightSize.height; - - float horizontalScale = sizableWidth/_centerSize.width; - float verticalScale = sizableHeight/_centerSize.height; - - if(_centerSprite) - { - _centerSprite->setScaleX(horizontalScale); - _centerSprite->setScaleY(verticalScale); - } - - float rescaledWidth = _centerSize.width * horizontalScale; - float rescaledHeight = _centerSize.height * verticalScale; - - float leftWidth = _topLeftSize.width; - float bottomHeight = _bottomRightSize.height; - - Vec2 centerOffset(_centerOffset.x * horizontalScale, _centerOffset.y * verticalScale); - - // Position corners - if(_bottomLeftSprite) - { - _bottomLeftSprite->setAnchorPoint(Vec2(1,1)); - _bottomLeftSprite->setPosition(leftWidth,bottomHeight); - } - if(_bottomRightSprite) - { - _bottomRightSprite->setAnchorPoint(Vec2(0,1)); - _bottomRightSprite->setPosition(leftWidth+rescaledWidth,bottomHeight); - } - if(_topLeftSprite) - { - _topLeftSprite->setAnchorPoint(Vec2(1,0)); - _topLeftSprite->setPosition(leftWidth, bottomHeight+rescaledHeight); - } - if(_topRightSprite) - { - _topRightSprite->setAnchorPoint(Vec2(0,0)); - _topRightSprite->setPosition(leftWidth+rescaledWidth, bottomHeight+rescaledHeight); - } - - // Scale and position borders - if(_leftSprite) - { - _leftSprite->setAnchorPoint(Vec2(1,0.5)); - _leftSprite->setPosition(leftWidth, bottomHeight+rescaledHeight/2 + centerOffset.y); - _leftSprite->setScaleY(verticalScale); - } - if(_rightSprite) - { - _rightSprite->setAnchorPoint(Vec2(0,0.5)); - _rightSprite->setPosition(leftWidth+rescaledWidth,bottomHeight+rescaledHeight/2 + centerOffset.y); - _rightSprite->setScaleY(verticalScale); - } - if(_topSprite) - { - _topSprite->setAnchorPoint(Vec2(0.5,0)); - _topSprite->setPosition(leftWidth+rescaledWidth/2 + centerOffset.x,bottomHeight+rescaledHeight); - _topSprite->setScaleX(horizontalScale); - } - if(_bottomSprite) - { - _bottomSprite->setAnchorPoint(Vec2(0.5,1)); - _bottomSprite->setPosition(leftWidth+rescaledWidth/2 + centerOffset.x,bottomHeight); - _bottomSprite->setScaleX(horizontalScale); - } - // Position centre - if(_centerSprite) - { - _centerSprite->setAnchorPoint(Vec2(0.5,0.5)); - _centerSprite->setPosition(leftWidth+rescaledWidth/2 + centerOffset.x, - bottomHeight+rescaledHeight/2 + centerOffset.y); - _centerSprite->setScaleX(horizontalScale); - _centerSprite->setScaleY(verticalScale); - } - } - - - Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(const Rect& capInsets) const { Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); if ( pReturn && pReturn->init(_scale9Image, _spriteRect, _spriteFrameRotated, - _offset, + Vec2::ZERO, _originalSize, - _capInsets) ) + _capInsetsInternal) ) { pReturn->autorelease(); return pReturn; @@ -1081,13 +575,6 @@ namespace ui { _scale9Image->setGLProgramState(glState); } - if (_scale9Enabled) - { - for (auto& sp : _protectedChildren) - { - sp->setGLProgramState(glState); - } - } _brightState = state; } @@ -1101,17 +588,10 @@ namespace ui { void Scale9Sprite::updateCapInset() { Rect insets; - if (this->_insetLeft == 0 && this->_insetTop == 0 && this->_insetRight == 0 && this->_insetBottom == 0) - { - insets = Rect::ZERO; - } - else - { - insets = Rect(_insetLeft, - _insetTop, - _originalSize.width-_insetLeft-_insetRight, - _originalSize.height-_insetTop-_insetBottom); - } + insets = Rect(_insetLeft, + _insetTop, + _originalSize.width-_insetLeft-_insetRight, + _originalSize.height-_insetTop-_insetBottom); this->setCapInsets(insets); } @@ -1136,7 +616,6 @@ namespace ui { void Scale9Sprite::setPreferredSize(const Size& preferredSize) { this->setContentSize(preferredSize); - this->_preferredSize = preferredSize; } @@ -1146,7 +625,7 @@ namespace ui { this->updateWithSprite(this->_scale9Image, _spriteRect, _spriteFrameRotated, - _offset, + Vec2::ZERO, _originalSize, capInsets); this->_insetLeft = capInsets.origin.x; @@ -1201,10 +680,8 @@ namespace ui { director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); int i = 0; // used by _children - int j = 0; // used by _protectedChildren sortAllChildren(); - sortAllProtectedChildren(); // // draw children and protectedChildren zOrder < 0 @@ -1219,25 +696,11 @@ namespace ui { break; } - if (_scale9Enabled) + if (_scale9Image && _scale9Image->getLocalZOrder() < 0 ) { - for( ; j < _protectedChildren.size(); j++ ) - { - auto node = _protectedChildren.at(j); - - if ( node && node->getLocalZOrder() < 0 ) - node->visit(renderer, _modelViewTransform, flags); - else - break; - } - } - else - { - if (_scale9Image && _scale9Image->getLocalZOrder() < 0 ) - { - _scale9Image->visit(renderer, _modelViewTransform, flags); - } + _scale9Image->visit(renderer, _modelViewTransform, flags); } + // // draw self @@ -1248,17 +711,9 @@ namespace ui { // // draw children and protectedChildren zOrder >= 0 // - if (_scale9Enabled) + if (_scale9Image && _scale9Image->getLocalZOrder() >= 0 ) { - for(auto it=_protectedChildren.cbegin()+j; it != _protectedChildren.cend(); ++it) - (*it)->visit(renderer, _modelViewTransform, flags); - } - else - { - if (_scale9Image && _scale9Image->getLocalZOrder() >= 0 ) - { - _scale9Image->visit(renderer, _modelViewTransform, flags); - } + _scale9Image->visit(renderer, _modelViewTransform, flags); } @@ -1286,7 +741,7 @@ namespace ui { Rect Scale9Sprite::getCapInsets()const { - return _capInsets; + return _capInsetsInternal; } @@ -1319,7 +774,6 @@ namespace ui { _scale9Enabled = enabled; this->cleanupSlicedSprites(); - _protectedChildren.clear(); //we must invalide the transform when toggling scale9enabled _transformUpdated = _transformDirty = _inverseDirty = true; @@ -1331,51 +785,30 @@ namespace ui { this->updateWithSprite(this->_scale9Image, _spriteRect, _spriteFrameRotated, - _offset, + Vec2::ZERO, _originalSize, - _capInsets); + _capInsetsInternal); } } - _positionsAreDirty = true; + else + { + if (_scale9Image) + { + auto quad = _scale9Image->getQuad(); + PolygonInfo polyInfo; + polyInfo.setQuad(&quad); + _scale9Image->setPolygonInfo(polyInfo); + } + + } + this->adjustScale9ImagePosition(); } bool Scale9Sprite::isScale9Enabled() const { return _scale9Enabled; } - - void Scale9Sprite::addProtectedChild(cocos2d::Node *child) - { - _reorderProtectedChildDirty = true; - _protectedChildren.pushBack(child); - } - - void Scale9Sprite::sortAllProtectedChildren() - { - if(this->_positionsAreDirty) - { - this->updatePositions(); - this->adjustScale9ImagePosition(); - this->_positionsAreDirty = false; - } - if( _reorderProtectedChildDirty ) - { - std::sort( std::begin(_protectedChildren), - std::end(_protectedChildren), - nodeComparisonLess ); - _reorderProtectedChildDirty = false; - } - } - - void Scale9Sprite::adjustScale9ImagePosition() - { - if (_scale9Image) - { - _scale9Image->setPosition(_contentSize.width * _scale9Image->getAnchorPoint().x, - _contentSize.height * _scale9Image->getAnchorPoint().y); - } - } - + void Scale9Sprite::setAnchorPoint(const cocos2d::Vec2 &position) { Node::setAnchorPoint(position); @@ -1383,85 +816,24 @@ namespace ui { { if (_scale9Image) { + _nonSliceSpriteAnchor = position; _scale9Image->setAnchorPoint(position); - _positionsAreDirty = true; + this->adjustScale9ImagePosition(); } } } - void Scale9Sprite::cleanup() + void Scale9Sprite::adjustScale9ImagePosition() { -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript) + if (_scale9Image) { - if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnCleanup)) - return; - } -#endif // #if CC_ENABLE_SCRIPT_BINDING - - Node::cleanup(); - // timers - for( const auto &child: _protectedChildren) - child->cleanup(); - } + if (!_scale9Enabled) { + _scale9Image->setAnchorPoint(_nonSliceSpriteAnchor); + _scale9Image->setPosition(_contentSize.width * _scale9Image->getAnchorPoint().x, + _contentSize.height * _scale9Image->getAnchorPoint().y); - void Scale9Sprite::onEnter() - { -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript) - { - if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter)) - return; + } } -#endif - Node::onEnter(); - for( const auto &child: _protectedChildren) - child->onEnter(); - } - - void Scale9Sprite::onExit() - { -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript) - { - if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnExit)) - return; - } -#endif - - Node::onExit(); - for( const auto &child: _protectedChildren) - child->onExit(); - } - - void Scale9Sprite::onEnterTransitionDidFinish() - { -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript) - { - if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnterTransitionDidFinish)) - return; - } -#endif - - Node::onEnterTransitionDidFinish(); - for( const auto &child: _protectedChildren) - child->onEnterTransitionDidFinish(); - } - - void Scale9Sprite::onExitTransitionDidStart() - { -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript) - { - if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnExitTransitionDidStart)) - return; - } -#endif - - Node::onExitTransitionDidStart(); - for( const auto &child: _protectedChildren) - child->onExitTransitionDidStart(); } void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor) @@ -1475,12 +847,7 @@ namespace ui { { _scale9Image->updateDisplayedColor(_displayedColor); } - - for(const auto &child : _protectedChildren) - { - child->updateDisplayedColor(_displayedColor); - } - + if (_cascadeColorEnabled) { for(const auto &child : _children) @@ -1500,11 +867,6 @@ namespace ui { _scale9Image->updateDisplayedOpacity(_displayedOpacity); } - for(auto child : _protectedChildren) - { - child->updateDisplayedOpacity(_displayedOpacity); - } - if (_cascadeOpacityEnabled) { for(auto child : _children) @@ -1520,10 +882,7 @@ namespace ui { { child->updateDisplayedColor(Color3B::WHITE); } - for(auto child : _protectedChildren) - { - child->updateDisplayedColor(Color3B::WHITE); - } + if (_scale9Image) { _scale9Image->updateDisplayedColor(Color3B::WHITE); @@ -1537,10 +896,6 @@ namespace ui { for(auto child : _children){ child->updateDisplayedOpacity(255); } - - for(auto child : _protectedChildren){ - child->updateDisplayedOpacity(255); - } } Sprite* Scale9Sprite::getSprite()const @@ -1635,11 +990,227 @@ namespace ui { if(_scale9Image) _scale9Image->setCameraMask(mask,applyChildren); + } + + // (0,0) O = capInsets.origin + // v0---------------------- + // | | | | + // | | | | + // v1-------O------+------| + // | | | | + // | | | | + // v2-------+------+------| + // | | | | + // | | | | + // v3-------------------- (1,1) (texture coordinate is flipped) + // u0 u1 u2 u3 + std::vector Scale9Sprite::calculateUV(Texture2D *tex, + const Rect& capInsets, + const Size& spriteRectSize) + { + auto atlasWidth = tex->getPixelsWide(); + auto atlasHeight = tex->getPixelsHigh(); - for(auto& iter: _protectedChildren) + //caculate texture coordinate + float leftWidth = 0, centerWidth = 0, rightWidth = 0; + float topHeight = 0, centerHeight = 0, bottomHeight = 0; + + if (_spriteFrameRotated) { - iter->setCameraMask(mask); + rightWidth = capInsets.origin.y; + centerWidth = capInsets.size.height; + leftWidth = spriteRectSize.height - centerWidth - rightWidth; + + topHeight = capInsets.origin.x; + centerHeight = capInsets.size.width; + bottomHeight = spriteRectSize.width - (topHeight + centerHeight); } + else + { + leftWidth = capInsets.origin.x; + centerWidth = capInsets.size.width; + rightWidth = spriteRectSize.width - (leftWidth + centerWidth); + + topHeight = capInsets.origin.y; + centerHeight = capInsets.size.height; + bottomHeight =spriteRectSize.height - (topHeight + centerHeight); + } + + auto textureRect = CC_RECT_POINTS_TO_PIXELS(_spriteRect); + //handle .9.png + if (_isPatch9) + { + //This magic number is used to avoiding artifact with .9.png format. + float offset = 1.3f; + textureRect = Rect(textureRect.origin.x + offset, + textureRect.origin.y + offset, + textureRect.size.width - 2, + textureRect.size.height - 2); + } + + //uv computation should take spritesheet into account. + float u0, u1, u2, u3; + float v0, v1, v2, v3; + if (_spriteFrameRotated) + { + u0 = textureRect.origin.x / atlasWidth; + u1 = (leftWidth + textureRect.origin.x) / atlasWidth; + u2 = (leftWidth + centerWidth + textureRect.origin.x) / atlasWidth; + u3 = (textureRect.origin.x + textureRect.size.height) / atlasWidth; + + v3 = textureRect.origin.y / atlasHeight; + v2 = (topHeight + textureRect.origin.y) / atlasHeight; + v1 = (topHeight + centerHeight + textureRect.origin.y) / atlasHeight; + v0 = (textureRect.origin.y + textureRect.size.width) / atlasHeight; + } + else + { + u0 = textureRect.origin.x / atlasWidth; + u1 = (leftWidth + textureRect.origin.x) / atlasWidth; + u2 = (leftWidth + centerWidth + textureRect.origin.x) / atlasWidth; + u3 = (textureRect.origin.x + textureRect.size.width) / atlasWidth; + + v0 = textureRect.origin.y / atlasHeight; + v1 = (topHeight + textureRect.origin.y) / atlasHeight; + v2 = (topHeight + centerHeight + textureRect.origin.y) / atlasHeight; + v3 = (textureRect.origin.y + textureRect.size.height) / atlasHeight; + } + + std::vector uvCoordinates = {Vec2(u0,v3), Vec2(u1,v2), Vec2(u2,v1), Vec2(u3,v0)}; + + return uvCoordinates; + } + + // + // y3----------------------(preferedSize.width, preferedSize.height) + // | | | | + // | | | | + // y2-------O------+------| + // | | | | + // | | | | + // y1-------+------+------| + // | | | | + // | | | | + //x0,y0-------------------- + // x1 x2 x3 + std::vector Scale9Sprite::calculateVertices(const Rect& capInsets, + const Size& spriteRectSize) + { + float leftWidth = 0, centerWidth = 0, rightWidth = 0; + float topHeight = 0, centerHeight = 0, bottomHeight = 0; + + leftWidth = capInsets.origin.x; + centerWidth = capInsets.size.width; + rightWidth = spriteRectSize.width - (leftWidth + centerWidth); + + topHeight = capInsets.origin.y; + centerHeight = capInsets.size.height; + bottomHeight = spriteRectSize.height - (topHeight + centerHeight); + + + leftWidth = leftWidth / CC_CONTENT_SCALE_FACTOR(); + rightWidth = rightWidth / CC_CONTENT_SCALE_FACTOR(); + topHeight = topHeight / CC_CONTENT_SCALE_FACTOR(); + bottomHeight = bottomHeight / CC_CONTENT_SCALE_FACTOR(); + float sizableWidth = _preferredSize.width - leftWidth - rightWidth; + float sizableHeight = _preferredSize.height - topHeight - bottomHeight; + float x0,x1,x2,x3; + float y0,y1,y2,y3; + if(sizableWidth >= 0) + { + x0 = 0; + x1 = leftWidth; + x2 = leftWidth + sizableWidth; + x3 = _preferredSize.width; + } + else + { + float xScale = _preferredSize.width / (leftWidth + rightWidth); + x0 = 0; + x1 = x2 = leftWidth * xScale; + x3 = (leftWidth + rightWidth) * xScale; + } + + if(sizableHeight >= 0) + { + y0 = 0; + y1 = bottomHeight; + y2 = bottomHeight + sizableHeight; + y3 = _preferredSize.height; + } + else + { + float yScale = _preferredSize.height / (topHeight + bottomHeight); + y0 = 0; + y1 = y2= bottomHeight * yScale; + y3 = (bottomHeight + topHeight) * yScale; + } + + std::vector vertices = {Vec2(x0,y0), Vec2(x1,y1), Vec2(x2,y2), Vec2(x3,y3)}; + return vertices; + } + + TrianglesCommand::Triangles Scale9Sprite::calculateTriangles(const std::vector& uv, + const std::vector& vertices) + { + const unsigned short slicedTotalVertexCount = 16; + const unsigned short slicedTotalIndices = 54; + CC_SAFE_DELETE_ARRAY(_sliceVertices); + CC_SAFE_DELETE_ARRAY(_sliceIndices); + + _sliceVertices = new V3F_C4B_T2F[slicedTotalVertexCount]; + _sliceIndices = new unsigned short[slicedTotalIndices]; + + unsigned short indicesStart = 0; + const unsigned short indicesOffset = 6; + const unsigned short quadIndices[]={4,0,5, 1,5,0}; + + Color4B color4 = Color4B(_scale9Image->getDisplayedColor()); + + for (int j = 0; j <= 3; ++j) + { + for (int i = 0; i <= 3; ++i) + { + V3F_C4B_T2F vertextData; + vertextData.vertices.x = vertices[i].x; + vertextData.vertices.y = vertices[j].y; + + if (_spriteFrameRotated) + { + vertextData.texCoords.u = uv[j].x; + vertextData.texCoords.v = uv[i].y; + } + else + { + vertextData.texCoords.u = uv[i].x; + vertextData.texCoords.v = uv[j].y; + } + + vertextData.colors = color4; + + if (i < 3 && j < 3) + { + memcpy(_sliceIndices + indicesStart, quadIndices, indicesOffset * sizeof(unsigned short)); + + for (int k = 0; k < indicesOffset; ++k) + { + unsigned short actualIndex = (i + j * 3) * indicesOffset; + _sliceIndices[k + actualIndex] = _sliceIndices[k + actualIndex] + j * 4 + i; + } + indicesStart = indicesStart + indicesOffset; + } + + memcpy(_sliceVertices + i + j * 4, &vertextData, sizeof(V3F_C4B_T2F)); + } + } + + TrianglesCommand::Triangles triangles; + triangles.vertCount = slicedTotalVertexCount; + triangles.indexCount = slicedTotalIndices; + triangles.verts = _sliceVertices; + triangles.indices = _sliceIndices; + + return triangles; } }} diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index 7743d21359..60cd087a59 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -30,6 +30,7 @@ #include "2d/CCSpriteBatchNode.h" #include "platform/CCPlatformMacros.h" #include "ui/GUIExport.h" +#include "renderer/CCTrianglesCommand.h" /** * @addtogroup ui @@ -457,7 +458,7 @@ namespace ui { // overrides virtual void setContentSize(const Size & size) override; virtual void setAnchorPoint(const Vec2& anchorPoint) override; - + /** * Change the state of 9-slice sprite. * @see `State` @@ -584,38 +585,6 @@ namespace ui { /// @} end of Children and Parent virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; - virtual void cleanup() override; - - /** - * @lua NA - */ - virtual void onEnter() override; - - /** Event callback that is invoked when the Node enters in the 'stage'. - * If the Node enters the 'stage' with a transition, this event is called when the transition finishes. - * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish() - * @js NA - * @lua NA - */ - virtual void onEnterTransitionDidFinish() override; - - /** - * Event callback that is invoked every time the Node leaves the 'stage'. - * If the Node leaves the 'stage' with a transition, this event is called when the transition finishes. - * During onExit you can't access a sibling node. - * If you override onExit, you shall call its parent's one, e.g., Node::onExit(). - * @js NA - * @lua NA - */ - virtual void onExit() override; - - /** - * Event callback that is called every time the Node leaves the 'stage'. - * If the Node leaves the 'stage' with a transition, this callback is called when the transition starts. - * @js NA - * @lua NA - */ - virtual void onExitTransitionDidStart() override; virtual void updateDisplayedOpacity(GLubyte parentOpacity) override; virtual void updateDisplayedColor(const Color3B& parentColor) override; @@ -681,57 +650,34 @@ namespace ui { virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override; protected: void updateCapInset(); - void updatePositions(); void createSlicedSprites(); void cleanupSlicedSprites(); void adjustScale9ImagePosition(); void applyBlendFunc(); void updateBlendFunc(Texture2D *texture); - /** - * Sorts the children array once before drawing, instead of every time when a child is added or reordered. - * This approach can improves the performance massively. - * @note Don't call this manually unless a child added needs to be removed in the same frame - */ - virtual void sortAllProtectedChildren(); + std::vector calculateUV(Texture2D *tex, const Rect& capInsets, + const Size& spriteRectSize); + std::vector calculateVertices(const Rect& capInsets, const Size& spriteRectSize); + TrianglesCommand::Triangles calculateTriangles(const std::vector& uv, + const std::vector& vertices); bool _spritesGenerated; Rect _spriteRect; bool _spriteFrameRotated; Rect _capInsetsInternal; - bool _positionsAreDirty; Sprite* _scale9Image; //the original sprite - Sprite* _topLeftSprite; - Sprite* _topSprite; - Sprite* _topRightSprite; - Sprite* _leftSprite; - Sprite* _centerSprite; - Sprite* _rightSprite; - Sprite* _bottomLeftSprite; - Sprite* _bottomSprite; - Sprite* _bottomRightSprite; bool _scale9Enabled; BlendFunc _blendFunc; - Size _topLeftSize; - Size _centerSize; - Size _bottomRightSize; - Vec2 _centerOffset; - /** Original sprite's size. */ Size _originalSize; - Vec2 _offset; /** Preferred sprite's size. By default the preferred size is the original size. */ //if the preferredSize component is given as -1, it is ignored Size _preferredSize; - /** - * The end-cap insets. - * On a non-resizeable sprite, this property is set to CGRect::ZERO; the sprite - * does not use end caps and the entire sprite is subject to stretching. - */ - Rect _capInsets; + /** Sets the left side inset */ float _insetLeft; /** Sets the top side inset */ @@ -741,16 +687,14 @@ namespace ui { /** Sets the bottom side inset */ float _insetBottom; - /// helper that reorder a child - void addProtectedChild(Node* child); - - Vector _protectedChildren; ///holds the 9 sprites - bool _reorderProtectedChildDirty; - bool _flippedX; bool _flippedY; bool _isPatch9; State _brightState; + Vec2 _nonSliceSpriteAnchor; + + V3F_C4B_T2F* _sliceVertices; + unsigned short* _sliceIndices; }; }} //end of namespace From 9a14ad5b14cd7ae1a152e84dbab098581d7437c8 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 29 Oct 2015 14:27:27 +0800 Subject: [PATCH 042/192] fix a small bug related to non slice anchorPoint --- cocos/ui/UIScale9Sprite.cpp | 45 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 213038086e..1b73575a2e 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -49,9 +49,9 @@ namespace ui { ,_flippedY(false) ,_isPatch9(false) ,_brightState(State::NORMAL) + ,_nonSliceSpriteAnchor(Vec2::ANCHOR_MIDDLE) ,_sliceVertices(nullptr) ,_sliceIndices(nullptr) - ,_nonSliceSpriteAnchor(Vec2::ANCHOR_MIDDLE) { this->setAnchorPoint(Vec2(0.5,0.5)); } @@ -138,6 +138,7 @@ namespace ui { const Size &originalSize, const Rect& capInsets) { + bool ret = true; if(sprite) { auto texture = sprite->getTexture(); @@ -157,16 +158,16 @@ namespace ui { } } - - this->updateWithSprite(sprite, - rect, - rotated, - offset, - originalSize, - actualCapInsets); + + ret = this->updateWithSprite(sprite, + rect, + rotated, + offset, + originalSize, + actualCapInsets); } - return true; + return ret; } bool Scale9Sprite::initWithBatchNode(cocos2d::SpriteBatchNode *batchnode, @@ -391,6 +392,7 @@ namespace ui { const Size &originalSize, const Rect& capInsets) { + GLubyte opacity = getOpacity(); Color3B color = getColor(); @@ -421,15 +423,6 @@ namespace ui { { return false; } - _scale9Image->setAnchorPoint(Vec2::ZERO); - _scale9Image->setPosition(Vec2::ZERO); - - SpriteFrame *spriteFrame = _scale9Image->getSpriteFrame(); - - if (!spriteFrame) - { - return false; - } Rect rect(textureRect); Size size(originalSize); @@ -458,6 +451,8 @@ namespace ui { if (_scale9Enabled) { + _scale9Image->setAnchorPoint(Vec2::ZERO); + _scale9Image->setPosition(Vec2::ZERO); this->createSlicedSprites(); } @@ -487,33 +482,33 @@ namespace ui { if (_scale9Enabled) { Texture2D *tex = _scale9Image ? _scale9Image->getTexture() : nullptr; - + if (tex == nullptr) { return; } - + auto capInsets = CC_RECT_POINTS_TO_PIXELS(_capInsetsInternal); auto textureRect = CC_RECT_POINTS_TO_PIXELS(_spriteRect); auto spriteRectSize = CC_SIZE_POINTS_TO_PIXELS(_originalSize); - + //handle .9.png if (_isPatch9) { spriteRectSize = Size(spriteRectSize.width - 2, spriteRectSize.height-2); } - - + + if(capInsets.equals(Rect::ZERO)) { capInsets = Rect(spriteRectSize.width/3, spriteRectSize.height/3, spriteRectSize.width/3, spriteRectSize.height/3); } - + auto uv = this->calculateUV(tex, capInsets, spriteRectSize); auto vertices = this->calculateVertices(capInsets, spriteRectSize); auto triangles = this->calculateTriangles(uv, vertices); - + _scale9Image->getPolygonInfo().setTriangles(triangles); } } From 9aa1f7138d789f62bb959efc6ad36e88e4cc4420 Mon Sep 17 00:00:00 2001 From: Filipe Lemos Date: Thu, 29 Oct 2015 08:36:03 +0000 Subject: [PATCH 043/192] Added override keyword to getVersion --- cocos/platform/android/CCApplication-android.h | 2 +- cocos/platform/ios/CCApplication-ios.h | 2 +- cocos/platform/linux/CCApplication-linux.h | 2 +- cocos/platform/mac/CCApplication-mac.h | 2 +- cocos/platform/win32/CCApplication-win32.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/platform/android/CCApplication-android.h b/cocos/platform/android/CCApplication-android.h index 3783868235..3555255d0e 100644 --- a/cocos/platform/android/CCApplication-android.h +++ b/cocos/platform/android/CCApplication-android.h @@ -87,7 +87,7 @@ public: /** @brief Get application version. */ - virtual std::string getVersion(); + virtual std::string getVersion() override; /** @brief Open url in default browser diff --git a/cocos/platform/ios/CCApplication-ios.h b/cocos/platform/ios/CCApplication-ios.h index 63b3884369..411eac89e6 100644 --- a/cocos/platform/ios/CCApplication-ios.h +++ b/cocos/platform/ios/CCApplication-ios.h @@ -89,7 +89,7 @@ public: /** @brief Get application version. */ - virtual std::string getVersion(); + virtual std::string getVersion() override; /** @brief Open url in default browser diff --git a/cocos/platform/linux/CCApplication-linux.h b/cocos/platform/linux/CCApplication-linux.h index 7342269028..d96cb61115 100644 --- a/cocos/platform/linux/CCApplication-linux.h +++ b/cocos/platform/linux/CCApplication-linux.h @@ -81,7 +81,7 @@ public: /** @brief Get application version */ - virtual std::string getVersion(); + virtual std::string getVersion() override; /** @brief Open url in default browser diff --git a/cocos/platform/mac/CCApplication-mac.h b/cocos/platform/mac/CCApplication-mac.h index bf20f5c1e6..275164d678 100644 --- a/cocos/platform/mac/CCApplication-mac.h +++ b/cocos/platform/mac/CCApplication-mac.h @@ -94,7 +94,7 @@ public: /** @brief Get application version. */ - virtual std::string getVersion(); + virtual std::string getVersion() override; /** @brief Open url in default browser diff --git a/cocos/platform/win32/CCApplication-win32.h b/cocos/platform/win32/CCApplication-win32.h index 455e6d5b89..84b858c706 100644 --- a/cocos/platform/win32/CCApplication-win32.h +++ b/cocos/platform/win32/CCApplication-win32.h @@ -78,7 +78,7 @@ public: /** @brief Get application version */ - virtual std::string getVersion(); + virtual std::string getVersion() override; /** @brief Open url in default browser From 7c82f9fe881a53b1f709810c5509029e4a8650fa Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 29 Oct 2015 21:53:58 +0800 Subject: [PATCH 044/192] cache slice sprite calculation --- cocos/ui/UIScale9Sprite.cpp | 19 ++++++++++++------- cocos/ui/UIScale9Sprite.h | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 1b73575a2e..812e417f99 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -52,6 +52,7 @@ namespace ui { ,_nonSliceSpriteAnchor(Vec2::ANCHOR_MIDDLE) ,_sliceVertices(nullptr) ,_sliceIndices(nullptr) + ,_sliceSpriteDirty(false) { this->setAnchorPoint(Vec2(0.5,0.5)); } @@ -453,7 +454,7 @@ namespace ui { { _scale9Image->setAnchorPoint(Vec2::ZERO); _scale9Image->setPosition(Vec2::ZERO); - this->createSlicedSprites(); + _sliceSpriteDirty = true; } applyBlendFunc(); @@ -521,8 +522,8 @@ namespace ui { } Node::setContentSize(size); _preferredSize = size; - this->createSlicedSprites(); - this->adjustScale9ImagePosition(); + _sliceSpriteDirty = true; + this->adjustNoneScale9ImagePosition(); } Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(const Rect& capInsets) const @@ -533,7 +534,7 @@ namespace ui { _spriteFrameRotated, Vec2::ZERO, _originalSize, - _capInsetsInternal) ) + capInsets) ) { pReturn->autorelease(); return pReturn; @@ -663,6 +664,10 @@ namespace ui { { return; } + if (_scale9Enabled && _sliceSpriteDirty) { + this->createSlicedSprites(); + _sliceSpriteDirty = false; + } uint32_t flags = processParentFlags(parentTransform, parentFlags); @@ -796,7 +801,7 @@ namespace ui { } } - this->adjustScale9ImagePosition(); + this->adjustNoneScale9ImagePosition(); } bool Scale9Sprite::isScale9Enabled() const @@ -813,12 +818,12 @@ namespace ui { { _nonSliceSpriteAnchor = position; _scale9Image->setAnchorPoint(position); - this->adjustScale9ImagePosition(); + this->adjustNoneScale9ImagePosition(); } } } - void Scale9Sprite::adjustScale9ImagePosition() + void Scale9Sprite::adjustNoneScale9ImagePosition() { if (_scale9Image) { diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index 60cd087a59..ff6c6792b4 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -652,7 +652,7 @@ namespace ui { void updateCapInset(); void createSlicedSprites(); void cleanupSlicedSprites(); - void adjustScale9ImagePosition(); + void adjustNoneScale9ImagePosition(); void applyBlendFunc(); void updateBlendFunc(Texture2D *texture); std::vector calculateUV(Texture2D *tex, const Rect& capInsets, @@ -695,6 +695,7 @@ namespace ui { V3F_C4B_T2F* _sliceVertices; unsigned short* _sliceIndices; + bool _sliceSpriteDirty; }; }} //end of namespace From 14175341949c5b49f15ca9bb43113eeba5faadec Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 29 Oct 2015 23:13:36 +0800 Subject: [PATCH 045/192] add rendering type to scale9sprite --- cocos/ui/UIScale9Sprite.cpp | 100 ++++++++++++++---- cocos/ui/UIScale9Sprite.h | 20 ++++ .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 4 +- 3 files changed, 103 insertions(+), 21 deletions(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 812e417f99..6f204396a7 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -53,6 +53,7 @@ namespace ui { ,_sliceVertices(nullptr) ,_sliceIndices(nullptr) ,_sliceSpriteDirty(false) + ,_renderingType(RenderingType::SLICE) { this->setAnchorPoint(Vec2(0.5,0.5)); } @@ -1076,7 +1077,16 @@ namespace ui { v3 = (textureRect.origin.y + textureRect.size.height) / atlasHeight; } - std::vector uvCoordinates = {Vec2(u0,v3), Vec2(u1,v2), Vec2(u2,v1), Vec2(u3,v0)}; + + std::vector uvCoordinates; + if (_renderingType == RenderingType::SIMPLE) + { + uvCoordinates = {Vec2(u0,v3), Vec2(u3,v0)}; + } + else + { + uvCoordinates = {Vec2(u0,v3), Vec2(u1,v2), Vec2(u2,v1), Vec2(u3,v0)}; + } return uvCoordinates; } @@ -1146,15 +1156,24 @@ namespace ui { y3 = (bottomHeight + topHeight) * yScale; } - std::vector vertices = {Vec2(x0,y0), Vec2(x1,y1), Vec2(x2,y2), Vec2(x3,y3)}; + std::vector vertices; + + if (_renderingType == RenderingType::SIMPLE) + { + vertices = {Vec2(x0,y0), Vec2(x3,y3)}; + } + else + { + vertices = {Vec2(x0,y0), Vec2(x1,y1), Vec2(x2,y2), Vec2(x3,y3)}; + } return vertices; } TrianglesCommand::Triangles Scale9Sprite::calculateTriangles(const std::vector& uv, const std::vector& vertices) { - const unsigned short slicedTotalVertexCount = 16; - const unsigned short slicedTotalIndices = 54; + const unsigned short slicedTotalVertexCount = powf(uv.size(),2); + const unsigned short slicedTotalIndices = 6 * powf(uv.size() -1, 2); CC_SAFE_DELETE_ARRAY(_sliceVertices); CC_SAFE_DELETE_ARRAY(_sliceIndices); @@ -1163,13 +1182,16 @@ namespace ui { unsigned short indicesStart = 0; const unsigned short indicesOffset = 6; - const unsigned short quadIndices[]={4,0,5, 1,5,0}; + const unsigned short sliceQuadIndices[] = {4,0,5, 1,5,0}; + const unsigned short simpleQuadIndices[] = {0,1,2, 3,2,1}; + Color4B color4 = Color4B(_scale9Image->getDisplayedColor()); + int vertexCount = (int)(vertices.size() - 1); - for (int j = 0; j <= 3; ++j) + for (int j = 0; j <= vertexCount; ++j) { - for (int i = 0; i <= 3; ++i) + for (int i = 0; i <= vertexCount; ++i) { V3F_C4B_T2F vertextData; vertextData.vertices.x = vertices[i].x; @@ -1187,22 +1209,45 @@ namespace ui { } vertextData.colors = color4; - - if (i < 3 && j < 3) + + //if slice mode + if (_renderingType == RenderingType::SLICE) { - memcpy(_sliceIndices + indicesStart, quadIndices, indicesOffset * sizeof(unsigned short)); - - for (int k = 0; k < indicesOffset; ++k) - { - unsigned short actualIndex = (i + j * 3) * indicesOffset; - _sliceIndices[k + actualIndex] = _sliceIndices[k + actualIndex] + j * 4 + i; - } - indicesStart = indicesStart + indicesOffset; + memcpy(_sliceVertices + i + j * 4, &vertextData, sizeof(V3F_C4B_T2F)); + } + else + { + memcpy(_sliceVertices + i + j * 2, &vertextData, sizeof(V3F_C4B_T2F)); } - - memcpy(_sliceVertices + i + j * 4, &vertextData, sizeof(V3F_C4B_T2F)); } } + + if (_renderingType == RenderingType::SLICE) + { + for (int j = 0; j <= vertexCount; ++j) + { + for (int i = 0; i <= vertexCount; ++i) + { + if (i < 3 && j < 3) + { + memcpy(_sliceIndices + indicesStart, sliceQuadIndices, indicesOffset * sizeof(unsigned short)); + + for (int k = 0; k < indicesOffset; ++k) + { + unsigned short actualIndex = (i + j * 3) * indicesOffset; + _sliceIndices[k + actualIndex] = _sliceIndices[k + actualIndex] + j * 4 + i; + } + indicesStart = indicesStart + indicesOffset; + } + + } + } + } + + if (_renderingType == RenderingType::SIMPLE) + { + memcpy(_sliceIndices, simpleQuadIndices, indicesOffset * sizeof(unsigned short)); + } TrianglesCommand::Triangles triangles; triangles.vertCount = slicedTotalVertexCount; @@ -1212,5 +1257,22 @@ namespace ui { return triangles; } + + void Scale9Sprite::setRenderingType(cocos2d::ui::Scale9Sprite::RenderingType type) + { + _renderingType = type; + if (_renderingType == RenderingType::SIMPLE) + { + this->setInsetTop(0); + this->setInsetBottom(0); + this->setInsetLeft(0); + this->setInsetRight(0); + } + } + + Scale9Sprite::RenderingType Scale9Sprite::getRenderingType()const + { + return _renderingType; + } }} diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index ff6c6792b4..46dfe7d616 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -78,6 +78,12 @@ namespace ui { GRAY }; + enum class RenderingType + { + SIMPLE, + SLICE + }; + public: /** @@ -648,6 +654,19 @@ namespace ui { virtual float getScale() const override; using Node::getScaleZ; virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override; + + /** + * Set the slice sprite rendering type. + * When setting to SIMPLE, only 4 vertexes is used to rendering. + * otherwise 16 vertexes will be used to rendering. + * @see RenderingType + */ + void setRenderingType(RenderingType type); + + /** + * Return the slice sprite rendering type. + */ + RenderingType getRenderingType()const; protected: void updateCapInset(); void createSlicedSprites(); @@ -696,6 +715,7 @@ namespace ui { V3F_C4B_T2F* _sliceVertices; unsigned short* _sliceIndices; bool _sliceSpriteDirty; + RenderingType _renderingType; }; }} //end of namespace diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 187ca1e2cc..d86de82d73 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -345,7 +345,7 @@ bool UIS9FrameNameSpriteSheetCropped::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); - + blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPosition(Vec2(x, y)); this->addChild(blocks); @@ -366,7 +366,7 @@ bool UIS9FrameNameSpriteSheetCroppedRotated::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); - + blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPosition(Vec2(x, y)); this->addChild(blocks); From 11fc969ecbba5c3d5f1e1dec408a47d56a8a2c20 Mon Sep 17 00:00:00 2001 From: Filipe Lemos Date: Thu, 29 Oct 2015 17:14:32 +0000 Subject: [PATCH 046/192] Fixed inconsistency in getVersion() when no version is available on Android --- .../android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index bee8144410..282382da6f 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -217,7 +217,7 @@ public class Cocos2dxHelper { String version = Cocos2dxActivity.getContext().getPackageManager().getPackageInfo(Cocos2dxActivity.getContext().getPackageName(), 0).versionName; return version; } catch(Exception e) { - return "-"; + return ""; } } From f84c2de1e230eff2dc04c89eced9e0fdf581018a Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 30 Oct 2015 09:58:02 +0800 Subject: [PATCH 047/192] add sprite and scale9sprite batch test --- cocos/ui/UIScale9Sprite.cpp | 20 ++++--- cocos/ui/UIScale9Sprite.h | 1 + .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 55 ++++++++++++++++++- .../CocoStudioGUITest/UIScale9SpriteTest.h | 8 +++ 4 files changed, 75 insertions(+), 9 deletions(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 6f204396a7..28db149836 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -477,6 +477,14 @@ namespace ui { return true; } + + void Scale9Sprite::configureSimpleModeRendering() + { + this->setInsetTop(0); + this->setInsetBottom(0); + this->setInsetLeft(0); + this->setInsetRight(0); + } void Scale9Sprite::createSlicedSprites() { @@ -489,6 +497,11 @@ namespace ui { { return; } + + if (_renderingType == RenderingType::SIMPLE) + { + this->configureSimpleModeRendering(); + } auto capInsets = CC_RECT_POINTS_TO_PIXELS(_capInsetsInternal); auto textureRect = CC_RECT_POINTS_TO_PIXELS(_spriteRect); @@ -1261,13 +1274,6 @@ namespace ui { void Scale9Sprite::setRenderingType(cocos2d::ui::Scale9Sprite::RenderingType type) { _renderingType = type; - if (_renderingType == RenderingType::SIMPLE) - { - this->setInsetTop(0); - this->setInsetBottom(0); - this->setInsetLeft(0); - this->setInsetRight(0); - } } Scale9Sprite::RenderingType Scale9Sprite::getRenderingType()const diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index 46dfe7d616..593297fe4e 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -672,6 +672,7 @@ namespace ui { void createSlicedSprites(); void cleanupSlicedSprites(); void adjustNoneScale9ImagePosition(); + void configureSimpleModeRendering(); void applyBlendFunc(); void updateBlendFunc(Texture2D *texture); std::vector calculateUV(Texture2D *tex, const Rect& capInsets, diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index d86de82d73..362b57c2a4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -53,6 +53,7 @@ UIScale9SpriteTests::UIScale9SpriteTests() ADD_TEST_CASE(UIS9Flip); ADD_TEST_CASE(UIS9ChangeAnchorPoint); ADD_TEST_CASE(UIS9NinePatchTest); + ADD_TEST_CASE(UIS9BatchTest); } // UIScale9SpriteTest @@ -347,7 +348,7 @@ bool UIS9FrameNameSpriteSheetCropped::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPosition(Vec2(x, y)); - + blocks->setCapInsets(Rect(5,5,5,5)); this->addChild(blocks); return true; @@ -368,7 +369,7 @@ bool UIS9FrameNameSpriteSheetCroppedRotated::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPosition(Vec2(x, y)); - + blocks->setInsetBottom(10); this->addChild(blocks); return true; @@ -904,3 +905,53 @@ bool UIS9NinePatchTest::init() } return false; } + +bool UIS9BatchTest::init() +{ + if (UIScene::init()) { + SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/blocks9ss.plist"); + + auto winSize = Director::getInstance()->getVisibleSize(); + + auto label = Label::createWithSystemFont("Click Button to Add Sprite and Slice Sprite\nThe draw call should always be 19 after adding sprites", "Arial", 15); + label->setPosition(Vec2(winSize.width/2, winSize.height - 60)); + this->addChild(label); + + auto preferedSize = Size(150,99); + std::vector spriteFrameNameArray = {"blocks9.png", "blocks9r.png"}; + auto addSpriteButton = ui::Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); + addSpriteButton->setPosition(Vec2(winSize.width/2 - 50,winSize.height - 100)); + addSpriteButton->setTitleText("Add Normal Sprite"); + srand((unsigned)time(nullptr)); + addSpriteButton->addClickEventListener([=](Ref*){ + auto spriteFrameName = spriteFrameNameArray[rand()%2]; + auto sprite = Sprite::createWithSpriteFrameName(spriteFrameName); + sprite->setPosition(Vec2(rand() % (int)winSize.width + 50, winSize.height/2)); + this->addChild(sprite); + }); + this->addChild(addSpriteButton); + + auto addSliceSpriteButton = ui::Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); + addSliceSpriteButton->setPosition(Vec2(winSize.width/2 + 50,winSize.height - 100)); + addSliceSpriteButton->setTitleText("Add Slice Sprite"); + addSliceSpriteButton->addClickEventListener([=](Ref*){ + int random = rand()%2; + auto spriteFrameName = spriteFrameNameArray[random]; + auto sprite = ui::Scale9Sprite::createWithSpriteFrameName(spriteFrameName); + sprite->setPosition(Vec2(rand() % (int)winSize.width + 50, winSize.height/3)); + if (random == 0) { + sprite->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); + }else{ + sprite->setRenderingType(Scale9Sprite::RenderingType::SLICE); + } + sprite->setPreferredSize(preferedSize); + this->addChild(sprite); + }); + this->addChild(addSliceSpriteButton); + + + return true; + } + return false; +} + diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h index 4138593e26..d66d338194 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h @@ -258,4 +258,12 @@ public: virtual bool init() override; }; +class UIS9BatchTest: public UIScene +{ +public: + CREATE_FUNC(UIS9BatchTest); + + virtual bool init() override; +}; + #endif /* defined(__cocos2d_tests__UIScale9SpriteTest__) */ From 3e2094981f2d9a436914e230225227d1f3241327 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 30 Oct 2015 14:01:01 +0800 Subject: [PATCH 048/192] add scale9sprite rendering type test --- cocos/ui/UIScale9Sprite.cpp | 5 +++ .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 39 +++++++++++++++++++ .../CocoStudioGUITest/UIScale9SpriteTest.h | 8 ++++ 3 files changed, 52 insertions(+) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 28db149836..c20d440186 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -1273,7 +1273,12 @@ namespace ui { void Scale9Sprite::setRenderingType(cocos2d::ui::Scale9Sprite::RenderingType type) { + if (_renderingType == type) + { + return; + } _renderingType = type; + _sliceSpriteDirty = true; } Scale9Sprite::RenderingType Scale9Sprite::getRenderingType()const diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 362b57c2a4..408c61f91b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -54,6 +54,7 @@ UIScale9SpriteTests::UIScale9SpriteTests() ADD_TEST_CASE(UIS9ChangeAnchorPoint); ADD_TEST_CASE(UIS9NinePatchTest); ADD_TEST_CASE(UIS9BatchTest); + ADD_TEST_CASE(UIS9ToggleRenderingTypeTest); } // UIScale9SpriteTest @@ -955,3 +956,41 @@ bool UIS9BatchTest::init() return false; } +bool UIS9ToggleRenderingTypeTest::init() +{ + if (UIScene::init()) { + + auto winSize = Director::getInstance()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2 - 20); + + auto label = Label::createWithSystemFont("Click Button to toggle rendering type", "Arial", 15); + label->setPosition(Vec2(winSize.width/2, winSize.height - 60)); + this->addChild(label); + + auto blocks = ui::Scale9Sprite::create("Images/blocks9.png"); + + blocks->setPosition(Vec2(x, y)); + blocks->setPreferredSize(Size(96*2, 96)); + this->addChild(blocks); + + auto addSliceSpriteButton = ui::Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); + addSliceSpriteButton->setPosition(Vec2(winSize.width/2,winSize.height - 100)); + addSliceSpriteButton->setTitleText("Slice Rendering"); + addSliceSpriteButton->addClickEventListener([=](Ref*){ + if (blocks->getRenderingType() == Scale9Sprite::RenderingType::SLICE) { + blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); + addSliceSpriteButton->setTitleText("Simple Rendering"); + }else{ + blocks->setRenderingType(Scale9Sprite::RenderingType::SLICE); + addSliceSpriteButton->setTitleText("Slice Rendering"); + blocks->setCapInsets(Rect(96/3,96/3,96/3,96/3)); + } + }); + this->addChild(addSliceSpriteButton); + + return true; + } + return false; +} + diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h index d66d338194..87b328bf9c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h @@ -266,4 +266,12 @@ public: virtual bool init() override; }; +class UIS9ToggleRenderingTypeTest: public UIScene +{ +public: + CREATE_FUNC(UIS9ToggleRenderingTypeTest); + + virtual bool init() override; +}; + #endif /* defined(__cocos2d_tests__UIScale9SpriteTest__) */ From 61ce3e8a032d98c0019f0dcef77f30b50c8530a6 Mon Sep 17 00:00:00 2001 From: Filipe Lemos Date: Fri, 30 Oct 2015 10:02:07 +0000 Subject: [PATCH 049/192] Fixed warnings about missing override in CCApplication for iOS/Mac --- cocos/platform/ios/CCApplication-ios.h | 10 +++++----- cocos/platform/mac/CCApplication-mac.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos/platform/ios/CCApplication-ios.h b/cocos/platform/ios/CCApplication-ios.h index 411eac89e6..ea9f95d59a 100644 --- a/cocos/platform/ios/CCApplication-ios.h +++ b/cocos/platform/ios/CCApplication-ios.h @@ -67,24 +67,24 @@ public: @brief Callback by Director for limit FPS. @param interval The time, expressed in seconds, between current frame and next. */ - virtual void setAnimationInterval(float interval); + virtual void setAnimationInterval(float interval) override; /** @brief Get current language config @return Current language config */ - virtual LanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage() override; /** @brief Get current language iso 639-1 code @return Current language iso 639-1 code */ - virtual const char * getCurrentLanguageCode(); + virtual const char * getCurrentLanguageCode() override; /** @brief Get target platform */ - virtual Platform getTargetPlatform(); + virtual Platform getTargetPlatform() override; /** @brief Get application version. @@ -96,7 +96,7 @@ public: @param String with url to open. @return true if the resource located by the URL was successfully opened; otherwise false. */ - virtual bool openURL(const std::string &url); + virtual bool openURL(const std::string &url) override; /** @brief This function will be called when the application screen size is changed. diff --git a/cocos/platform/mac/CCApplication-mac.h b/cocos/platform/mac/CCApplication-mac.h index 275164d678..c056d73fe3 100644 --- a/cocos/platform/mac/CCApplication-mac.h +++ b/cocos/platform/mac/CCApplication-mac.h @@ -52,7 +52,7 @@ public: @brief Callback by Director for limit FPS. @param interval The time, which expressed in second in second, between current frame and next. */ - virtual void setAnimationInterval(float interval); + virtual void setAnimationInterval(float interval) override; /** @brief Get status bar rectangle in GLView window. @@ -78,18 +78,18 @@ public: @brief Get current language config @return Current language config */ - virtual LanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage() override; /** @brief Get current language iso 639-1 code @return Current language iso 639-1 code */ - virtual const char * getCurrentLanguageCode(); + virtual const char * getCurrentLanguageCode() override; /** @brief Get target platform */ - virtual Platform getTargetPlatform(); + virtual Platform getTargetPlatform() override; /** @brief Get application version. @@ -101,7 +101,7 @@ public: @param String with url to open. @return true if the resource located by the URL was successfully opened; otherwise false. */ - virtual bool openURL(const std::string &url); + virtual bool openURL(const std::string &url) override; /** * Sets the Resource root path. From 4f8982862582bdee68d6e2c90cdffbd2ab5382a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=B6sel?= Date: Mon, 2 Nov 2015 14:18:21 +0100 Subject: [PATCH 050/192] Removed PhysicsBody::update from PhysicsWorld --- cocos/physics/CCPhysicsWorld.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 73545d658b..a1d2c538f5 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -826,10 +826,6 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/) if (userCall) { cpSpaceStep(_cpSpace, delta); - for (auto& body : _bodies) - { - body->update(delta); - } } else { @@ -840,10 +836,6 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/) for (int i = 0; i < _substeps; ++i) { cpSpaceStep(_cpSpace, dt); - for (auto& body : _bodies) - { - body->update(dt); - } } _updateRateCount = 0; _updateTime = 0.0f; From c1a64e9243e21d7fc9a9b5dbe3f26f9a88df876f Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Fri, 6 Nov 2015 02:14:34 +0800 Subject: [PATCH 051/192] new implementation of EditBoxImpl-win32 --- cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp | 387 +++++++++++---------- cocos/ui/UIEditBox/UIEditBoxImpl-win32.h | 6 +- 2 files changed, 211 insertions(+), 182 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp index a311ea0075..b8faf4c3ca 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp @@ -37,10 +37,6 @@ #pragma warning (disable: 4312) -class CWin32InputBox; - -typedef void (*Win32InputBoxTextChange)(const char *pText, cocos2d::ui::EditBoxImplWin *ctx); - // Structure used to orient the inputbox behavior struct WIN32INPUTBOX_PARAM { @@ -72,12 +68,6 @@ struct WIN32INPUTBOX_PARAM IN DWORD nMaxLength; - IN OPTIONAL cocos2d::ui::EditBox::KeyboardReturnType eReturnType; - IN OPTIONAL cocos2d::ui::EditBox::InputMode eInputMode; - IN OPTIONAL cocos2d::ui::EditBox::InputFlag eInputFlag; - IN OPTIONAL Win32InputBoxTextChange lpfnOnTextChange; - IN OPTIONAL cocos2d::ui::EditBoxImplWin* lpCtx; - // Owner window HWND hwndOwner; HINSTANCE hInstance; @@ -96,17 +86,29 @@ private: static LRESULT CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); HWND _hwndEditCtrl; int _recursionDepth; + HHOOK _getMsgHook; + + cocos2d::ui::EditBox::KeyboardReturnType _returnType; + cocos2d::ui::EditBox::InputMode _inputMode; + cocos2d::ui::EditBox::InputFlag _inputFlag; + std::function _onTextChange; + std::function _onClose; void InitDialog(); - void SetParam(WIN32INPUTBOX_PARAM *); - WIN32INPUTBOX_PARAM * GetParam(); + static LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam); public: CWin32InputBox(WIN32INPUTBOX_PARAM *); ~CWin32InputBox(); - static INT_PTR InputBoxEx(WIN32INPUTBOX_PARAM *); + static INT_PTR InputBoxEx(WIN32INPUTBOX_PARAM *, + cocos2d::ui::EditBox::KeyboardReturnType eReturnType, + cocos2d::ui::EditBox::InputMode eInputMode, + cocos2d::ui::EditBox::InputFlag eInputFlag, + const std::function &onTextChange, + const std::function &onClose); + static INT_PTR InputBox( LPCSTR szTitle, LPCSTR szPrompt, @@ -117,11 +119,11 @@ public: cocos2d::ui::EditBox::KeyboardReturnType eReturnType, cocos2d::ui::EditBox::InputMode eInputMode, cocos2d::ui::EditBox::InputFlag eInputFlag, - Win32InputBoxTextChange lpfnOnTextChange, - cocos2d::ui::EditBoxImplWin *ctx); + const std::function &onTextChange, + const std::function &onClose); void SetText(const char *pText); - void Close(); + void Close(INT_PTR buttonId); }; @@ -221,27 +223,23 @@ WIN32INPUTBOX_PARAM::WIN32INPUTBOX_PARAM() CWin32InputBox::CWin32InputBox(WIN32INPUTBOX_PARAM *param) { - _param = param; + _param = new (std::nothrow) WIN32INPUTBOX_PARAM(*param); _hwndEditCtrl = NULL; _recursionDepth = 0; + _getMsgHook = NULL; } CWin32InputBox::~CWin32InputBox() { - + CC_SAFE_DELETE(_param); } -void CWin32InputBox::SetParam(WIN32INPUTBOX_PARAM *param) -{ - _param = param; -} - -WIN32INPUTBOX_PARAM *CWin32InputBox::GetParam() -{ - return _param; -} - -INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param) +INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param, + cocos2d::ui::EditBox::KeyboardReturnType eReturnType, + cocos2d::ui::EditBox::InputMode eInputMode, + cocos2d::ui::EditBox::InputFlag eInputFlag, + const std::function &onTextChange, + const std::function &onClose) { // Check mandatory parameters if (param->pstrResult == nullptr) @@ -309,15 +307,17 @@ INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param) dlgTemplate->y = param->yPos; } - CWin32InputBox inputbox(param); - s_win32InputBox = &inputbox; + CCAssert(s_win32InputBox == nullptr, ""); - // Resize dialog and SHOW or HIDE multiline - INT_PTR r = ::DialogBoxIndirectParam(param->hInstance, dlgTemplate, param->hwndOwner, (DLGPROC)DlgProc, (LPARAM)&inputbox); - param->hDlg = NULL; - s_win32InputBox = nullptr; + s_win32InputBox = new (std::nothrow) CWin32InputBox(param); + s_win32InputBox->_onTextChange = onTextChange; + s_win32InputBox->_onClose = onClose; - return r; + HWND hDlg = ::CreateDialogIndirectParam(param->hInstance, dlgTemplate, param->hwndOwner, (DLGPROC)DlgProc, (LPARAM)s_win32InputBox); + ::ShowWindow(hDlg, SW_SHOW); + ::EnableWindow(param->hwndOwner, FALSE); + + return TRUE; } INT_PTR CWin32InputBox::InputBox( @@ -330,8 +330,8 @@ INT_PTR CWin32InputBox::InputBox( cocos2d::ui::EditBox::KeyboardReturnType eReturnType, cocos2d::ui::EditBox::InputMode eInputMode, cocos2d::ui::EditBox::InputFlag eInputFlag, - Win32InputBoxTextChange lpfnOnTextChange, - cocos2d::ui::EditBoxImplWin *ctx) + const std::function &onTextChange, + const std::function &onClose) { WIN32INPUTBOX_PARAM param; @@ -341,18 +341,14 @@ INT_PTR CWin32InputBox::InputBox( param.nMaxLength = nResultSize; param.bMultiline = bMultiLine; param.hwndOwner = hwndParent; - param.eReturnType = eReturnType; - param.eInputMode = eInputMode; - param.eInputFlag = eInputFlag; - param.lpfnOnTextChange = lpfnOnTextChange; - param.lpCtx = ctx; - return InputBoxEx(¶m); + + return InputBoxEx(¶m, eReturnType, eInputMode, eInputFlag, onTextChange, onClose); } void CWin32InputBox::InitDialog() { // Set the button captions, associated with ReturnType - switch (_param->eReturnType) + switch (_returnType) { case cocos2d::ui::EditBox::KeyboardReturnType::DEFAULT: ::SetDlgItemTextW(_param->hDlg, IDOK, L"OK"); @@ -444,7 +440,7 @@ void CWin32InputBox::InitDialog() ::SendMessageW(hwndEdit2, EM_LIMITTEXT, (WPARAM)_param->nMaxLength, 0); } - switch (_param->eInputFlag) + switch (_inputFlag) { case cocos2d::ui::EditBox::InputFlag::PASSWORD: // Sets a password character displayed in a edit control when the user types text. @@ -468,7 +464,7 @@ void CWin32InputBox::InitDialog() break; } - switch (_param->eInputMode) + switch (_inputMode) { case cocos2d::ui::EditBox::InputMode::ANY: break; @@ -492,81 +488,91 @@ void CWin32InputBox::InitDialog() default: break; } + + CCAssert(_getMsgHook == NULL, ""); + + // To make the enter key work, here need a Windows Message hook. + // Please refer to https://support.microsoft.com/en-us/kb/187988 + _getMsgHook = ::SetWindowsHookEx(WH_GETMESSAGE, &CWin32InputBox::GetMsgProc, ::GetModuleHandle(nullptr), ::GetCurrentThreadId()); } -#define REDNERING_TIMER_ID 2015 +LRESULT CALLBACK CWin32InputBox::GetMsgProc(int code, WPARAM wParam, LPARAM lParam) +{ + if (code == HC_ACTION) + { + LPMSG lpMsg = (LPMSG)lParam; + if (lpMsg->message == WM_KEYDOWN) + { + if (lpMsg->wParam == VK_RETURN) // User has hit the ENTER key. + { + // Translate the message manually. + lpMsg->hwnd = s_win32InputBox->_param->hDlg; + lpMsg->message = WM_COMMAND; + lpMsg->wParam = IDOK; + } + } + } + return ::CallNextHookEx(s_win32InputBox->_getMsgHook, code, wParam, lParam); +} // Message handler for about box. LRESULT CALLBACK CWin32InputBox::DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { CWin32InputBox *_this = (CWin32InputBox *) ::GetWindowLongPtr(hDlg, GWLP_USERDATA); - WIN32INPUTBOX_PARAM *param = _this ? _this->GetParam() : 0; switch (message) { case WM_INITDIALOG: { - SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam); + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam); - _this = (CWin32InputBox *)lParam; - _this->_param->hDlg = hDlg; - _this->InitDialog(); - - // Set timer for rendering - TIMERPROC lpTimerFunc = [](HWND, UINT, UINT, DWORD) { - auto director = cocos2d::Director::getInstance(); - auto glview = director->getOpenGLView(); - director->mainLoop(); - glview->pollEvents(); - }; - ::SetTimer(hDlg, REDNERING_TIMER_ID, USER_TIMER_MINIMUM, lpTimerFunc); - return TRUE; + _this = (CWin32InputBox *)lParam; + _this->_param->hDlg = hDlg; + _this->InitDialog(); + return TRUE; } case WM_COMMAND: { #ifdef _MY_DEBUG - CHAR buf[1024]; - static int i = 0; - sprintf(buf, "WM_COMMAND: %09d wParam=%08X lParam=%08X\n", i++, wParam, lParam); - OutputDebugStringA(buf); + CHAR buf[1024]; + static int i = 0; + sprintf(buf, "WM_COMMAND: %09d wParam=%08X lParam=%08X\n", i++, wParam, lParam); + OutputDebugStringA(buf); #endif - INT_PTR buttonId = LOWORD(wParam); - if (buttonId == IDOK || buttonId == IDCANCEL) - { - // Yes! Just close the dialog box simply, - // because the text of EditBox has been already synced at the moment of text altered in the edit control - ::EndDialog(hDlg, buttonId); - return TRUE; - } + INT_PTR buttonId = LOWORD(wParam); + if (buttonId == IDOK || buttonId == IDCANCEL) + { + // Yes! Just close the dialog box simply, + // because the text of EditBox has been already synced at the moment of text altered in the edit control + _this->Close(buttonId); + return TRUE; + } - // text altered in the edit control - // Please refer to https://msdn.microsoft.com/en-us/library/bb761676%28v=vs.85%29.aspx - if (HIWORD(wParam) == EN_CHANGE && _this->_recursionDepth == 0 && _this->_param->lpfnOnTextChange != nullptr) - { - std::u16string wstrResult; - std::string utf8Result; + // text altered in the edit control + // Please refer to https://msdn.microsoft.com/en-us/library/bb761676%28v=vs.85%29.aspx + if (HIWORD(wParam) == EN_CHANGE && _this->_recursionDepth == 0) + { + std::u16string wstrResult; + std::string utf8Result; - int inputLength = ::GetWindowTextLengthW(_this->_hwndEditCtrl); - wstrResult.resize(inputLength); + int inputLength = ::GetWindowTextLengthW(_this->_hwndEditCtrl); + wstrResult.resize(inputLength); - ::GetWindowTextW( - _this->_hwndEditCtrl, - (LPWSTR) const_cast(wstrResult.c_str()), - inputLength+1); + ::GetWindowTextW(_this->_hwndEditCtrl, (LPWSTR) const_cast(wstrResult.c_str()), inputLength+1); + bool conversionResult = cocos2d::StringUtils::UTF16ToUTF8(wstrResult, utf8Result); + _this->_param->pstrResult->clear(); + ++_this->_recursionDepth; // Prevent recursive calls + if (conversionResult) + { + *(_this->_param->pstrResult) = std::move(utf8Result); + } - bool conversionResult = cocos2d::StringUtils::UTF16ToUTF8(wstrResult, utf8Result); - _this->_param->pstrResult->clear(); - ++_this->_recursionDepth; // Prevent recursive calls - if (conversionResult) - { - *(_this->_param->pstrResult) = std::move(utf8Result); - } - // Invoke editBoxTextChanged indirectly - _this->_param->lpfnOnTextChange(_this->_param->pstrResult->c_str(), _this->_param->lpCtx); - --_this->_recursionDepth; - return TRUE; - } + // Invoke editBoxTextChanged indirectly + _this->_onTextChange(_this->_param->pstrResult->c_str()); + --_this->_recursionDepth; + return TRUE; + } } break; } @@ -592,12 +598,22 @@ void CWin32InputBox::SetText(const char* pText) } } -void CWin32InputBox::Close() +void CWin32InputBox::Close(INT_PTR buttonId) { + if (_getMsgHook != NULL) + { + ::UnhookWindowsHookEx(_getMsgHook); + _getMsgHook = NULL; + } + if (_param->hDlg != NULL) { - ::EndDialog(_param->hDlg, IDCANCEL); + ::EnableWindow(_param->hwndOwner, TRUE); + ::SetFocus(_param->hwndOwner); + ::DestroyWindow(_param->hDlg); _param->hDlg = NULL; + + _onClose(buttonId); } } @@ -622,7 +638,7 @@ EditBoxImplWin::EditBoxImplWin(EditBox* pEditText) , _maxLength(-1) , _isEditing(false) { - + } EditBoxImplWin::~EditBoxImplWin() @@ -640,7 +656,7 @@ bool EditBoxImplWin::initWithSize(const Size& size) //! int fontSize = getFontSizeAccordingHeightJni(size.height-12); _label = Label::create(); _label->setSystemFontSize(size.height-12); - // align the text vertically center + // align the text vertically center _label->setAnchorPoint(Vec2(0, 0.5f)); _label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height / 2.0f)); _label->setTextColor(_colText); @@ -648,42 +664,42 @@ bool EditBoxImplWin::initWithSize(const Size& size) _labelPlaceHolder = Label::create(); _labelPlaceHolder->setSystemFontSize(size.height-12); - // align the text vertically center + // align the text vertically center _labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f)); _labelPlaceHolder->setPosition(CC_EDIT_BOX_PADDING, size.height / 2.0f); _labelPlaceHolder->setVisible(false); _labelPlaceHolder->setTextColor(_colPlaceHolder); _editBox->addChild(_labelPlaceHolder); - + _editSize = size; return true; } void EditBoxImplWin::setFont(const char* pFontName, int fontSize) { - if (_label != nullptr) - { - if(strlen(pFontName) > 0) - { - _label->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _label->setSystemFontSize(fontSize); - } - } - - if (_labelPlaceHolder != nullptr) - { - if(strlen(pFontName) > 0) - { - _labelPlaceHolder->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _labelPlaceHolder->setSystemFontSize(fontSize); - } - } + if (_label != nullptr) + { + if (pFontName[0] != '\0') // To determine whether a string is empty quickly + { + _label->setSystemFontName(pFontName); + } + if (fontSize > 0) + { + _label->setSystemFontSize(fontSize); + } + } + + if (_labelPlaceHolder != nullptr) + { + if (pFontName[0] != '\0') // To determine whether a string is empty quickly + { + _labelPlaceHolder->setSystemFontName(pFontName); + } + if (fontSize > 0) + { + _labelPlaceHolder->setSystemFontSize(fontSize); + } + } } void EditBoxImplWin::setFontColor(const Color4B& color) @@ -694,17 +710,17 @@ void EditBoxImplWin::setFontColor(const Color4B& color) void EditBoxImplWin::setPlaceholderFont(const char* pFontName, int fontSize) { - if (_labelPlaceHolder != nullptr) - { - if(strlen(pFontName) > 0) - { - _labelPlaceHolder->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _labelPlaceHolder->setSystemFontSize(fontSize); - } - } + if (_labelPlaceHolder != nullptr) + { + if (pFontName[0] != '\0') // To determine whether a string is empty quickly + { + _labelPlaceHolder->setSystemFontName(pFontName); + } + if (fontSize > 0) + { + _labelPlaceHolder->setSystemFontSize(fontSize); + } + } } void EditBoxImplWin::setPlaceholderFontColor(const Color4B& color) @@ -762,9 +778,9 @@ void EditBoxImplWin::setText(const char* pText) { _labelPlaceHolder->setVisible(false); - if (EditBox::InputFlag::PASSWORD == _editBoxInputFlag) + if (EditBox::InputFlag::PASSWORD == _editBoxInputFlag) { - long length = StringUtils::getCharacterCountInUTF8String(_text); + long length = StringUtils::getCharacterCountInUTF8String(_text); std::string strToShow(length, '*'); // Fills strToShow with length consecutive copies of character '*' _label->setString(strToShow); } @@ -772,7 +788,7 @@ void EditBoxImplWin::setText(const char* pText) { _label->setString(_text); } - + float maxWidth = _editSize.width - 2 * CC_EDIT_BOX_PADDING; auto labelSize = _label->getContentSize(); if (labelSize.width > maxWidth) @@ -810,8 +826,8 @@ void EditBoxImplWin::setPlaceHolder(const char* pText) void EditBoxImplWin::setPosition(const Vec2& pos) { - //_label->setPosition(pos); - //_labelPlaceHolder->setPosition(pos); + //_label->setPosition(pos); + //_labelPlaceHolder->setPosition(pos); } void EditBoxImplWin::setVisible(bool visible) @@ -824,15 +840,19 @@ void EditBoxImplWin::setContentSize(const Size& size) void EditBoxImplWin::setAnchorPoint(const Vec2& anchorPoint) { // don't need to be implemented on win32 platform. - } void EditBoxImplWin::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) -{ +{ } void EditBoxImplWin::openKeyboard() { + if (s_win32InputBox != nullptr) + { + return; + } + if (_delegate != nullptr) { _delegate->editBoxEditingDidBegin(_editBox); @@ -843,38 +863,45 @@ void EditBoxImplWin::openKeyboard() auto editBox = this->getEditBox(); if (nullptr != editBox && 0 != editBox->getScriptEditBoxHandler()) { - CommonScriptData data(editBox->getScriptEditBoxHandler(), "began",editBox); - ScriptEvent event(kCommonEvent,(void*)&data); + CommonScriptData data(editBox->getScriptEditBoxHandler(), "began", editBox); + ScriptEvent event(kCommonEvent, (void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } #endif - - std::string placeHolder = _labelPlaceHolder->getString(); - if (placeHolder.length() == 0) - placeHolder = "Enter value"; - std::string text = getText(); - std::string originalText = text; - auto glView = Director::getInstance()->getOpenGLView(); - HWND hwnd = glView->getWin32Window(); - bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), &text, _maxLength, false, hwnd, + std::string placeHolder = _labelPlaceHolder->getString(); + if (placeHolder.length() == 0) + placeHolder = "Enter value"; + + _editingText = getText(); + _originalText = _editingText; + auto glView = Director::getInstance()->getOpenGLView(); + HWND hwnd = glView->getWin32Window(); + CWin32InputBox::InputBox("Input", placeHolder.c_str(), &_editingText, _maxLength, false, hwnd, _keyboardReturnType, _editBoxInputMode, _editBoxInputFlag, - &EditBoxImplWin::onWin32InputBoxTextChange, this) == IDOK; - _isEditing = false; - - setText(didChange ? text.c_str() : originalText.c_str()); + std::bind(&EditBoxImplWin::onWin32InputBoxTextChange, this, std::placeholders::_1), + std::bind(&EditBoxImplWin::onWin32InputBoxClose, this, std::placeholders::_1)); +} + +void EditBoxImplWin::onWin32InputBoxClose(INT_PTR buttonId) +{ + bool didChange = buttonId == IDOK; + CC_SAFE_DELETE(s_win32InputBox); + _isEditing = false; + + setText(didChange ? _editingText.c_str() : _originalText.c_str()); + + if (_delegate != nullptr) + { + _delegate->editBoxTextChanged(_editBox, getText()); + _delegate->editBoxEditingDidEnd(_editBox); + _delegate->editBoxReturn(_editBox); + } - if (_delegate != nullptr) - { - _delegate->editBoxTextChanged(_editBox, getText()); - _delegate->editBoxEditingDidEnd(_editBox); - _delegate->editBoxReturn(_editBox); - } - #if CC_ENABLE_SCRIPT_BINDING if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler()) { - CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox); + CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed", _editBox); ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); memset(data.eventName,0,sizeof(data.eventName)); @@ -889,23 +916,21 @@ void EditBoxImplWin::openKeyboard() #endif // #if CC_ENABLE_SCRIPT_BINDING } -void EditBoxImplWin::onWin32InputBoxTextChange(const char *pText, EditBoxImplWin* thiz) +void EditBoxImplWin::onWin32InputBoxTextChange(const char *pText) { - thiz->_isEditing = false; // Prevent recursive calls - thiz->setText(pText); - thiz->_isEditing = true; + _isEditing = false; // Prevent recursive calls + setText(pText); + _isEditing = true; - auto delegate = thiz->getDelegate(); - if (delegate != nullptr) + if (_delegate != nullptr) { - delegate->editBoxTextChanged(thiz->_editBox, thiz->_text); + _delegate->editBoxTextChanged(_editBox, _text); } #if CC_ENABLE_SCRIPT_BINDING - auto editBox = thiz->getEditBox(); - if (nullptr != editBox && 0 != editBox->getScriptEditBoxHandler()) + if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler()) { - CommonScriptData data(editBox->getScriptEditBoxHandler(), "changed", editBox); + CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed", _editBox); ScriptEvent event(kCommonEvent, (void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } @@ -917,8 +942,8 @@ void EditBoxImplWin::closeKeyboard() // close the running Win32InputBox if (s_win32InputBox != nullptr) { - s_win32InputBox->Close(); - s_win32InputBox = nullptr; + s_win32InputBox->Close(IDCANCEL); + CC_SAFE_DELETE(s_win32InputBox); _isEditing = false; } } diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h index 9ebfa94162..f18bd145df 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h @@ -105,8 +105,12 @@ private: HWND _sysEdit; int _maxTextLength; */ + std::string _editingText; + std::string _originalText; bool _isEditing; - static void onWin32InputBoxTextChange(const char *pText, EditBoxImplWin *thiz); + + void onWin32InputBoxTextChange(const char *pText); + void onWin32InputBoxClose(INT_PTR buttonId); }; From 1a56668cd33cf25a85e4e1c20ed933f05dc83896 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 6 Nov 2015 09:49:19 +0800 Subject: [PATCH 052/192] Fix "TextureCache Test" in js-test crash under Android --- cocos/network/CCDownloader-android.cpp | 16 +++++++++++++--- cocos/network/CCDownloader-android.h | 3 +++ cocos/platform/android/javaactivity-android.cpp | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cocos/network/CCDownloader-android.cpp b/cocos/network/CCDownloader-android.cpp index bc2db212bb..6da56ba79e 100644 --- a/cocos/network/CCDownloader-android.cpp +++ b/cocos/network/CCDownloader-android.cpp @@ -43,6 +43,7 @@ namespace cocos2d { namespace network { static int sTaskCounter; static int sDownloaderCounter; + static bool _registered = false; struct DownloadTaskAndroid : public IDownloadTask { @@ -53,7 +54,6 @@ namespace cocos2d { namespace network { } virtual ~DownloadTaskAndroid() { - DLLOG("Destruct DownloadTaskAndroid: %p", this); } @@ -66,7 +66,8 @@ namespace cocos2d { namespace network { , _impl(nullptr) { // use local static variable make sure native methods registered once - static bool _registered = _registerNativeMethods(JniHelper::getEnv()); + if(!_registered) + _registered = _registerNativeMethods(JniHelper::getEnv()); DLLOG("Construct DownloaderAndroid: %p", this); JniMethodInfo methodInfo; if (JniHelper::getStaticMethodInfo(methodInfo, @@ -163,6 +164,7 @@ namespace cocos2d { namespace network { } DownloadTaskAndroid *coTask = iter->second; string str = (errStr ? errStr : ""); + _taskMap.erase(iter); onTaskFinish(*coTask->task, errStr ? DownloadTask::ERROR_IMPL_INTERNAL : DownloadTask::ERROR_NO_ERROR, errCode, @@ -170,7 +172,15 @@ namespace cocos2d { namespace network { data ); coTask->task.reset(); - _taskMap.erase(iter); + } + + + void _preloadJavaDownloaderClass() + { + if(!_registered) + { + _registered = _registerNativeMethods(JniHelper::getEnv()); + } } } } // namespace cocos2d::network diff --git a/cocos/network/CCDownloader-android.h b/cocos/network/CCDownloader-android.h index 75f5a3a74e..868f602736 100644 --- a/cocos/network/CCDownloader-android.h +++ b/cocos/network/CCDownloader-android.h @@ -50,5 +50,8 @@ namespace cocos2d { namespace network std::unordered_map _taskMap; }; + // Load java downloader class from main thread, to void addImageAsync function + // perform in sub-thread cause java downloader unusable + void _preloadJavaDownloaderClass(); }} // namespace cocos2d::network diff --git a/cocos/platform/android/javaactivity-android.cpp b/cocos/platform/android/javaactivity-android.cpp index afcf93eca0..6e826c639e 100644 --- a/cocos/platform/android/javaactivity-android.cpp +++ b/cocos/platform/android/javaactivity-android.cpp @@ -36,6 +36,7 @@ THE SOFTWARE. #include "renderer/ccGLStateCache.h" #include "2d/CCDrawingPrimitives.h" #include "platform/android/jni/JniHelper.h" +#include "network/CCDownloader-android.h" #include #include @@ -81,6 +82,7 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, j director->getEventDispatcher()->dispatchEvent(&recreatedEvent); director->setGLDefaultValues(); } + cocos2d::network::_preloadJavaDownloaderClass(); } JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz) From 139d8b531082814341e9a9fedab8b08574be05db Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 6 Nov 2015 10:10:09 +0800 Subject: [PATCH 053/192] Remove unused code --- cocos/network/CCDownloader-android.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/cocos/network/CCDownloader-android.cpp b/cocos/network/CCDownloader-android.cpp index 6da56ba79e..c558ace317 100644 --- a/cocos/network/CCDownloader-android.cpp +++ b/cocos/network/CCDownloader-android.cpp @@ -65,9 +65,6 @@ namespace cocos2d { namespace network { : _id(++sDownloaderCounter) , _impl(nullptr) { - // use local static variable make sure native methods registered once - if(!_registered) - _registered = _registerNativeMethods(JniHelper::getEnv()); DLLOG("Construct DownloaderAndroid: %p", this); JniMethodInfo methodInfo; if (JniHelper::getStaticMethodInfo(methodInfo, From 668558b99f988d8fffa30d9e99e7954a7bc371c9 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 6 Nov 2015 11:38:41 +0800 Subject: [PATCH 054/192] Fix when leave "ComponentTest" scene, background music still go on playing in lua-test under Android system --- tests/lua-tests/src/ComponentTest/main.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/lua-tests/src/ComponentTest/main.lua b/tests/lua-tests/src/ComponentTest/main.lua index b5f4090d15..4a459048e5 100644 --- a/tests/lua-tests/src/ComponentTest/main.lua +++ b/tests/lua-tests/src/ComponentTest/main.lua @@ -30,10 +30,18 @@ local function ComponentTestLayer() cc.Director:getInstance():replaceScene(scene); end + local function onNodeEvent(event) + if "exit" == event then + ccexp.AudioEngine:stopAll() + end + end + layer._listener1 = cc.EventListenerCustom:create("component game over", onEvent) local eventDispatcher = cc.Director:getInstance():getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(layer._listener1, 1) + layer:registerScriptHandler(onNodeEvent) + return layer end From 76ed15591f8194545bf30d53b94ddb54263e5a06 Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Fri, 6 Nov 2015 11:56:45 +0800 Subject: [PATCH 055/192] Update web submodule to latest. --- .../studio/parsers/timelineParser-2.x.js | 412 +----------------- web | 2 +- 2 files changed, 16 insertions(+), 398 deletions(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index fa0f84aa6f..8eab3690b5 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -160,20 +160,12 @@ } }; - var skyBoxBrushInstance = null; - var getSkyboxRes = function(json, key) { - if(json.hasOwnProperty(key) && json[key].hasOwnProperty("Path")) { - return json[key]["Path"]; - } - return ""; - } - /** * SingleNode * @param json * @returns {cc.Node} */ - parser.initSingleNode = function(json, resourcePath){ + parser.initSingleNode = function(json){ var node = new cc.Node(); this.generalAttributes(node, json); @@ -181,27 +173,6 @@ if(color != null) node.setColor(getColor(color)); - if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"]&& - json.hasOwnProperty("SkyBoxValid") && true == json["SkyBoxValid"]) - { - var leftFileData = resourcePath + getSkyboxRes(json, "LeftImage"); - var rightFileData = resourcePath + getSkyboxRes(json, "RightImage"); - var upFileData = resourcePath + getSkyboxRes(json, "UpImage"); - var downFileData = resourcePath + getSkyboxRes(json, "DownImage"); - var forwardFileData = resourcePath + getSkyboxRes(json, "ForwardImage"); - var backFileData = resourcePath + getSkyboxRes(json, "BackImage"); - var fileUtil = jsb.fileUtils; - if(fileUtil.isFileExist(leftFileData)&& - fileUtil.isFileExist(rightFileData)&& - fileUtil.isFileExist(upFileData)&& - fileUtil.isFileExist(downFileData)&& - fileUtil.isFileExist(forwardFileData)&& - fileUtil.isFileExist(backFileData)) - { - skyBoxBrushInstance = cc.CameraBackgroundSkyBoxBrush.create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); - } - } - return node; }; @@ -257,6 +228,8 @@ var node, self = this; loadTexture(json["FileData"], resourcePath, function(path, type){ + if(!cc.loader.getRes(path)) + cc.log("%s need to be preloaded", path); node = new cc.ParticleSystem(path); self.generalAttributes(node, json); node.setPositionType(cc.ParticleSystem.TYPE_GROUPED); @@ -496,7 +469,7 @@ this.widgetAttributes(widget, json); - var clipEnabled = json["ClipAble"]; + var clipEnabled = json["ClipAble"] || false; if(clipEnabled != null) widget.setClippingEnabled(clipEnabled); @@ -777,7 +750,7 @@ widget.setBackGroundImage(path, type); }); - var clipEnabled = json["ClipAble"]; + var clipEnabled = json["ClipAble"] || false; widget.setClippingEnabled(clipEnabled); var colorType = getParam(json["ComboBoxIndex"], 0); @@ -914,6 +887,8 @@ ]; textureList.forEach(function(item){ loadTexture(json[item.name], resourcePath, function(path, type){ + if(type === 0 && !loader.getRes(path)) + cc.log("%s need to be preloaded", path); item.handle.call(widget, path, type); }); }); @@ -1078,6 +1053,8 @@ var startCharMap = json["StartChar"]; loadTexture(json["LabelAtlasFileImage_CNB"], resourcePath, function(path, type){ + if(!cc.loader.getRes(path)) + cc.log("%s need to be preloaded", path); if(type === 0){ widget.setProperty(stringValue, path, itemWidth, itemHeight, startCharMap); } @@ -1102,6 +1079,8 @@ widget.setString(text); loadTexture(json["LabelBMFontFile_CNB"], resourcePath, function(path, type){ + if(!cc.loader.getRes(path)) + cc.log("%s need to be pre loaded", path); widget.setFntFile(path); }); widget.ignoreContentAdaptWithSize(true); @@ -1296,6 +1275,8 @@ }); + delete json["AnchorPoint"]; + delete json["Size"]; parser.generalAttributes(node, json); node.setColor(getColor(json["CColor"])); @@ -1312,7 +1293,7 @@ var blendFunc = json["BlendFunc"]; if(blendFunc && blendFunc["Src"] !== undefined && blendFunc["Dst"] !== undefined) - node.setBlendFunc(new cc.BlendFunc(blendFunc["Src"] || 0, blendFunc["Dst"] || 0)); + node.setBlendFunc(new cc.BlendFunc(blendFunc["Src"], blendFunc["Dst"])); parser.generalAttributes(node, json); var color = json["CColor"]; @@ -1375,363 +1356,6 @@ node.setContentSize(cc.size(x, y)); }; - var get3DVector = function(json, name, defValue){ - var x = defValue, y = defValue, z = defValue; - if(json && name && json[name]){ - if(undefined !== json[name]["ValueX"]) { - x = json[name]["ValueX"]; - } else if(undefined !== json[name]["X"]) { - x = json[name]["X"] - } - if(null === x || isNaN(x)) - x = defValue; - - if(undefined !== json[name]["ValueY"]) { - y = json[name]["ValueY"]; - } else if(undefined !== json[name]["Y"]) { - y = json[name]["Y"] - } - if(null === y || isNaN(y)) - y = defValue; - - if(undefined !== json[name]["ValueZ"]) { - z = json[name]["ValueZ"]; - } else if(undefined !== json[name]["Z"]) { - z = json[name]["Z"] - } - if(null === z || isNaN(z)) - z = defValue; - } - var vec3 = cc.math.vec3(x, y, z); - return vec3; - }; - - parser.general3DAttributes = function(node, json){ - var pos = get3DVector(json, "Position3D", 0); - node.setPosition3D(pos); - - var rotation = get3DVector(json, "Rotation3D", 0); - node.setRotation3D(rotation); - - var scale = get3DVector(json, "Scale3D", 1.0); - node.setScaleX(scale.x); - node.setScaleY(scale.y); - node.setScaleZ(scale.z); - - var camMask =json["CameraFlagMode"]; - if(undefined !== camMask && null !== camMask) - node.setCameraMask(camMask); - - this.generalAttributes(node, json); - }; - - /** - * Node3D - * @param json - * @returns {*} - */ - parser.initNode3D = function(json){ - var node = cc.Node.create(); - if(node) - this.general3DAttributes(node, json); - return node; - }; - - /** - * Camera - * @param json - * @returns {*} - */ - parser.initCamera = function(json,resourcePath){ - var s = cc.winSize; - var fov = json["Fov"] ? json["Fov"] : 60; - - var nearClip = 1; - var farClip = 500; - if(json["ClipPlane"]){ - if(undefined !== json["ClipPlane"]["ValueX"]) { - nearClip = json["ClipPlane"]["ValueX"]; - } else if(undefined !== json["ClipPlane"]["X"]) { - nearClip = json["ClipPlane"]["X"]; - } - - if(undefined !== json["ClipPlane"]["ValueY"]) { - farClip = json["ClipPlane"]["ValueY"]; - } else if(undefined !== json["ClipPlane"]["Y"]) { - farClip = json["ClipPlane"]["Y"]; - } - - if(null === nearClip || isNaN(nearClip)) - nearClip = 1; - if(null === farClip || isNaN(farClip)) - farClip = 500; - } - - var node = cc.Camera.createPerspective(fov, s.width/s.height, nearClip, farClip); - - if(node){ - this.general3DAttributes(node, json); - - var camMode = json["UserCameraFlagMode"]; - var cameraFlagData = json["CameraFlagData"]; - var cameraFlag = cc.CameraFlag.USER1; - if(undefined === cameraFlagData || isNaN(cameraFlagData) || 0 === cameraFlagData) - { - switch(camMode){ - case "USER1": - cameraFlag = cc.CameraFlag.USER1; break; - case "USER2": - cameraFlag = cc.CameraFlag.USER2; break; - case "USER3": - cameraFlag = cc.CameraFlag.USER3; break; - case "USER4": - cameraFlag = cc.CameraFlag.USER4; break; - case "USER5": - cameraFlag = cc.CameraFlag.USER5; break; - case "USER6": - cameraFlag = cc.CameraFlag.USER6; break; - case "USER7": - cameraFlag = cc.CameraFlag.USER7; break; - case "USER8": - cameraFlag = cc.CameraFlag.USER8; break; - case "DEFAULT": - cameraFlag = cc.CameraFlag.DEFAULT; break; - } - } else { - cameraFlag = cameraFlagData; - } - node.setCameraFlag(cameraFlag); - } - - if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"] && - json.hasOwnProperty("SkyBoxValid") && true == json["SkyBoxValid"]) - { - var leftFileData = resourcePath + getSkyboxRes(json, "LeftImage"); - var rightFileData = resourcePath + getSkyboxRes(json, "RightImage"); - var upFileData = resourcePath + getSkyboxRes(json, "UpImage"); - var downFileData = resourcePath + getSkyboxRes(json, "DownImage"); - var forwardFileData = resourcePath + getSkyboxRes(json, "ForwardImage"); - var backFileData = resourcePath + getSkyboxRes(json, "BackImage"); - - var fileUtil = jsb.fileUtils; - if(fileUtil.isFileExist(leftFileData)&& - fileUtil.isFileExist(rightFileData)&& - fileUtil.isFileExist(upFileData)&& - fileUtil.isFileExist(downFileData)&& - fileUtil.isFileExist(forwardFileData)&& - fileUtil.isFileExist(backFileData)) - { - var innerBrush = cc.CameraBackgroundSkyBoxBrush.create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); - node.setBackgroundBrush(innerBrush); - } - else - node.setBackgroundBrush(skyBoxBrushInstance); - } - else if(skyBoxBrushInstance != null) - { - node.setBackgroundBrush(skyBoxBrushInstance); - } - return node; - }; - - /** - * Sprite3D - * @param json - * @param resourcePath - * @returns {*} - */ - parser.initSprite3D = function(json, resourcePath){ - var resFile = null; - if(json["FileData"] && json["FileData"]["Path"]) - resFile = resourcePath + json["FileData"]["Path"]; - - var node = null; - if(resFile) { - if(jsb.fileUtils.isFileExist(resFile)) - node = jsb.Sprite3D.create(resFile); - } - if(null === node) - node = jsb.Sprite3D.create(); - - if(node) { - this.general3DAttributes(node, json); - - if(json["CColor"]) { - var col = getColor(json["CColor"]); - if(col && col.r !== 255 || col.g !== 255 || col.b !== 255) - node.setColor(col); - } - - if(json.hasOwnProperty("IsFlipped") && true == json["IsFlipped"]) { - node.setCullFaceEnabled(true); - node.setCullFace(gl.FRONT); - } - - if(json.hasOwnProperty("LightFlag")){ - var lightFlagStr = json["LightFlag"]; - var lightFlag = 0; - switch(lightFlagStr){ - case "LIGHT0": - lightFlag = cc.LightFlag.LIGHT0; break; - case "LIGHT1": - lightFlag = cc.LightFlag.LIGHT1; break; - case "LIGHT2": - lightFlag = cc.LightFlag.LIGHT2; break; - case "LIGHT3": - lightFlag = cc.LightFlag.LIGHT3; break; - case "LIGHT4": - lightFlag = cc.LightFlag.LIGHT4; break; - case "LIGHT5": - lightFlag = cc.LightFlag.LIGHT5; break; - case "LIGHT6": - lightFlag = cc.LightFlag.LIGHT6; break; - case "LIGHT7": - lightFlag = cc.LightFlag.LIGHT7; break; - case "LIGHT8": - lightFlag = cc.LightFlag.LIGHT8; break; - case "LIGHT9": - lightFlag = cc.LightFlag.LIGHT9; break; - case "LIGHT10": - lightFlag = cc.LightFlag.LIGHT10; break; - case "LIGHT11": - lightFlag = cc.LightFlag.LIGHT11; break; - case "LIGHT12": - lightFlag = cc.LightFlag.LIGHT12; break; - } - node.setLightMask(lightFlag); - } - var autoAction = getParam(json["RunAction3D"], false); - if(autoAction && resFile){ - var animation = jsb.Animation3D.create(resFile, ""); - if(animation){ - var animate = jsb.Animate3D.create(animation); - var action = cc.RepeatForever.create(animate); - node.runAction(action); - } - } - } - - return node; - }; - - /** - * Particle3D - * @param json - * @param resourcePath - * @returns {*} - */ - parser.initParticle3D = function(json, resourcePath){ - var node = null; - - var resFile = null; - if(json["FileData"] && json["FileData"]["Path"]) - resFile = resourcePath+json["FileData"]["Path"]; - - if(resFile){ - if(jsb.fileUtils.isFileExist(resFile)) - node = jsb.PUParticleSystem3D.create(resFile); - } - - if(null === node) - node = jsb.PUParticleSystem3D.create(); - - if(node){ - this.general3DAttributes(node, json); - node.startParticleSystem(); - } - - return node; - }; - - /** - * Light3D - * @param json - * @param resourcePath - * @returns {*} - */ - parser.initLight3D = function(json, resourcePath){ - var node = new cc.Node(); - - var light = jsb.DirectionLight.create(cc.math.vec3(0, 0, 1), cc.color(255,255,255,255)); - var flag = 0; - var intensity = 1; - var range = 5.0; - var outerAngle = 30.0; - var enabled = true; - - if(json.hasOwnProperty("Intensity")){ - intensity = json["Intensity"]; - } - if(json.hasOwnProperty("Enable")){ - enabled = json["Enable"]; - } - if(json.hasOwnProperty("Range")){ - range = json["Range"]; - } - if(json.hasOwnProperty("OuterAngle")){ - outerAngle = json["OuterAngle"] * 0.5; - } - if(json.hasOwnProperty("Flag")){ - var lightFlagStr = json["Flag"]; - switch(lightFlagStr){ - case "LIGHT0": - flag = cc.LightFlag.LIGHT0; break; - case "LIGHT1": - flag = cc.LightFlag.LIGHT1; break; - case "LIGHT2": - flag = cc.LightFlag.LIGHT2; break; - case "LIGHT3": - flag = cc.LightFlag.LIGHT3; break; - case "LIGHT4": - flag = cc.LightFlag.LIGHT4; break; - case "LIGHT5": - flag = cc.LightFlag.LIGHT5; break; - case "LIGHT6": - flag = cc.LightFlag.LIGHT6; break; - case "LIGHT7": - flag = cc.LightFlag.LIGHT7; break; - case "LIGHT8": - flag = cc.LightFlag.LIGHT8; break; - case "LIGHT9": - flag = cc.LightFlag.LIGHT9; break; - case "LIGHT10": - flag = cc.LightFlag.LIGHT10; break; - case "LIGHT11": - flag = cc.LightFlag.LIGHT11; break; - case "LIGHT12": - flag = cc.LightFlag.LIGHT12; break; - } - } - if(json.hasOwnProperty("Type")){ - var type = json["Type"]; - switch(type){ - case "DIRECTIONAL": - light = jsb.DirectionLight.create(cc.math.vec3(0, 0, 1), cc.color(255, 255, 255, 255)); break; - case "POINT": - light = jsb.PointLight.create(cc.math.vec3(0, 0, 0), cc.color(255, 255, 255, 255), range); break; - case "SPOT": - light = jsb.SpotLight.create(cc.math.vec3(0, 0, 1), cc.math.vec3(0, 0, 0), cc.color(255, 255, 255, 255), 0, cc.degreesToRadians(outerAngle), range); break; - case "AMBIENT": - light = jsb.AmbientLight.create(cc.color(255,255,255,255)); break; - } - } - - light.setIntensity(intensity); - light.setEnabled(enabled); - light.setLightFlag(flag); - - node.addChild(light); - if(node) - this.general3DAttributes(node, json); - - if(json["CColor"]) { - var col = getColor(json["CColor"]); - if(col && col.r !== 255 || col.g !== 255 || col.b !== 255) - node.setColor(col); - } - return node; - }; - var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, {name: "NodeObjectData", handle: parser.initSingleNode}, @@ -1758,13 +1382,7 @@ {name: "ProjectNodeObjectData", handle: parser.initProjectNode}, {name: "ArmatureNodeObjectData", handle: parser.initArmature}, {name: "BoneNodeObjectData", handle: parser.initBoneNode}, - {name: "SkeletonNodeObjectData", handle: parser.initSkeletonNode}, - - {name: "Sprite3DObjectData", handle: parser.initSprite3D}, - {name: "Particle3DObjectData", handle: parser.initParticle3D}, - {name: "UserCameraObjectData", handle: parser.initCamera}, - {name: "Node3DObjectData", handle: parser.initNode3D}, - {name: "Light3DObjectData", handle: parser.initLight3D} + {name: "SkeletonNodeObjectData", handle: parser.initSkeletonNode} ]; register.forEach(function(item){ diff --git a/web b/web index e52c98198f..85518886f7 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit e52c98198fd8325017b213365180580be06d2259 +Subproject commit 85518886f7ba8a618ec69bb75a9b7d67ea2d1c7d From 8183d34b683f12e2c6c897797b15393def1d78d2 Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Fri, 6 Nov 2015 12:50:36 +0800 Subject: [PATCH 056/192] revert old timelineParser-2.x.js and add "||false" to it. --- .../studio/parsers/timelineParser-2.x.js | 408 +++++++++++++++++- 1 file changed, 395 insertions(+), 13 deletions(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index 8eab3690b5..0a023cbdf0 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -160,12 +160,20 @@ } }; + var skyBoxBrushInstance = null; + var getSkyboxRes = function(json, key) { + if(json.hasOwnProperty(key) && json[key].hasOwnProperty("Path")) { + return json[key]["Path"]; + } + return ""; + } + /** * SingleNode * @param json * @returns {cc.Node} */ - parser.initSingleNode = function(json){ + parser.initSingleNode = function(json, resourcePath){ var node = new cc.Node(); this.generalAttributes(node, json); @@ -173,6 +181,27 @@ if(color != null) node.setColor(getColor(color)); + if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"]&& + json.hasOwnProperty("SkyBoxValid") && true == json["SkyBoxValid"]) + { + var leftFileData = resourcePath + getSkyboxRes(json, "LeftImage"); + var rightFileData = resourcePath + getSkyboxRes(json, "RightImage"); + var upFileData = resourcePath + getSkyboxRes(json, "UpImage"); + var downFileData = resourcePath + getSkyboxRes(json, "DownImage"); + var forwardFileData = resourcePath + getSkyboxRes(json, "ForwardImage"); + var backFileData = resourcePath + getSkyboxRes(json, "BackImage"); + var fileUtil = jsb.fileUtils; + if(fileUtil.isFileExist(leftFileData)&& + fileUtil.isFileExist(rightFileData)&& + fileUtil.isFileExist(upFileData)&& + fileUtil.isFileExist(downFileData)&& + fileUtil.isFileExist(forwardFileData)&& + fileUtil.isFileExist(backFileData)) + { + skyBoxBrushInstance = cc.CameraBackgroundSkyBoxBrush.create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); + } + } + return node; }; @@ -228,8 +257,6 @@ var node, self = this; loadTexture(json["FileData"], resourcePath, function(path, type){ - if(!cc.loader.getRes(path)) - cc.log("%s need to be preloaded", path); node = new cc.ParticleSystem(path); self.generalAttributes(node, json); node.setPositionType(cc.ParticleSystem.TYPE_GROUPED); @@ -887,8 +914,6 @@ ]; textureList.forEach(function(item){ loadTexture(json[item.name], resourcePath, function(path, type){ - if(type === 0 && !loader.getRes(path)) - cc.log("%s need to be preloaded", path); item.handle.call(widget, path, type); }); }); @@ -1053,8 +1078,6 @@ var startCharMap = json["StartChar"]; loadTexture(json["LabelAtlasFileImage_CNB"], resourcePath, function(path, type){ - if(!cc.loader.getRes(path)) - cc.log("%s need to be preloaded", path); if(type === 0){ widget.setProperty(stringValue, path, itemWidth, itemHeight, startCharMap); } @@ -1079,8 +1102,6 @@ widget.setString(text); loadTexture(json["LabelBMFontFile_CNB"], resourcePath, function(path, type){ - if(!cc.loader.getRes(path)) - cc.log("%s need to be pre loaded", path); widget.setFntFile(path); }); widget.ignoreContentAdaptWithSize(true); @@ -1275,8 +1296,6 @@ }); - delete json["AnchorPoint"]; - delete json["Size"]; parser.generalAttributes(node, json); node.setColor(getColor(json["CColor"])); @@ -1293,7 +1312,7 @@ var blendFunc = json["BlendFunc"]; if(blendFunc && blendFunc["Src"] !== undefined && blendFunc["Dst"] !== undefined) - node.setBlendFunc(new cc.BlendFunc(blendFunc["Src"], blendFunc["Dst"])); + node.setBlendFunc(new cc.BlendFunc(blendFunc["Src"] || 0, blendFunc["Dst"] || 0)); parser.generalAttributes(node, json); var color = json["CColor"]; @@ -1356,6 +1375,363 @@ node.setContentSize(cc.size(x, y)); }; + var get3DVector = function(json, name, defValue){ + var x = defValue, y = defValue, z = defValue; + if(json && name && json[name]){ + if(undefined !== json[name]["ValueX"]) { + x = json[name]["ValueX"]; + } else if(undefined !== json[name]["X"]) { + x = json[name]["X"] + } + if(null === x || isNaN(x)) + x = defValue; + + if(undefined !== json[name]["ValueY"]) { + y = json[name]["ValueY"]; + } else if(undefined !== json[name]["Y"]) { + y = json[name]["Y"] + } + if(null === y || isNaN(y)) + y = defValue; + + if(undefined !== json[name]["ValueZ"]) { + z = json[name]["ValueZ"]; + } else if(undefined !== json[name]["Z"]) { + z = json[name]["Z"] + } + if(null === z || isNaN(z)) + z = defValue; + } + var vec3 = cc.math.vec3(x, y, z); + return vec3; + }; + + parser.general3DAttributes = function(node, json){ + var pos = get3DVector(json, "Position3D", 0); + node.setPosition3D(pos); + + var rotation = get3DVector(json, "Rotation3D", 0); + node.setRotation3D(rotation); + + var scale = get3DVector(json, "Scale3D", 1.0); + node.setScaleX(scale.x); + node.setScaleY(scale.y); + node.setScaleZ(scale.z); + + var camMask =json["CameraFlagMode"]; + if(undefined !== camMask && null !== camMask) + node.setCameraMask(camMask); + + this.generalAttributes(node, json); + }; + + /** + * Node3D + * @param json + * @returns {*} + */ + parser.initNode3D = function(json){ + var node = cc.Node.create(); + if(node) + this.general3DAttributes(node, json); + return node; + }; + + /** + * Camera + * @param json + * @returns {*} + */ + parser.initCamera = function(json,resourcePath){ + var s = cc.winSize; + var fov = json["Fov"] ? json["Fov"] : 60; + + var nearClip = 1; + var farClip = 500; + if(json["ClipPlane"]){ + if(undefined !== json["ClipPlane"]["ValueX"]) { + nearClip = json["ClipPlane"]["ValueX"]; + } else if(undefined !== json["ClipPlane"]["X"]) { + nearClip = json["ClipPlane"]["X"]; + } + + if(undefined !== json["ClipPlane"]["ValueY"]) { + farClip = json["ClipPlane"]["ValueY"]; + } else if(undefined !== json["ClipPlane"]["Y"]) { + farClip = json["ClipPlane"]["Y"]; + } + + if(null === nearClip || isNaN(nearClip)) + nearClip = 1; + if(null === farClip || isNaN(farClip)) + farClip = 500; + } + + var node = cc.Camera.createPerspective(fov, s.width/s.height, nearClip, farClip); + + if(node){ + this.general3DAttributes(node, json); + + var camMode = json["UserCameraFlagMode"]; + var cameraFlagData = json["CameraFlagData"]; + var cameraFlag = cc.CameraFlag.USER1; + if(undefined === cameraFlagData || isNaN(cameraFlagData) || 0 === cameraFlagData) + { + switch(camMode){ + case "USER1": + cameraFlag = cc.CameraFlag.USER1; break; + case "USER2": + cameraFlag = cc.CameraFlag.USER2; break; + case "USER3": + cameraFlag = cc.CameraFlag.USER3; break; + case "USER4": + cameraFlag = cc.CameraFlag.USER4; break; + case "USER5": + cameraFlag = cc.CameraFlag.USER5; break; + case "USER6": + cameraFlag = cc.CameraFlag.USER6; break; + case "USER7": + cameraFlag = cc.CameraFlag.USER7; break; + case "USER8": + cameraFlag = cc.CameraFlag.USER8; break; + case "DEFAULT": + cameraFlag = cc.CameraFlag.DEFAULT; break; + } + } else { + cameraFlag = cameraFlagData; + } + node.setCameraFlag(cameraFlag); + } + + if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"] && + json.hasOwnProperty("SkyBoxValid") && true == json["SkyBoxValid"]) + { + var leftFileData = resourcePath + getSkyboxRes(json, "LeftImage"); + var rightFileData = resourcePath + getSkyboxRes(json, "RightImage"); + var upFileData = resourcePath + getSkyboxRes(json, "UpImage"); + var downFileData = resourcePath + getSkyboxRes(json, "DownImage"); + var forwardFileData = resourcePath + getSkyboxRes(json, "ForwardImage"); + var backFileData = resourcePath + getSkyboxRes(json, "BackImage"); + + var fileUtil = jsb.fileUtils; + if(fileUtil.isFileExist(leftFileData)&& + fileUtil.isFileExist(rightFileData)&& + fileUtil.isFileExist(upFileData)&& + fileUtil.isFileExist(downFileData)&& + fileUtil.isFileExist(forwardFileData)&& + fileUtil.isFileExist(backFileData)) + { + var innerBrush = cc.CameraBackgroundSkyBoxBrush.create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); + node.setBackgroundBrush(innerBrush); + } + else + node.setBackgroundBrush(skyBoxBrushInstance); + } + else if(skyBoxBrushInstance != null) + { + node.setBackgroundBrush(skyBoxBrushInstance); + } + return node; + }; + + /** + * Sprite3D + * @param json + * @param resourcePath + * @returns {*} + */ + parser.initSprite3D = function(json, resourcePath){ + var resFile = null; + if(json["FileData"] && json["FileData"]["Path"]) + resFile = resourcePath + json["FileData"]["Path"]; + + var node = null; + if(resFile) { + if(jsb.fileUtils.isFileExist(resFile)) + node = jsb.Sprite3D.create(resFile); + } + if(null === node) + node = jsb.Sprite3D.create(); + + if(node) { + this.general3DAttributes(node, json); + + if(json["CColor"]) { + var col = getColor(json["CColor"]); + if(col && col.r !== 255 || col.g !== 255 || col.b !== 255) + node.setColor(col); + } + + if(json.hasOwnProperty("IsFlipped") && true == json["IsFlipped"]) { + node.setCullFaceEnabled(true); + node.setCullFace(gl.FRONT); + } + + if(json.hasOwnProperty("LightFlag")){ + var lightFlagStr = json["LightFlag"]; + var lightFlag = 0; + switch(lightFlagStr){ + case "LIGHT0": + lightFlag = cc.LightFlag.LIGHT0; break; + case "LIGHT1": + lightFlag = cc.LightFlag.LIGHT1; break; + case "LIGHT2": + lightFlag = cc.LightFlag.LIGHT2; break; + case "LIGHT3": + lightFlag = cc.LightFlag.LIGHT3; break; + case "LIGHT4": + lightFlag = cc.LightFlag.LIGHT4; break; + case "LIGHT5": + lightFlag = cc.LightFlag.LIGHT5; break; + case "LIGHT6": + lightFlag = cc.LightFlag.LIGHT6; break; + case "LIGHT7": + lightFlag = cc.LightFlag.LIGHT7; break; + case "LIGHT8": + lightFlag = cc.LightFlag.LIGHT8; break; + case "LIGHT9": + lightFlag = cc.LightFlag.LIGHT9; break; + case "LIGHT10": + lightFlag = cc.LightFlag.LIGHT10; break; + case "LIGHT11": + lightFlag = cc.LightFlag.LIGHT11; break; + case "LIGHT12": + lightFlag = cc.LightFlag.LIGHT12; break; + } + node.setLightMask(lightFlag); + } + var autoAction = getParam(json["RunAction3D"], false); + if(autoAction && resFile){ + var animation = jsb.Animation3D.create(resFile, ""); + if(animation){ + var animate = jsb.Animate3D.create(animation); + var action = cc.RepeatForever.create(animate); + node.runAction(action); + } + } + } + + return node; + }; + + /** + * Particle3D + * @param json + * @param resourcePath + * @returns {*} + */ + parser.initParticle3D = function(json, resourcePath){ + var node = null; + + var resFile = null; + if(json["FileData"] && json["FileData"]["Path"]) + resFile = resourcePath+json["FileData"]["Path"]; + + if(resFile){ + if(jsb.fileUtils.isFileExist(resFile)) + node = jsb.PUParticleSystem3D.create(resFile); + } + + if(null === node) + node = jsb.PUParticleSystem3D.create(); + + if(node){ + this.general3DAttributes(node, json); + node.startParticleSystem(); + } + + return node; + }; + + /** + * Light3D + * @param json + * @param resourcePath + * @returns {*} + */ + parser.initLight3D = function(json, resourcePath){ + var node = new cc.Node(); + + var light = jsb.DirectionLight.create(cc.math.vec3(0, 0, 1), cc.color(255,255,255,255)); + var flag = 0; + var intensity = 1; + var range = 5.0; + var outerAngle = 30.0; + var enabled = true; + + if(json.hasOwnProperty("Intensity")){ + intensity = json["Intensity"]; + } + if(json.hasOwnProperty("Enable")){ + enabled = json["Enable"]; + } + if(json.hasOwnProperty("Range")){ + range = json["Range"]; + } + if(json.hasOwnProperty("OuterAngle")){ + outerAngle = json["OuterAngle"] * 0.5; + } + if(json.hasOwnProperty("Flag")){ + var lightFlagStr = json["Flag"]; + switch(lightFlagStr){ + case "LIGHT0": + flag = cc.LightFlag.LIGHT0; break; + case "LIGHT1": + flag = cc.LightFlag.LIGHT1; break; + case "LIGHT2": + flag = cc.LightFlag.LIGHT2; break; + case "LIGHT3": + flag = cc.LightFlag.LIGHT3; break; + case "LIGHT4": + flag = cc.LightFlag.LIGHT4; break; + case "LIGHT5": + flag = cc.LightFlag.LIGHT5; break; + case "LIGHT6": + flag = cc.LightFlag.LIGHT6; break; + case "LIGHT7": + flag = cc.LightFlag.LIGHT7; break; + case "LIGHT8": + flag = cc.LightFlag.LIGHT8; break; + case "LIGHT9": + flag = cc.LightFlag.LIGHT9; break; + case "LIGHT10": + flag = cc.LightFlag.LIGHT10; break; + case "LIGHT11": + flag = cc.LightFlag.LIGHT11; break; + case "LIGHT12": + flag = cc.LightFlag.LIGHT12; break; + } + } + if(json.hasOwnProperty("Type")){ + var type = json["Type"]; + switch(type){ + case "DIRECTIONAL": + light = jsb.DirectionLight.create(cc.math.vec3(0, 0, 1), cc.color(255, 255, 255, 255)); break; + case "POINT": + light = jsb.PointLight.create(cc.math.vec3(0, 0, 0), cc.color(255, 255, 255, 255), range); break; + case "SPOT": + light = jsb.SpotLight.create(cc.math.vec3(0, 0, 1), cc.math.vec3(0, 0, 0), cc.color(255, 255, 255, 255), 0, cc.degreesToRadians(outerAngle), range); break; + case "AMBIENT": + light = jsb.AmbientLight.create(cc.color(255,255,255,255)); break; + } + } + + light.setIntensity(intensity); + light.setEnabled(enabled); + light.setLightFlag(flag); + + node.addChild(light); + if(node) + this.general3DAttributes(node, json); + + if(json["CColor"]) { + var col = getColor(json["CColor"]); + if(col && col.r !== 255 || col.g !== 255 || col.b !== 255) + node.setColor(col); + } + return node; + }; + var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, {name: "NodeObjectData", handle: parser.initSingleNode}, @@ -1382,7 +1758,13 @@ {name: "ProjectNodeObjectData", handle: parser.initProjectNode}, {name: "ArmatureNodeObjectData", handle: parser.initArmature}, {name: "BoneNodeObjectData", handle: parser.initBoneNode}, - {name: "SkeletonNodeObjectData", handle: parser.initSkeletonNode} + {name: "SkeletonNodeObjectData", handle: parser.initSkeletonNode}, + + {name: "Sprite3DObjectData", handle: parser.initSprite3D}, + {name: "Particle3DObjectData", handle: parser.initParticle3D}, + {name: "UserCameraObjectData", handle: parser.initCamera}, + {name: "Node3DObjectData", handle: parser.initNode3D}, + {name: "Light3DObjectData", handle: parser.initLight3D} ]; register.forEach(function(item){ From fec8a5db02fda8dda7816a3a32923ab0f7f7b502 Mon Sep 17 00:00:00 2001 From: Nhuan Vu Duc Date: Fri, 6 Nov 2015 12:59:48 +0700 Subject: [PATCH 057/192] Fix cannot add view to mFrameLayout when extends Cocos2dxActivity --- .../org/cocos2dx/lib/Cocos2dxActivity.java | 40 ----------- .../src/org/cocos2dx/lib/ResizeLayout.java | 68 +++++++++++++++++++ 2 files changed, 68 insertions(+), 40 deletions(-) create mode 100644 cocos/platform/android/java/src/org/cocos2dx/lib/ResizeLayout.java diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index cadabac2e2..851e1b4bfe 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -50,46 +50,6 @@ import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLDisplay; -class ResizeLayout extends FrameLayout{ - private boolean mEnableForceDoLayout = false; - - public ResizeLayout(Context context){ - super(context); - } - - public ResizeLayout(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public void setEnableForceDoLayout(boolean flag){ - mEnableForceDoLayout = flag; - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - if(mEnableForceDoLayout){ - /*This is a hot-fix for some android devices which don't do layout when the main window - * is paned. We refersh the layout in 24 frames per seconds. - * When the editBox is lose focus or when user begin to type, the do layout is disabled. - */ - final Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - @Override - public void run() { - //Do something after 100ms - requestLayout(); - invalidate(); - } - }, 1000 / 24); - - } - - } - -} - - public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener { // =========================================================== // Constants diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/ResizeLayout.java b/cocos/platform/android/java/src/org/cocos2dx/lib/ResizeLayout.java new file mode 100644 index 0000000000..0c9b2fdf78 --- /dev/null +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/ResizeLayout.java @@ -0,0 +1,68 @@ +/**************************************************************************** + Copyright (c) 2010-2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +package org.cocos2dx.lib; + +import android.content.Context; +import android.os.Handler; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +public class ResizeLayout extends FrameLayout { + private boolean mEnableForceDoLayout = false; + + public ResizeLayout(Context context){ + super(context); + } + + public ResizeLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setEnableForceDoLayout(boolean flag){ + mEnableForceDoLayout = flag; + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + if(mEnableForceDoLayout){ + /*This is a hot-fix for some android devices which don't do layout when the main window + * is paned. We refersh the layout in 24 frames per seconds. + * When the editBox is lose focus or when user begin to type, the do layout is disabled. + */ + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + //Do something after 100ms + requestLayout(); + invalidate(); + } + }, 1000 / 24); + + } + + } + +} From c0c35c603e321a4c00527008cfd6c25fc9804190 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 6 Nov 2015 18:38:09 +0800 Subject: [PATCH 058/192] Update version number & RELEASE_NOTES.md, prepare 3.9 release --- cocos/cocos2d.cpp | 2 +- .../js-bindings/manual/ScriptingCore.h | 2 +- .../js-bindings/script/jsb_cocos2d.js | 2 +- docs/RELEASE_NOTES.md | 560 ++++++++---------- plugin | 2 +- .../runtime-src/proj.ios_mac/mac/Info.plist | 2 +- .../frameworks/runtime-src/proj.win32/game.rc | 2 +- web | 2 +- 8 files changed, 245 insertions(+), 329 deletions(-) diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index 2a80e68f3a..b428bb75ae 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -31,7 +31,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "cocos2d-x-3.9beta0"; + return "cocos2d-x-3.9"; } NS_CC_END diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 3ead7224c8..5f472a8f45 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -39,7 +39,7 @@ #include #include -#define ENGINE_VERSION "Cocos2d-JS v3.9 Beta0" +#define ENGINE_VERSION "Cocos2d-JS v3.9" void js_log(const char *format, ...); diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index a95409a838..d545151eb3 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.9 Beta0"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.9"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 19350b0fc5..9c40e223c8 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -2,7 +2,7 @@ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [Cocos2d-x v3.8 Release Notes](#cocos2d-x-v38-release-notes) +- [Cocos2d-x 3.9 Release Notes](#cocos2d-x-39-release-notes) - [Misc Information](#misc-information) - [Requirements](#requirements) - [Runtime Requirements](#runtime-requirements) @@ -14,22 +14,18 @@ - [Windows](#windows) - [Linux](#linux) - [How to start a new game](#how-to-start-a-new-game) -- [v3.8](#v38) - - [Highlights and API changes of v3.8](#highlights-and-api-changes-of-v38) - - [Download](#download) - - [The main features in detail:](#the-main-features-in-detail) +- [v3.9](#v39) + - [Highlights features, improvements and API updates of v3.9](#highlights-features-improvements-and-api-updates-of-v39) + - [The main features in detail of Cocos2d-x v3.9:](#the-main-features-in-detail-of-cocos2d-x-v39) - [3D Module](#3d-module) - - [UI System](#ui-system) - - [AudioEngine](#audioengine) - - [FileUtils](#fileutils) + - [2D Module](#2d-module) - [Others](#others) - [Other changes](#other-changes) - - [New APIs](#new-apis) -- [The Next Step](#the-next-step) + - [NEW APIS](#new-apis) -# Cocos2d-x v3.8 Release Notes # +# Cocos2d-x 3.9 Release Notes # # Misc Information @@ -150,379 +146,299 @@ Use Cocos Console to create a new game: cocos new -l cpp|js|lua MyNewGame ``` -# v3.8 +# v3.9 -## Highlights and API changes of v3.8 +## Highlights features, improvements and API updates of v3.9 -As promised, Cocos2d-x v3.8 have greatly improved the stability and API friendliness. On one side, we continue to improve 3D capacity by providing 3D physics collider, skybox background brush and key frame event callback in Animate3D. On another side, we have refined several core modules, including UI system, AudioEngine, FileUtils, Bindings Generator, etc. +We are happy to announce the release of Cocos2d-x v3.9. Following are the highlighted features, improvements and API updates in this version. -Here is some highlighted improvments and API changes: +1. 3D Module: + - Added 3D MotionStreak to support streak effect. + - Refined Sprite3D to support material system. +2. 2D Module: + - Added frame callback function and animation callback function. + - Added script component system. + - Reconstruction of 2D physics with Component. + - Improved EditBox implemention on iOS and Win32 platform. + - Removed dependence of libcurl on AssetsManager, AssetsManagerEx and Downloader (iOS & Android). + - Improved particle performance. +3. Others: + - Supported Action inheritance, update function overwriting in JSB. + - Improved ScrollView performance in Web engine. + - Improved Scale9Sprite performance in Web engine. + - Decoupled Sprite's setTexture and updateColor in Web engine. + - Added support for debugging and release on real devices with Xcode7 and iOS9. -1. 3D Module - - Added 3D physics collider - - Supported setting camera background brushes with color/depth/skybox - - Added key frame event Callback in Animate3D - - Added light map support in Terrain -2. UI System - - Reimplemented and enhanced EditBox on Android - - Added ScrollViewBar for displaying a scroll bar at the side of ScrollView (JSB/Lua ready) - - Added RadioButton widget (JSB/Lua ready) - - Added HANYI FullType font support -3. AudioEngine - - AudioEngine supported audio preloading - - Bound new AudioEngine in JSB -4. FileUtils - - Added a set of file writing APIs: writeStringToFile, writeDataToFile, writeValueMapToFile, writeValueVectorToFile -5. Others - - Improved Bindings Generator tool - - Merged JSB test project into cocos2d test project - - framework: Support generate prebuilt libs of engine with debug mode - - console: Supported new portrait projects from templates - -## Download - -[Cocos2d-x v3.8](http://www.cocos2d-x.org/filedown/cocos2d-x-3.8.zip) including : C++, Lua & JS - -## The main features in detail: +## The main features in detail of Cocos2d-x v3.9: ### 3D Module -1. 3D physics collider +1. 3D MotionStreak + + In this version, 3D MotionStreak is added to support streak effect. Check the testcase of Sprite3Dtest to see how to use it. - 3D physics collider is a new type of physics object. It can be used as both trigger and collider. +2. Sprite3D - Trigger is a region defined by physics shapes and can get callback when other physics objects enter or leave. Its usage is described in the following code: - - ```cpp - //create a collider using colliderDes - Physics3DColliderDes colliderDes; - colliderDes.shape = Physics3DShape::createSphere(10.0f); - colliderDes.isTrigger = true; - auto collider = Physics3DCollider::create(&colliderDes); - auto component = Physics3DComponent::create(collider); - auto node = Node::create(); - addChild(node); - node->addComponent(component); + Added Sprite3D material class. It will be easy and convenient to create internal material. - collider->onTriggerEnter = [=](Physics3DObject *otherObject){ - //some body entering - }; - collider->onTriggerExit = [=](Physics3DObject *otherObject){ - //some one leaving - }; - ``` +### 2D Module - Collider is similar to rigid body, it can give force to the rigid body that collides with it. However, it is static and has better performance than rigid body. It is proper to represent a static scene or objects using collider and dynamic part using rigid body. You can set colliderDes.isTrigger to false when you want to make it collider. +1. Frame callback function and animation callback function -2. Camera background brushes + Three interfaces are added in ActionTimelineData class, which are addFrameEndCallFunc, removeFrameEndCall and clearFrameEndCalls. It will be easy to add or remove specific frame event. - Different with previous versions, in v3.8, developers can choose to erase the camera’s background with 4 types of brush: none, color, depth, skybox. None brush means do nothing; Color brush erases background using given color and depth; depth brush erases background using given depth; skybox brush erases background using given skybox with 6 texture faces. The default brush is depth brush. The usage of brushes is showing below: +2. Script Component - ```cpp - // Using none brush - _camera->setBackgroundBrush(CameraBackgroundBrush::createNoneBrush()); - // Using depth brush, clear depth with 1.0 - _camera->setBackgroundBrush(CameraBackgroundBrush::createDepthBrush(1.f)); - // Using color brush, clear color is (1,0,0,1), depth is 1 - _camera->setBackgroundBrush(CameraBackgroundBrush::createColorBrush(Color4F(1.f, 0.f, 0.f, 1.f), 1.f)); - // SkyBox brush - _camera->setBackgroundBrush(CameraBackgroundBrush::createSkyboxBrush("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg","Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg","Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg")); - ``` + Script component is used to extend c++ Nodes. You can add a script component to a Node, then the script component will receive onEnter,onExit and update events. For example: -3. Animate3D key frame event callback + ```c++ + // create a sprite and add a lua component auto player = + Sprite::create("player.png"); + + auto luaComponent = ComponentLua::create("player.lua"); + player->addComponent(luaComponent); + ``` + + ```lua + // player.lua + local player = { + onEnter = function(self) + -- do some things in onEnter + end + + onExit = function(slef) + -- do some things in onExit + end + + update = function(self) + -- do some things every frame + end + } + + -- it is needed to return player to let c++ nodes know it + return player + ``` + + Javascript can work as the same way, just use ComponentJS instead of ComponentLua. + + There are some differences between lua component and Javascript component: + + Should return the object in lua component, in Javascript, you only have to extend cc.ComponentJS, and ensure the result of the last statement is the class of Component. + + Lua component can only be used in lua projects, Javascript component can only be used in Javascript projects. + + More detail usage please refer to: `tests/lua-tests/src/ComponentTest` and `tests/js-tests/src/ComponentTest` - Similar to 2d AnimationFrame callback, frame event callback is supported in Animated3D now. It allows developer to set a callback to be invoked when specific frame is played. Sample code: - ```cpp - auto animation = Animation3D::create(“XX.c3b”); - auto animate = Animate3D::create(animation); - ValueMap valuemap0;//you can add some user data here, it can be used in the frame event callback - //add a callback when frame 275 is played - animate->setKeyFrameUserInfo(275, valuemap0); - - auto listener = EventListenerCustom::create(Animate3DDisplayedNotification, [&](EventCustom* event) - { - auto info = (Animate3D::Animate3DDisplayedEventInfo*)event->getUserData(); - - //frame 275 is played, you can add some code here - cocos2d::log(“frame %d”, info->frame); - }); - Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(listener, -1); - ``` +3. 2D Physics -4. Light map support in Terrain + Before v3.9, there are many physics related codes in Node, such as Node::setPhysicsBody(). Since v3.9, we move these codes into physics component. - Terrain with light map is supported in v3.8, which means you can add a light map texture baked from other tools to the terrain. The light map texture contains light info, so that the terrain seems to be lighted with several lights. Terrain with light map can be created like this, + After using physics component, the way to use physics is changed. Before + v3.9, you can use physics like this: + + ``` + auto node = Node::create(); + node->setPhysicsBody(PhysicsBody::createEdgeBox(...)); + ``` + + Since v3.9 you should use like this: + + ``` + auto node = Node::create(); + node->addComponent(PhysicsBody::createEdgeBox(...)); - ```cpp - //create a normal terrain as before - Terrain::DetailMap r(“TerrainTest/dirt.jpg”),g(“TerrainTest/Grass2.jpg”),b(“TerrainTest/road.jpg”),a(“TerrainTest/GreenSkin.jpg”); - Terrain::TerrainData data(“TerrainTest/heightmap16.jpg”,”TerrainTest/alphamap.png”,r,g,b,a); - _terrain = Terrain::create(data,Terrain::CrackFixedType::SKIRT); - _terrain->setLODDistance(3.2f,6.4f,9.6f); - _terrain->setMaxDetailMapAmount(4); - _terrain->setDrawWire(false); - //set light map for the terrain - _terrain->setLightMap(“TerrainTest/Lightmap.png”); - ``` + ``` -### UI System +4. EditBox implemention on iOS and Win32 platform -1. Reimplemented EditBox + - Specify the maximum number of characters in the dialog box. + - Support password input. + - Games will continue when the dialogue box pops up. + - Sync the content in dialogue box. - The usage of EditBox is the same as before, but we have reimplemented it for Android platform. The use experience is highly improved, important improvements are: +5. Remove dependence of curl on AssetsManager, AssetsManagerEx and Downloader (iOS & Android) - - Display cursor in EditBox - - Support copy, cut, paste and select actions in EditBox - - Support multi-line input, you should set InputMode to `ANY` to enable multi-line input - - EditBox won't be masked by the keyboard UI anymore + >From v3.9, iOS and Android version will not depend on libcurl, which make + the game package smaller and solve some bugs caused by libcurl. Stability has + been improved with the updated iOS and Android system. -2. ScrollViewBar - - In the previous versions, the ScrollView doesn't have any visual notification for the current location in view. In v3.8, we have added a scroll bar attached to the ScrollView. You could tweak the the opacity, color, width and the duration for auto hiding the scroll bar. Speical thanks to @neokim. - - Usage: - - ```cpp - ui::ScrollView* scrollView = ui::ScrollView::create(); - scrollView->setScrollBarWidth(4); - scrollView->setScrollBarPositionFromCorner(Vec2(2, 2)); - scrollView->setScrollBarColor(Color3B::WHITE); - this->addChild(scrollView); - ``` - -3. RadioButton widget - - RadioButton is a specific type of two-states button that is similar to CheckBox. - - Additionally, it can be used together with RadioButtonGroup to interact with other radio buttons. - - There is only one RadioButton in checked state at the same time within a RadioButtonGroup. Special thanks to @neokim who have contributed the implementation of this new widget. - - Usage: - - ```cpp - //create a RadioButtonGroup - auto radioButtonGroup = RadioButtonGroup::create(); - this->addChild(radioButtonGroup); - - //create a RadioButton - RadioButton* radioButton1 = RadioButton::create("radio_button_off.png", "radio_button_on.png"); - radioButton1->setPosition(Vec2(100,100); - this->addChild(radioButton1); - - //create another RadioButton - RadioButton* radioButton2 = RadioButton::create("radio_button_off.png", "radio_button_on.png"); - radioButton2->setPosition(Vec2(100,100); - this->addChild(radioButton2); - - //add the RadioButtons into RadioButtonGroup - radioButtonGroup->addRadioButton(radioButton1); - radioButtonGroup->addRadioButton(radioButton2); - ``` - -### AudioEngine - -1. Audio preloading - - AudioEngine now supports preload audio files before playing it. For some large audio file, this feature can smooth the audio playing experience in user's games. Sample code: - - ```cpp - //Use it with callback - AudioEngine::preload("audio1.mp3",[](bool isSuccess){ - //... - }); - //Use it without callback - AudioEngine::preload("audio2.mp3"); - ``` - -2. JSB new AudioEngine - - In JSB, the default audio engine was SimpleAudioEngine (renamed to cc.audioEngine). It was the old audio engine provided since v2, and it have some inconvenience like delay time, no event support, etc. So we decided to provide new AudioEngine in JSB, the API remains the same as C++ API, and its usage can be found in [its test case](https://github.com/cocos2d/cocos2d-x/blob/v3/tests/js-tests/src/NativeTest/AudioEngineTest.js). - -### FileUtils - -1. New file writing APIs - - In v3.8, we have provided a bunch of file writing APIs in FileUtils. Now you can use very simple APIs to write string, binary data, value map, and value vector into a file in user's file system. Each API is demonstrated in the following sample code: - - ```cpp - std::string writablePath = FileUtils::getInstance()->getWritablePath(); - - // FileUtils::writeStringToFile - std::string writeDataStr = "the string data will be write into a file"; - std::string fullPath = writablePath + "writeStringTest.txt"; - FileUtils::getInstance()->writeStringToFile(writeDataStr, fullPath.c_str()); - - // FileUtils::writeDataToFile - std::string writeDataStr = "the binary data will be write into a file"; - Data writeData; - writeData.copy((unsigned char *)writeDataStr.c_str(), writeDataStr.size()); - std::string fullPath = writablePath + "writeDataTest.txt"; - FileUtils::getInstance()->writeDataToFile(writeData, fullPath.c_str())); - - // FileUtils::writeValueMapToFile - std::string fullPath = writablePath + "testWriteValueMap.plist"; - FileUtils::getInstance()->writeValueMapToFile(valueMap, fullPath.c_str()); - - // FileUtils::writeValueVectorToFile - std::string fullPath = writablePath + "testWriteValueVector.plist"; - FileUtils::getInstance()->writeValueVectorToFile(valueVector, fullPath.c_str()); - ``` - - Besides, you can retrieve the extension (in lower case) of a file with `FileUtils::getFileExtension` API. +6. Improved particle performance. ### Others -1. Bindings Generator +1. Supported Action inheritance, update function overwriting in JSB - In v3.8, we also improved our bindings generator tool, now it's even more powerful and be able to bind almost all kind of C++ APIs to script. Here is a detailed list about improvement in bindings generator. + In previous version of JSB, developers cannot inherit Action class in JS script, + such as Action / ActionInterval / ActionInstant, for their update function will not be called. In v3.9, developers can create subclass of Action and make extensions. More detail usage please refer to the textcase in ActionTest + / ActionCustomTest. - - Supported generating auto bindings code for public member variables - - Avoid memory leak of non-Ref classes instance by controlling C++ object memory with JS object - - Made JSB classes automatically extendable if configured in classes_need_extend list - - Improved support for Lambda functions in JS auto bindings +2. ScrollView performance on Web engine -2. JSB test project + ScrollView and ListView are the popular UI controls in Web engine. Their + performance is not perfect in previous versions, especially when there are multiple sub-controls. In v3.9, we have improved its rendering performance. They only act on the contents displayed on the current screen. Test + date shows that, comparing with v3.8, rendering efficiency of v3.9 have been improved for twice to four times in different devices and browsers. - In v3.8, JSB test project have been merged into C++ test project. That means cocos2d_js_tests.xcodeproj, cocos2d-js-win32.sln, cocos2d-js-win8.1-universal.sln have been removed. You can find jsb test targets in cocos2d_test.xcodeproj, cocos2d-win32.sln and cocos2d-win8.1-universal.sln. +3. Scale9Sprite performance on Web engine -3. Compile custom framework in debug mode + In this version, we have changed the way to construct 9-slice sprite. The engine uses 9 rendering commands instead of the 9 nodes in previous versions. This helps to reduce memory usage and improve rendering performance. - From v3.7, you was able to generate customized Cocos Framework from cocos2d-x. We have improved this ability in v3.8, now you will be able to generate framework in debug mode. Here is the some documentation about it: +4. Decoupled Sprite's setTexture and updateColor in Web engine. - - [Framework compile documentation](http://www.cocos2d-x.org/wiki/Cocos_gen-libs). - - [How to customize Cocos Framework](http://www.cocos2d-x.org/docs/manual/studio/v4/chapter3/HowToCode/CustomizeFramework-v3.8/en) - - [How to generate Cocos Simulator](http://www.cocos2d-x.org/wiki/Cocos_gen-simulator) + - Organized the rendering logic in Sprite. UpdateColor is accomplished by texture instead of the Sprite. + - Fixed a bug about image with alpha channel that when the image is set to black, there is color difference between previous and current version. + - Improved texture update logic to reduce texture updates when changing colors. + - Improved the logic about the rendering function in SpriteCanvasRenderCmd. + - Removed some duplicate codes about updateColor. -4. Portrait projects support +5. Support for debugging and release on real devices with Xcode7 and iOS9 - From v3.8, you can generate portrait oriented games with Cocos Console: + In v3.8.1, we have made it possible to debug on Xcode7. However, there was a bug with iOS9 real device debuging, and in v3.9, we have fixed the bug. - ``` - cocos new -l cpp|lua|js --portrait MyPortraitGame - ``` - - More details can be found in [Cocos new command](http://www.cocos2d-x.org/wiki/Cocos_new) and [Cocos Console general documentation](http://www.cocos2d-x.org/wiki/Cocos2d-console) ## Other changes -- [NEW] UI: Enhanced ScrollView with easing out scrolling -- [NEW] UI: Added PageView vertical scroll support -- [NEW] UI: Added PageView::JumpToPage API -- [NEW] UI: Added a setter for line width in DrawNode -- [NEW] Action: Permitted setting bitwise flags to action -- [NEW] Animate: Added Animate's getCurrentFrameIndex function -- [NEW] FileUtils: Added FileUtils::getFileExtension for getting file's extension name -- [NEW] Device: Added vibrate support to enable vibration for a duration -- [NEW] UserDefault: Supported removing key pairs from UserDefault -- [NEW] spine: Supported Spine runtime 2.3 (Both native and web engine) -- [NEW] console: Moved the framework-compile tools into cocos2d-console -- [NEW] network: Upgrade SocketIO support to v1.x +[NEW] Label: Added line spacing/leading feature to Label. -- [REFINE] 3D: Supported composite 2D/3D scene by moving UI and camera far away -- [REFINE] 3D: Improved Particle3D performance -- [REFINE] Label: Supported adding child nodes in Label -- [REFINE] UI: Improved Slider's precision -- [REFINE] UI: Refined scroll event dispatching for ScrollView -- [REFINE] UI: Improved event handling in TextField -- [REFINE] Label: Supported auto batch with bitmap font or char map -- [REFINE] studio: Added BlendFrame support to Skeleton Animation -- [REFINE] studio: Enabled blendfunc cascade to the skin of BoneNode -- [REFINE] utils: Made utils::captureScreen saving file in another thread to improve the performance -- [REFINE] 3rd party: Update Nibiru SDK to 2.6 -- [REFINE] JS: Supported new construction for 3d classes in JS -- [REFINE] JS: Refine performance for Cocos Studio JSON parser for 2.x -- [REFINE] web: Avoid re-bake the content when the parent node's position get changed -- [REFINE] web: Solved repeat loading same resource issue when parsing cocos studio project -- [REFINE] web: Optimized resources automatic loading in JSON parser -- [REFINE] web: Avoid cc.loader resource loading being terminated while encounter errors -- [REFINE] web: Suspended the video player when the browser is minimized +[NEW] ListView: Added APIs to scroll to specific item in list. -You can also take a look at [the full changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG) +[NEW] ListView: Added APIs to get an item in specific position like center, leftmost, rightmost, topmost and bottommost. -## New APIs +[NEW] ListView: Added a feature for magnetic scrolling. -In the above changes, there are some new APIs introduced in v3.8, they are listed here: +[NEW] Animate: Added ActionTimeline::setAnimationEndCallBack and ActionTimeline::addFrameEndCallFunc. -1. PageView vertical scroll support +[NEW] Animate: Added CSLoader::createNodeWithVisibleSize, CSLoader::createNodeWithVisibleSize and moved "ui::Helper::DoLayout" into them. - ``` - PageView* pageView = PageView::create(); - pageView->setContentSize(Size(240.0f, 130.0f)); - pageView->setDirection(ui::PageView::Direction::VERTICAL); - ``` +[NEW] Stuio: Added support for Cocos Studio Light3D. -2. Setter for line width in DrawNode +[NEW] Platform: Added the missing CURL support to the Windows 10 UWP version. - ``` - DrawNode* drawNode = DrawNode::create(); - drawNode->setLineWidth(5.0f); - ``` +[NEW] Platform: Added UIEditBox support on linux platform. -3. Bitwise flags of action +[REFINE] 3D: Added non-null checks in PUScriptCompiler::visit before dereferencing. - ``` - enum Flags { - FRAME = 1, - COLOR = 2, - OPACITY = 4, - POSITION = 8, - SCALE = 16, - ROTATION = 32, - SKEW = 64 - }; +[REFINE] 3D: Refined SkyboxBrush by making the shader parameter take effect at once. - auto action = RepeatForever::create(Sequence::create(FadeTo::create( 0.1f, 155), TintTo::create(0.1f, 255,0,0), nullptr)); - // Since opacity and color will be modified in this action, it can be flagged as opacity and color action - action->setFlags(Flags::OPACITY|Flags::COLOR); +[REFINE] Label: Changed label font size type to float to support high precision when font size is small. - auto action2 = RepeatForever::create(Sequence::create(MoveBy::create(0.3f, Vec2(5, 0)), nullptr)); - // Since position will be modified in this action, it can be flagged as position action - action->setFlags(Flags::POSITION); - ``` +[REFINE] ListView: Fixed an issue that list view's Magnetic::CENTER is not working well when non-bounceable. -4. Get current frame index in animation +[REFINE] ListView: Added feature of jumping to a specific item in list view. - ``` - auto action = RepeatForever::create( Animate::create(animation); - sprite->runAction(action); - sprite->scheduleOnce([=](float){ - int index = action->getCurrentFrameIndex(); - // ... - }, 1.0f, "get-current-frame"); - - ``` +[REFINE] Sprite: Added a "unsupport image format!" log when creating a sprite in CCImage.cpp. -5. File's extension name getter +[REFINE] ScrollView: Merge logics of Scroll View for scroll by inertia and auto scroll into one. - ``` - std::string extension = FileUtils::getInstance()->getFileExtension("grossini.png"); - ``` +[REFINE] Animate: Moved initialization of image to an appropriate location, because it always called twice in +SpriteFrameCache::addSpriteFramesWithFile(). -6. Vibration support +[REFINE] Simulator: Changed the size of startFlag to 13. - ``` - // Virate the device for 0.5 second - Device::vibrate(0.5f); - ``` +[REFINE] Simulator: Show Node and Skeleton in the middle of the simulator. -7. Remove key pairs from UserDefault +[REFINE] Simulator: Removed screen direction check in simulator to avoid render error. - ``` - // Remove value referenced by "some key" - UserDefault::getInstance()->deleteValueForKey("some key"); - ``` +[REFINE] Pysics: Refined components to improve physics performance. -# The Next Step +[REFINE] UI: Refined ComponentContainer to improve performance. -In v3.9, we will continue to improve our framework, several important tasks are: +[REFINE] UI: EventListenerMouse will dispatch EventMouse events. -1. We are about to provide a script based component system. -2. Improve ScrollView, ListView performance in both native and web engine. -3. Improve 2D particle system performance. -4. Improve web engine renderer logic and performance. -5. Support Action inheritance in JSB. -6. Remove libcurl dependency on iOS and Android. +[REFINE] OpenGL: Added check for glfwCreateWindow. -[The v3.9 milestone tasks](https://github.com/cocos2d/cocos2d-x/milestones/v3.9) (It's still being reviewing and will be updated) +[REFINE] Platform: Fixed a crash on xiaomi2 if Cocos2d-x is built as a dynamic library. + +[REFINE] Platform: Updated libcococs2d name to v3.9 on WinRT platforms. + +[REFINE] Platform: Added some support for mouse on WinRT. Include: Show/Hide mouse cursor; Mouse event +implemented similar Desktop version; Left button send mouse event and touch; Support other mouse button and scroll +wheel. + +[REFINE] Platform: Correct the convertion between unicode and utf8 on WinRT. + +[REFINE] Platform: Improved EditBox implement on Win32 platform. + +[REFINE] JS: Add jsb.fileUtils.writeDataToFile(). + +[REFINE] JS: Set js templates Mac target platform from null to 10.7. + +[REFINE] JS: Removed the static define of variable in headfile of ScriptingCore. + +[REFINE] Lua: Added AssetsManagerEx constants UPDATE_FAILED and ERROR_DECOMPRESS in Lua. + +[REFINE] Lua / JS: Refined lua/js binding tool. + +[REFINE] I/O: Refined AssetsManagerEx unzipping by using async. + +[REFINE] Web: Improved logic of jsb_boot.js to sync with the web engine behavior. + +[REFINE] Web: Sync with CCBoot for web. + +[REFINE] Build: Fixed various compiler warnings on Xcode 7. + +[REFINE] Build: Fixed Wformat-security warning on Xcode. + +[REFINE] Build: Fixed a compile error in __LayerRGBA. + +[REFINE] Tool: Added tools for generating documents automatically. + +[REFINE] Doc: Clean up the code of setRect() function. + +[REFINE] Doc: Fixed a minor typo and renamed INTIAL_CAPS_ALL_CHARACTERS to INITIAL_CAPS_ALL_CHARACTERS +in UIEditBox. + +You can also take a look at the full changelog. + + +## NEW APIS + +1. Script component + + Added ComponentLua and ComponentJS components, easy to add Lua and JS scripts. + +2. 3D MotionStreak + + Added MotionStreak3D class to support 3D streak effects, see the following link for detailed information, https://github.com/cocos2d/cocos2d-x/pull/13647/files. + +3. JSB Module + + Added cc.fileUtils.writeDataToFile, please see https://github.com/cocos2d/cocos2d-x/pull/13726 + +4. Sprite3D + + Added Sprite3Dmaterial class to make it easy to create innate material. + +5. ActionTimelineData + + Three interfaces are added in ActionTimelineData class, which are addFrameEndCallFunc, removeFrameEndCall and clearFrameEndCalls. + +6. ActionTimeline::removeFrameEndCallFunc + +7. Improvements for ListView + + - Add APIs to scroll to specific item in list. + - Add APIs to get an item in specific position like center, leftmost, rightmost, topmost and bottommost. + - Add a feature for magnetic scrolling. + + For more information: https://github.com/cocos2d/cocos2d-x/pull/13723 + +8. Node + + Added the missing API getChildByTag + +9. Label + + Added setLineSpacing, getLineSpacing + +10. CSLoader + + Added createNodeWithVisibleSize, createNodeWithVisibleSize + +11. ComponentContainer + + Removed isEmpty + +12. Sprite + + Removed debugDraw(bool on) diff --git a/plugin b/plugin index ad539b56c5..4b68a78781 160000 --- a/plugin +++ b/plugin @@ -1 +1 @@ -Subproject commit ad539b56c5354c1083f479d4c8d275ae8c7fdfa7 +Subproject commit 4b68a78781f57c3cda70fcebb2a9066914d28efb diff --git a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist index bf6cc9e78c..3a52f89600 100644 --- a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist +++ b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist @@ -45,7 +45,7 @@ CFBundleSignature ???? CFBundleVersion - 20150314 + 20151106 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc index aa3ca86328..35e7e472f4 100755 --- a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc +++ b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc @@ -64,7 +64,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "About Simulator" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CTEXT "Version 3.9 (20150922)",IDC_ABOUT_VERSION,35,70,173,17 + CTEXT "Version 3.9 (20151106)",IDC_ABOUT_VERSION,35,70,173,17 CTEXT "Cocos Simulator",IDC_ABOUT_TITLE,35,49,173,17 CTEXT "Copyright (C) 2015. All rights reserved.",IDC_STATIC,35,94,173,17 ICON "GLFW_ICON",IDC_STATIC,111,15,20,20 diff --git a/web b/web index 85518886f7..1af39e177a 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 85518886f7ba8a618ec69bb75a9b7d67ea2d1c7d +Subproject commit 1af39e177a13bb54e1ee9c3eb60aca62b995a00e From 7a0d014194c0eef76434fdf682f4086a2c2d8c9a Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 6 Nov 2015 21:08:47 +0800 Subject: [PATCH 059/192] update file --- docs/RELEASE_NOTES.md | 181 ++++++++++++++++++++---------------------- 1 file changed, 85 insertions(+), 96 deletions(-) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 9c40e223c8..8fcb789e02 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -174,81 +174,80 @@ We are happy to announce the release of Cocos2d-x v3.9. Following are the highli ### 3D Module 1. 3D MotionStreak - - In this version, 3D MotionStreak is added to support streak effect. Check the testcase of Sprite3Dtest to see how to use it. + + In this version, 3D MotionStreak is added to support streak effect. Check the testcase: [Sprite3DTest](https://github.com/cocos2d/cocos2d-x/blob/v3/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp#L2472) to see how to use it. 2. Sprite3D - Added Sprite3D material class. It will be easy and convenient to create internal material. + Added Sprite3D material class. It will be easy and convenient to create internal material. ### 2D Module 1. Frame callback function and animation callback function - Three interfaces are added in ActionTimelineData class, which are addFrameEndCallFunc, removeFrameEndCall and clearFrameEndCalls. It will be easy to add or remove specific frame event. + Three interfaces are added in ActionTimelineData class, which are addFrameEndCallFunc, removeFrameEndCall and clearFrameEndCalls. It will be easy to add or remove specific frame event. 2. Script Component - Script component is used to extend c++ Nodes. You can add a script component to a Node, then the script component will receive onEnter,onExit and update events. For example: + Script component is used to extend c++ Nodes. You can add a script component to a Node, then the script component will receive onEnter,onExit and update events. For example: - ```c++ - // create a sprite and add a lua component auto player = - Sprite::create("player.png"); - - auto luaComponent = ComponentLua::create("player.lua"); - player->addComponent(luaComponent); - ``` - - ```lua - // player.lua - local player = { - onEnter = function(self) - -- do some things in onEnter - end - - onExit = function(slef) - -- do some things in onExit - end - - update = function(self) - -- do some things every frame - end - } - - -- it is needed to return player to let c++ nodes know it - return player - ``` - - Javascript can work as the same way, just use ComponentJS instead of ComponentLua. - - There are some differences between lua component and Javascript component: - - Should return the object in lua component, in Javascript, you only have to extend cc.ComponentJS, and ensure the result of the last statement is the class of Component. - - Lua component can only be used in lua projects, Javascript component can only be used in Javascript projects. - - More detail usage please refer to: `tests/lua-tests/src/ComponentTest` and `tests/js-tests/src/ComponentTest` + ```c++ + // create a sprite and add a lua component auto player = + Sprite::create("player.png"); + + auto luaComponent = ComponentLua::create("player.lua"); + player->addComponent(luaComponent); + ``` + + ```lua + // player.lua + local player = { + onEnter = function(self) + -- do some things in onEnter + end + + onExit = function(slef) + -- do some things in onExit + end + + update = function(self) + -- do some things every frame + end + } + + -- it is needed to return player to let c++ nodes know it + return player + ``` + + Javascript can work as the same way, just use ComponentJS instead of ComponentLua. + + There are some differences between lua component and Javascript component: + + Should return the object in lua component, in Javascript, you only have to extend cc.ComponentJS, and ensure the result of the last statement is the class of Component. + + Lua component can only be used in lua projects, Javascript component can only be used in Javascript projects. + + More detail usage please refer to: `tests/lua-tests/src/ComponentTest` and `tests/js-tests/src/ComponentTest` 3. 2D Physics - Before v3.9, there are many physics related codes in Node, such as Node::setPhysicsBody(). Since v3.9, we move these codes into physics component. + Before v3.9, there are many physics related codes in Node, such as Node::setPhysicsBody(). Since v3.9, we move these codes into physics component. - After using physics component, the way to use physics is changed. Before - v3.9, you can use physics like this: - - ``` - auto node = Node::create(); - node->setPhysicsBody(PhysicsBody::createEdgeBox(...)); - ``` - - Since v3.9 you should use like this: - - ``` - auto node = Node::create(); - node->addComponent(PhysicsBody::createEdgeBox(...)); + After using physics component, the way to use physics is changed. Before v3.9, you can use physics like this: + + ``` + auto node = Node::create(); + node->setPhysicsBody(PhysicsBody::createEdgeBox(...)); + ``` + + Since v3.9 you should use like this: + + ``` + auto node = Node::create(); + node->addComponent(PhysicsBody::createEdgeBox(...)); - ``` + ``` 4. EditBox implemention on iOS and Win32 platform @@ -259,9 +258,9 @@ We are happy to announce the release of Cocos2d-x v3.9. Following are the highli 5. Remove dependence of curl on AssetsManager, AssetsManagerEx and Downloader (iOS & Android) - >From v3.9, iOS and Android version will not depend on libcurl, which make - the game package smaller and solve some bugs caused by libcurl. Stability has - been improved with the updated iOS and Android system. + From v3.9, iOS and Android version will not depend on libcurl, which make + the game package smaller and solve some bugs caused by libcurl. Stability has + been improved with the updated iOS and Android system. 6. Improved particle performance. @@ -269,19 +268,18 @@ We are happy to announce the release of Cocos2d-x v3.9. Following are the highli 1. Supported Action inheritance, update function overwriting in JSB - In previous version of JSB, developers cannot inherit Action class in JS script, - such as Action / ActionInterval / ActionInstant, for their update function will not be called. In v3.9, developers can create subclass of Action and make extensions. More detail usage please refer to the textcase in ActionTest - / ActionCustomTest. + In previous version of JSB, developers cannot inherit Action class in JS script, such as Action / ActionInterval / ActionInstant, for their update function will not be called. In v3.9, developers can create subclass of Action and make extensions. More detail usage please refer to the textcase in ActionTest + / ActionCustomTest. 2. ScrollView performance on Web engine - ScrollView and ListView are the popular UI controls in Web engine. Their - performance is not perfect in previous versions, especially when there are multiple sub-controls. In v3.9, we have improved its rendering performance. They only act on the contents displayed on the current screen. Test - date shows that, comparing with v3.8, rendering efficiency of v3.9 have been improved for twice to four times in different devices and browsers. + ScrollView and ListView are the popular UI controls in Web engine. Their + performance is not perfect in previous versions, especially when there are multiple sub-controls. In v3.9, we have improved its rendering performance. They only act on the contents displayed on the current screen. Test + date shows that, comparing with v3.8, rendering efficiency of v3.9 have been improved for twice to four times in different devices and browsers. 3. Scale9Sprite performance on Web engine - In this version, we have changed the way to construct 9-slice sprite. The engine uses 9 rendering commands instead of the 9 nodes in previous versions. This helps to reduce memory usage and improve rendering performance. + In this version, we have changed the way to construct 9-slice sprite. The engine uses 9 rendering commands instead of the 9 nodes in previous versions. This helps to reduce memory usage and improve rendering performance. 4. Decoupled Sprite's setTexture and updateColor in Web engine. @@ -388,57 +386,48 @@ wheel. [REFINE] Doc: Fixed a minor typo and renamed INTIAL_CAPS_ALL_CHARACTERS to INITIAL_CAPS_ALL_CHARACTERS in UIEditBox. -You can also take a look at the full changelog. +You can also take a look at the [full changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG). ## NEW APIS -1. Script component +1. JSB Module - Added ComponentLua and ComponentJS components, easy to add Lua and JS scripts. + Added cc.fileUtils.writeDataToFile -2. 3D MotionStreak +2. Sprite3D - Added MotionStreak3D class to support 3D streak effects, see the following link for detailed information, https://github.com/cocos2d/cocos2d-x/pull/13647/files. + Added Sprite3Dmaterial class to make it easy to create innate material. -3. JSB Module +3. ActionTimelineData - Added cc.fileUtils.writeDataToFile, please see https://github.com/cocos2d/cocos2d-x/pull/13726 + Three interfaces are added in ActionTimelineData class, which are addFrameEndCallFunc, removeFrameEndCall and clearFrameEndCalls. -4. Sprite3D +4. ActionTimeline::removeFrameEndCallFunc - Added Sprite3Dmaterial class to make it easy to create innate material. - -5. ActionTimelineData - - Three interfaces are added in ActionTimelineData class, which are addFrameEndCallFunc, removeFrameEndCall and clearFrameEndCalls. - -6. ActionTimeline::removeFrameEndCallFunc - -7. Improvements for ListView +5. Improvements for ListView - Add APIs to scroll to specific item in list. - Add APIs to get an item in specific position like center, leftmost, rightmost, topmost and bottommost. - Add a feature for magnetic scrolling. - For more information: https://github.com/cocos2d/cocos2d-x/pull/13723 + For more information: https://github.com/cocos2d/cocos2d-x/pull/13723 -8. Node +6. Node - Added the missing API getChildByTag + Added the missing API getChildByTag -9. Label +7. Label - Added setLineSpacing, getLineSpacing + Added setLineSpacing, getLineSpacing -10. CSLoader +8. CSLoader - Added createNodeWithVisibleSize, createNodeWithVisibleSize + Added createNodeWithVisibleSize, createNodeWithVisibleSize +9. ComponentContainer -11. ComponentContainer + Removed isEmpty - Removed isEmpty +10. Sprite -12. Sprite - - Removed debugDraw(bool on) + Removed debugDraw(bool on) From 4cf252475b6a9183b5ece350499b2f48c02c1a15 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 6 Nov 2015 21:41:34 +0800 Subject: [PATCH 060/192] update RELEASE_NOTES.md --- docs/RELEASE_NOTES.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 8fcb789e02..a8940da63a 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -268,8 +268,7 @@ We are happy to announce the release of Cocos2d-x v3.9. Following are the highli 1. Supported Action inheritance, update function overwriting in JSB - In previous version of JSB, developers cannot inherit Action class in JS script, such as Action / ActionInterval / ActionInstant, for their update function will not be called. In v3.9, developers can create subclass of Action and make extensions. More detail usage please refer to the textcase in ActionTest - / ActionCustomTest. + In previous version of JSB, developers cannot inherit Action class in JS script, such as Action / ActionInterval / ActionInstant, for their update function will not be called. In v3.9, developers can create subclass of Action and make extensions. More detail usage please refer to the textcase in ActionTest / ActionCustomTest. 2. ScrollView performance on Web engine @@ -393,7 +392,7 @@ You can also take a look at the [full changelog](https://github.com/cocos2d/coco 1. JSB Module - Added cc.fileUtils.writeDataToFile + Added jsb.fileUtils.writeDataToFile 2. Sprite3D From eac57ec33e7e09fe6d541ef8cb45a71b47e2441e Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 9 Nov 2015 12:31:41 +0800 Subject: [PATCH 061/192] Web engine important issue fix --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index 1af39e177a..9f65531571 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 1af39e177a13bb54e1ee9c3eb60aca62b995a00e +Subproject commit 9f65531571443d7ea81beb86c3a7b5c2659057d0 From 1f0c498bcb5c26d884275ea747eba33621b66879 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 9 Nov 2015 19:45:17 +0800 Subject: [PATCH 062/192] Fixed actionNode position error bug --- cocos/editor-support/cocostudio/CCActionNode.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index f963a242f2..a879cd61f6 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "cocostudio/CCActionFrameEasing.h" #include "ui/UIWidget.h" #include "ui/UIHelper.h" +#include "ui/UILayout.h" #include "cocostudio/CocoLoader.h" #include "base/ccUtils.h" @@ -73,7 +74,14 @@ ActionNode::~ActionNode() void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) { + Widget * rw = dynamic_cast(root); + if (nullptr == rw) + return; + setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag")); + Widget* node = Helper::seekActionWidgetByActionTag(rw, getActionTag()); + bool positionOffset = node && (nullptr == (dynamic_cast(node))); + int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist"); for (int i=0; igetFloatValue_json(actionFrameDic, "positionx"); float positionY = DICTOOL->getFloatValue_json(actionFrameDic, "positiony"); + if (positionOffset && (nullptr != node->getParent())) + { + Vec2 AnchorPointIn = node->getParent()->getAnchorPointInPoints(); + positionX += AnchorPointIn.x; + positionY += AnchorPointIn.y; + } ActionMoveFrame* actionFrame = new (std::nothrow) ActionMoveFrame(); actionFrame->setFrameIndex(frameInex); actionFrame->setEasingType(frameTweenType); From 3aeb5e03892eea23cc3d57979e990add3f9f0b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=B3=B0?= Date: Mon, 9 Nov 2015 23:30:03 +0800 Subject: [PATCH 063/192] Fix when start simulator in CocoStudio to run a scene, can not read the correct config.json on MacOSX --- .../proj.ios_mac/mac/SimulatorApp.mm | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm index bc5ea77aa3..0a04d97885 100755 --- a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm +++ b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm @@ -206,6 +206,7 @@ static void glfwDropFunc(GLFWwindow *window, int count, const char **files) // set project directory as search root path string solutionDir = tmpConfig.getProjectDir(); + string spath = solutionDir; if (!solutionDir.empty()) { for (int i = 0; i < solutionDir.size(); ++i) @@ -215,6 +216,24 @@ static void glfwDropFunc(GLFWwindow *window, int count, const char **files) solutionDir[i] = '/'; } } + + spath = solutionDir; + if (spath[spath.length() - 1] == '/') { + spath = spath.substr(0, spath.length() - 1); + } + string strExtention = FileUtils::getInstance()->getFileExtension(spath); + int pos = -1; + if(strExtention.compare(".csd") == 0) + { + pos = spath.rfind('/'); + if(pos > 0) + spath = spath.substr(0, pos); + } + pos = spath.rfind('/'); + if(pos > 0) + spath = spath.substr(0, pos+1); + FileUtils::getInstance()->addSearchPath(spath); + FileUtils::getInstance()->setDefaultResourceRootPath(solutionDir); FileUtils::getInstance()->addSearchPath(solutionDir); FileUtils::getInstance()->addSearchPath(tmpConfig.getProjectDir()); @@ -226,7 +245,9 @@ static void glfwDropFunc(GLFWwindow *window, int count, const char **files) // parse config.json auto parser = ConfigParser::getInstance(); - auto configPath = solutionDir.append(CONFIG_FILE); + auto configPath = spath.append(CONFIG_FILE); + if(!FileUtils::getInstance()->isFileExist(configPath)) + configPath = solutionDir.append(CONFIG_FILE); parser->readConfig(configPath); // set information From 049607b5d8c1583748559a2439cdacbd0c2b1587 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Tue, 10 Nov 2015 21:03:51 +0900 Subject: [PATCH 064/192] Replace tab indents to 4 spaces. --- cocos/ui/UIListView.h | 52 +++++++++++++++--------------- cocos/ui/UIPageView.cpp | 42 ++++++++++++------------ cocos/ui/UIPageView.h | 66 +++++++++++++++++++------------------- cocos/ui/UIScrollView.cpp | 10 +++--- cocos/ui/UIScrollView.h | 4 +-- cocos/ui/UIScrollViewBar.h | 4 +-- 6 files changed, 89 insertions(+), 89 deletions(-) diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 09d5313099..778ddabfdf 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -255,25 +255,25 @@ public: virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void removeChild(Node* child, bool cleaup = true) override; - /** - * @brief Query the closest item to a specific position in inner container. - * - * @param targetPosition Specifies the target position in inner container's coordinates. - * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. - * @return A item instance if list view is not empty. Otherwise, returns null. - */ - Widget* getClosestItemToPosition(const Vec2& targetPosition, const Vec2& itemAnchorPoint) const; - - /** - * @brief Query the closest item to a specific position in current view. + /** + * @brief Query the closest item to a specific position in inner container. + * + * @param targetPosition Specifies the target position in inner container's coordinates. + * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. + * @return A item instance if list view is not empty. Otherwise, returns null. + */ + Widget* getClosestItemToPosition(const Vec2& targetPosition, const Vec2& itemAnchorPoint) const; + + /** + * @brief Query the closest item to a specific position in current view. * For instance, to find the item in the center of view, call 'getClosestItemToPositionInCurrentView(Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE)'. - * - * @param positionRatioInView Specifies the target position with ratio in list view's content size. - * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. - * @return A item instance if list view is not empty. Otherwise, returns null. - */ - Widget* getClosestItemToPositionInCurrentView(const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) const; - + * + * @param positionRatioInView Specifies the target position with ratio in list view's content size. + * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. + * @return A item instance if list view is not empty. Otherwise, returns null. + */ + Widget* getClosestItemToPositionInCurrentView(const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) const; + /** * @brief Query the center item * @return A item instance. @@ -327,15 +327,15 @@ public: */ void jumpToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint); - /** - * @brief Scroll to specific item - * @param positionRatioInView Specifies the position with ratio in list view's content size. - * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. - * @param timeInSec Scroll time - */ + /** + * @brief Scroll to specific item + * @param positionRatioInView Specifies the position with ratio in list view's content size. + * @param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. + * @param timeInSec Scroll time + */ void scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint); - void scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint, float timeInSec); - + void scrollToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint, float timeInSec); + /** * @brief Query current selected widget's idnex. * diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 7a65a0143c..173445b7ab 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -68,7 +68,7 @@ bool PageView::init() { setDirection(Direction::HORIZONTAL); setMagneticType(MagneticType::CENTER); - setScrollBarEnabled(false); + setScrollBarEnabled(false); return true; } return false; @@ -95,32 +95,32 @@ void PageView::setDirection(PageView::Direction direction) void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate) { - insertCustomItem(widget, pageIdx); + insertCustomItem(widget, pageIdx); } void PageView::addPage(Layout* page) { - pushBackCustomItem(page); + pushBackCustomItem(page); } void PageView::insertPage(Layout* page, int idx) { - insertCustomItem(page, idx); + insertCustomItem(page, idx); } void PageView::removePage(Layout* page) { - removeItem(getIndex(page)); + removeItem(getIndex(page)); } void PageView::removePageAtIndex(ssize_t index) { - removeItem(index); + removeItem(index); } void PageView::removeAllPages() { - removeAllItems(); + removeAllItems(); } void PageView::setCurPageIndex( ssize_t index ) @@ -279,22 +279,22 @@ void PageView::addEventListener(const ccPageViewCallback& callback) ssize_t PageView::getCurPageIndex() const { - Widget* widget = ListView::getCenterItemInCurrentView(); - return getIndex(widget); + Widget* widget = ListView::getCenterItemInCurrentView(); + return getIndex(widget); } Vector& PageView::getPages() { - CCASSERT(false, "This method is obsolete!"); + CCASSERT(false, "This method is obsolete!"); // Temporary code to keep backward compatibility. static Vector pages; - pages.clear(); - for(Widget* widget : getItems()) - { - pages.pushBack(dynamic_cast(widget)); - } - return pages; + pages.clear(); + for(Widget* widget : getItems()) + { + pages.pushBack(dynamic_cast(widget)); + } + return pages; } Layout* PageView::getPage(ssize_t index) @@ -306,11 +306,11 @@ Layout* PageView::getPage(ssize_t index) // Temporary code to keep backward compatibility. static Vector pages; - pages.clear(); - for(Widget* widget : getItems()) - { - pages.pushBack(dynamic_cast(widget)); - } + pages.clear(); + for(Widget* widget : getItems()) + { + pages.pushBack(dynamic_cast(widget)); + } return pages.at(index); } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 1a90bca135..f8a4071b66 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -121,8 +121,8 @@ public: * @param widget Widget to be added to pageview. * @param pageIdx A given index. * @param forceCreate If `forceCreate` is true and `widget` isn't exists, pageview would create a default page and add it. - * - * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. + * + * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. */ CC_DEPRECATED_ATTRIBUTE void addWidgetToPage(Widget* widget, ssize_t pageIdx, bool forceCreate); @@ -130,8 +130,8 @@ public: * Insert a page into the end of PageView. * * @param page Page to be inserted. - * - * Since v3.9, this is deprecated. Use `ListView::pushBackCustomItem(Widget* item)` instead. + * + * Since v3.9, this is deprecated. Use `ListView::pushBackCustomItem(Widget* item)` instead. */ CC_DEPRECATED_ATTRIBUTE void addPage(Layout* page); @@ -140,8 +140,8 @@ public: * * @param page Page to be inserted. * @param idx A given index. - * - * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. + * + * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. */ CC_DEPRECATED_ATTRIBUTE void insertPage(Layout* page, int idx); @@ -149,35 +149,35 @@ public: * Remove a page of PageView. * * @param page Page to be removed. - * - * Since v3.9, this is deprecated. Use `ListView::removeItem(getIndex(item))` instead. - */ - CC_DEPRECATED_ATTRIBUTE void removePage(Layout* page); + * + * Since v3.9, this is deprecated. Use `ListView::removeItem(getIndex(item))` instead. + */ + CC_DEPRECATED_ATTRIBUTE void removePage(Layout* page); /** * Remove a page at a given index of PageView. * * @param index A given index. - * - * Since v3.9, this is deprecated. Use `ListView::removeItem(ssize_t index)` instead. - */ - CC_DEPRECATED_ATTRIBUTE void removePageAtIndex(ssize_t index); + * + * Since v3.9, this is deprecated. Use `ListView::removeItem(ssize_t index)` instead. + */ + CC_DEPRECATED_ATTRIBUTE void removePageAtIndex(ssize_t index); /** * @brief Remove all pages of the PageView. - * - * Since v3.9, this is deprecated. Use `ListView::removeAllItems()` instead. - */ - CC_DEPRECATED_ATTRIBUTE void removeAllPages(); + * + * Since v3.9, this is deprecated. Use `ListView::removeAllItems()` instead. + */ + CC_DEPRECATED_ATTRIBUTE void removeAllPages(); /** * Scroll to a page with a given index. * * @param idx A given index in the PageView. Index start from 0 to pageCount -1. - * - * Since v3.9, this is deprecated. Use `ListView::scrollToItem(ssize_t itemIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE)` instead. - */ - CC_DEPRECATED_ATTRIBUTE void scrollToPage(ssize_t idx); + * + * Since v3.9, this is deprecated. Use `ListView::scrollToItem(ssize_t itemIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE)` instead. + */ + CC_DEPRECATED_ATTRIBUTE void scrollToPage(ssize_t idx); /** * Scroll to a page with a given index. @@ -205,9 +205,9 @@ public: * This is the different between scrollToPage. * * @param index A given index in PageView. Index start from 0 to pageCount -1. - * - * Since v3.9, this is deprecated. Use `setCurrentPageIndex()` instead. - */ + * + * Since v3.9, this is deprecated. Use `setCurrentPageIndex()` instead. + */ CC_DEPRECATED_ATTRIBUTE void setCurPageIndex(ssize_t index); /** @@ -221,20 +221,20 @@ public: /** * @brief Get all the pages in the PageView. * @return A vector of Layout pointers. - * - * Since v3.9, this is obsolete. Use `Vector& ListView::getItems()` instead. - */ - CC_DEPRECATED_ATTRIBUTE Vector& getPages(); + * + * Since v3.9, this is obsolete. Use `Vector& ListView::getItems()` instead. + */ + CC_DEPRECATED_ATTRIBUTE Vector& getPages(); /** * @brief Get a page at a given index * * @param index A given index. * @return A layout pointer in PageView container. - * - * Since v3.9, this is obsolete. Use `Widget* ListView::getItem(index)` instead. - */ - CC_DEPRECATED_ATTRIBUTE Layout* getPage(ssize_t index); + * + * Since v3.9, this is obsolete. Use `Widget* ListView::getItem(index)` instead. + */ + CC_DEPRECATED_ATTRIBUTE Layout* getPage(ssize_t index); /** * Add a page turn callback to PageView, then when one page is turning, the callback will be called. diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index d2238966f4..81ae8b64a6 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -1116,11 +1116,11 @@ bool ScrollView::isInertiaScrollEnabled() const void ScrollView::setScrollBarEnabled(bool enabled) { - if(_scrollBarEnabled == enabled) - { - return; - } - + if(_scrollBarEnabled == enabled) + { + return; + } + if(_scrollBarEnabled) { removeScrollBar(); diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 01edbdaea9..0fe4c75acb 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -572,8 +572,8 @@ protected: virtual void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack); - bool calculateCurrAndPrevTouchPoints(Touch* touch, Vec3* currPt, Vec3* prevPt); - void gatherTouchMove(const Vec2& delta); + bool calculateCurrAndPrevTouchPoints(Touch* touch, Vec3* currPt, Vec3* prevPt); + void gatherTouchMove(const Vec2& delta); Vec2 calculateTouchMoveVelocity() const; virtual void startAttenuatingAutoScroll(const Vec2& deltaMove, const Vec2& initialVelocity); diff --git a/cocos/ui/UIScrollViewBar.h b/cocos/ui/UIScrollViewBar.h index f0120a04f8..4a40e4cbe0 100644 --- a/cocos/ui/UIScrollViewBar.h +++ b/cocos/ui/UIScrollViewBar.h @@ -157,13 +157,13 @@ private: ScrollView* _parent; ScrollView::Direction _direction; - + Sprite* _upperHalfCircle; Sprite* _lowerHalfCircle; Sprite* _body; GLubyte _opacity; - + float _marginFromBoundary; float _marginForLength; From 89798d949bee466d4397b959c040b80012732afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=B5=D1=81=D1=88=D0=B0=D0=BF=D0=BE=D1=88=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Tue, 10 Nov 2015 15:13:05 +0300 Subject: [PATCH 065/192] [js-tests] Test case for Scale9Sprite fade actions with cascade opacity enabled Test case for https://github.com/cocos2d/cocos2d-html5/pull/3181 --- .../S9SpriteTest/S9SpriteTest.js | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js b/tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js index 942ff676d1..4b5669184f 100644 --- a/tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js +++ b/tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js @@ -570,6 +570,36 @@ var S9SpriteColorOpacityTest = S9SpriteTestDemo.extend({ } }); +var S9SpriteOpacityWithFadeActionsTest = S9SpriteTestDemo.extend({ + _title:"Test opacity cascade for Scale9Sprite with fade actions\n(fade to opacity 144, then fadeOut, then fadeIn)", + + ctor:function() { + this._super(); + + var colorLayer = new cc.LayerColor(cc.color(144,144,144)); + colorLayer.setContentSize(winSize.width / 2, winSize.height / 2); + colorLayer.x = winSize.width / 4; + colorLayer.y = winSize.height / 4; + + colorLayer.setCascadeOpacityEnabled(true); + + var blocks = new ccui.Scale9Sprite('blocks9.png'); + blocks.x = winSize.width / 4; + blocks.y = winSize.height / 4; + + colorLayer.addChild(blocks); + + var fadeToAction = cc.fadeTo(1, 144); + var delay = cc.delayTime(0.5); + var fadeOutAction = cc.fadeOut(0.8); + var fadeInAction = cc.fadeIn(0.8); + + colorLayer.runAction(cc.sequence(fadeToAction, delay, fadeOutAction, delay.clone(), fadeInAction)); + + this.addChild(colorLayer); + } +}); + var S9SpriteTestScene = TestScene.extend({ runThisTest:function (num) { sceneIdx = (num || num == 0) ? (num - 1) : -1; @@ -598,7 +628,8 @@ var arrayOfS9SpriteTest = [ S9FrameNameSpriteSheetRotatedInsetsScaled, S9_TexturePacker, S9SpriteActionTest, - S9SpriteColorOpacityTest + S9SpriteColorOpacityTest, + S9SpriteOpacityWithFadeActionsTest ]; var nextS9SpriteTest = function () { From 9cbbd283c78fa33c11c4ef13eacf77e05b5c4d72 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Tue, 10 Nov 2015 21:11:11 +0900 Subject: [PATCH 066/192] PageView - Deprecate the APIs related to custom scroll threshold. --- cocos/ui/UIPageView.cpp | 14 +-- cocos/ui/UIPageView.h | 15 +-- .../UIPageViewTest/UIPageViewTest.cpp | 97 ------------------- .../UIPageViewTest/UIPageViewTest.h | 17 ---- 4 files changed, 12 insertions(+), 131 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 173445b7ab..f5855fed90 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -35,8 +35,6 @@ PageView::PageView(): _indicator(nullptr), _indicatorPositionAsAnchorPoint(Vec2(0.5f, 0.1f)), _currentPageIndex(-1), -_customScrollThreshold(0.0), -_usingCustomScrollThreshold(false), _childFocusCancelOffset(5.0f), _pageViewEventListener(nullptr), _pageViewEventSelector(nullptr), @@ -145,24 +143,22 @@ void PageView::scrollToItem(ssize_t itemIndex) void PageView::setCustomScrollThreshold(float threshold) { - CCASSERT(threshold > 0, "Invalid threshold!"); - _customScrollThreshold = threshold; - this->setUsingCustomScrollThreshold(true); + CCLOG("PageView::setCustomScrollThreshold() has no effect!"); } float PageView::getCustomScrollThreshold()const { - return _customScrollThreshold; + return 0; } void PageView::setUsingCustomScrollThreshold(bool flag) { - _usingCustomScrollThreshold = flag; + CCLOG("PageView::setUsingCustomScrollThreshold() has no effect!"); } bool PageView::isUsingCustomScrollThreshold()const { - return _usingCustomScrollThreshold; + return false; } void PageView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack) @@ -334,8 +330,6 @@ void PageView::copySpecialProperties(Widget *widget) _ccEventCallback = pageView->_ccEventCallback; _pageViewEventListener = pageView->_pageViewEventListener; _pageViewEventSelector = pageView->_pageViewEventSelector; - _usingCustomScrollThreshold = pageView->_usingCustomScrollThreshold; - _customScrollThreshold = pageView->_customScrollThreshold; } } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index f8a4071b66..634c110c38 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -328,27 +328,31 @@ public: /** *@brief If you don't specify the value, the pageView will turn page when scrolling at the half width of a page. *@param threshold A threshold in float. + *@deprecated Since v3.9, this method has no effect. */ - void setCustomScrollThreshold(float threshold); + CC_DEPRECATED_ATTRIBUTE void setCustomScrollThreshold(float threshold); /** *@brief Query the custom scroll threshold of the PageView. *@return Custom scroll threshold in float. + *@deprecated Since v3.9, this method always returns 0. */ - float getCustomScrollThreshold()const; + CC_DEPRECATED_ATTRIBUTE float getCustomScrollThreshold()const; /** *@brief Set using user defined scroll page threshold or not. * If you set it to false, then the default scroll threshold is pageView.width / 2 *@param flag True if using custom scroll threshold, false otherwise. + *@deprecated Since v3.9, this method has no effect. */ - void setUsingCustomScrollThreshold(bool flag); + CC_DEPRECATED_ATTRIBUTE void setUsingCustomScrollThreshold(bool flag); /** *@brief Query whether use user defined scroll page threshold or not. *@return True if using custom scroll threshold, false otherwise. + *@deprecated Since v3.9, this method always returns false. */ - bool isUsingCustomScrollThreshold()const; + CC_DEPRECATED_ATTRIBUTE bool isUsingCustomScrollThreshold()const; CC_CONSTRUCTOR_ACCESS: virtual bool init() override; @@ -372,9 +376,6 @@ protected: ssize_t _currentPageIndex; - float _customScrollThreshold; - bool _usingCustomScrollThreshold; - float _childFocusCancelOffset; Ref* _pageViewEventListener; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index a14b712cf3..6b0b167d6b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -8,7 +8,6 @@ UIPageViewTests::UIPageViewTests() { ADD_TEST_CASE(UIPageViewTest); ADD_TEST_CASE(UIPageViewButtonTest); - ADD_TEST_CASE(UIPageViewCustomScrollThreshold); ADD_TEST_CASE(UIPageViewTouchPropagationTest); ADD_TEST_CASE(UIPageViewDynamicAddAndRemoveTest); ADD_TEST_CASE(UIPageViewJumpToPageTest); @@ -220,102 +219,6 @@ void UIPageViewButtonTest::pageViewEvent(Ref *pSender, PageView::EventType type) } -// UIPageViewCustomScrollThreshold -UIPageViewCustomScrollThreshold::UIPageViewCustomScrollThreshold() -: _displayValueLabel(nullptr) -{ - -} - -UIPageViewCustomScrollThreshold::~UIPageViewCustomScrollThreshold() -{ -} - -bool UIPageViewCustomScrollThreshold::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getContentSize(); - - // Add a label in which the dragpanel events will be displayed - _displayValueLabel = Text::create("Scroll Threshold", "fonts/Marker Felt.ttf", 32); - _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); - _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, - widgetSize.height / 2.0f + - _displayValueLabel->getContentSize().height * 1.5)); - _uiLayer->addChild(_displayValueLabel); - - // Add the black background - Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); - _uiLayer->addChild(alert); - - Layout* root = static_cast(_uiLayer->getChildByTag(81)); - - Layout* background = dynamic_cast(root->getChildByName("background_Panel")); - - // Create the page view - PageView* pageView = PageView::create(); - pageView->setContentSize(Size(240.0f, 100.0f)); - Size backgroundSize = background->getContentSize(); - pageView->setPosition(Vec2(widgetSize - pageView->getContentSize()) / 2.0f + Vec2(0, 20)); - - int pageCount = 4; - for (int i = 0; i < pageCount; ++i) - { - Layout* layout = Layout::create(); - layout->setContentSize(Size(240.0f, 130.0f)); - - ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); - imageView->setScale9Enabled(true); - imageView->setContentSize(Size(240, 130)); - imageView->setPosition(layout->getContentSize() / 2.0f); - layout->addChild(imageView); - - Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); - label->setColor(Color3B(192, 192, 192)); - label->setPosition(layout->getContentSize() / 2.0f); - layout->addChild(label); - - pageView->insertCustomItem(layout, i); - } - - _uiLayer->addChild(pageView); - pageView->setName("pageView"); - - Slider* slider = Slider::create(); - slider->loadBarTexture("cocosui/sliderTrack.png"); - slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); - slider->loadProgressBarTexture("cocosui/sliderProgress.png"); - slider->setPosition(Vec2(widgetSize.width / 2.0f , widgetSize.height / 2.0f - 40)); - slider->addEventListener(CC_CALLBACK_2(UIPageViewCustomScrollThreshold::sliderEvent, this)); - slider->setPercent(50); - _uiLayer->addChild(slider); - - - return true; - } - return false; -} - - -void UIPageViewCustomScrollThreshold::sliderEvent(Ref *pSender, Slider::EventType type) -{ - if (type == Slider::EventType::ON_PERCENTAGE_CHANGED) - { - Slider* slider = dynamic_cast(pSender); - int percent = slider->getPercent(); - PageView* pageView = (PageView*)_uiLayer->getChildByName("pageView"); - if (percent == 0) { - percent = 1; - } - pageView->setCustomScrollThreshold(percent * 0.01 * pageView->getContentSize().width); - - _displayValueLabel->setString(StringUtils::format("Scroll Threshold: %f", pageView->getCustomScrollThreshold())); - } -} - // UIPageViewTouchPropagationTest UIPageViewTouchPropagationTest::UIPageViewTouchPropagationTest() : _displayValueLabel(nullptr) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 3354bf8cb5..466b95673a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -61,23 +61,6 @@ protected: cocos2d::ui::Text* _displayValueLabel; }; -class UIPageViewCustomScrollThreshold : public UIScene -{ -public: - CREATE_FUNC(UIPageViewCustomScrollThreshold); - - UIPageViewCustomScrollThreshold(); - ~UIPageViewCustomScrollThreshold(); - virtual bool init() override; - - void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type); - - void pageViewEvent(cocos2d::Ref* sender, cocos2d::ui::PageView::EventType type); -protected: - - cocos2d::ui::Text* _displayValueLabel; -}; - class UIPageViewTouchPropagationTest : public UIScene { public: From 94637bef2fbdf6a4a55d688f29fad69b9eb03cab Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Tue, 10 Nov 2015 21:30:43 +0900 Subject: [PATCH 067/192] PageView - Change to keep some of the original API names because it makes more sense. --- cocos/ui/UIPageView.cpp | 6 +++--- cocos/ui/UIPageView.h | 31 +++++++++---------------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index f5855fed90..ac281c0424 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -96,17 +96,17 @@ void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate insertCustomItem(widget, pageIdx); } -void PageView::addPage(Layout* page) +void PageView::addPage(Widget* page) { pushBackCustomItem(page); } -void PageView::insertPage(Layout* page, int idx) +void PageView::insertPage(Widget* page, int idx) { insertCustomItem(page, idx); } -void PageView::removePage(Layout* page) +void PageView::removePage(Widget* page) { removeItem(getIndex(page)); } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 634c110c38..65d6724ad3 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -122,7 +122,7 @@ public: * @param pageIdx A given index. * @param forceCreate If `forceCreate` is true and `widget` isn't exists, pageview would create a default page and add it. * - * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. + * Since v3.9, this is deprecated. Use `insertPage(Widget* page, int idx)` instead. */ CC_DEPRECATED_ATTRIBUTE void addWidgetToPage(Widget* widget, ssize_t pageIdx, bool forceCreate); @@ -130,54 +130,42 @@ public: * Insert a page into the end of PageView. * * @param page Page to be inserted. - * - * Since v3.9, this is deprecated. Use `ListView::pushBackCustomItem(Widget* item)` instead. */ - CC_DEPRECATED_ATTRIBUTE void addPage(Layout* page); - + void addPage(Widget* page); + /** * Insert a page into PageView at a given index. * * @param page Page to be inserted. * @param idx A given index. - * - * Since v3.9, this is deprecated. Use `ListView::insertCustomItem(Widget* item, ssize_t index)` instead. */ - CC_DEPRECATED_ATTRIBUTE void insertPage(Layout* page, int idx); - + void insertPage(Widget* page, int idx); + /** * Remove a page of PageView. * * @param page Page to be removed. - * - * Since v3.9, this is deprecated. Use `ListView::removeItem(getIndex(item))` instead. */ - CC_DEPRECATED_ATTRIBUTE void removePage(Layout* page); + void removePage(Widget* page); /** * Remove a page at a given index of PageView. * * @param index A given index. - * - * Since v3.9, this is deprecated. Use `ListView::removeItem(ssize_t index)` instead. */ - CC_DEPRECATED_ATTRIBUTE void removePageAtIndex(ssize_t index); + void removePageAtIndex(ssize_t index); /** * @brief Remove all pages of the PageView. - * - * Since v3.9, this is deprecated. Use `ListView::removeAllItems()` instead. */ - CC_DEPRECATED_ATTRIBUTE void removeAllPages(); + void removeAllPages(); /** * Scroll to a page with a given index. * * @param idx A given index in the PageView. Index start from 0 to pageCount -1. - * - * Since v3.9, this is deprecated. Use `ListView::scrollToItem(ssize_t itemIndex, Vec2::ANCHOR_MIDDLE, Vec2::ANCHOR_MIDDLE)` instead. */ - CC_DEPRECATED_ATTRIBUTE void scrollToPage(ssize_t idx); + void scrollToPage(ssize_t idx); /** * Scroll to a page with a given index. @@ -244,7 +232,6 @@ public: */ CC_DEPRECATED_ATTRIBUTE void addEventListenerPageView(Ref *target, SEL_PageViewEvent selector); - /** * @brief Add a page turn callback to PageView, then when one page is turning, the callback will be called. * From be36cd73b79986f86f9ea184d8a5953fd1a1a72f Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 11 Nov 2015 06:11:58 +0000 Subject: [PATCH 068/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 17ccf1a17e..8229ef3f0d 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -962,6 +962,7 @@ "cocos/platform/android/java/src/org/cocos2dx/lib/GameControllerAdapter.java", "cocos/platform/android/java/src/org/cocos2dx/lib/GameControllerDelegate.java", "cocos/platform/android/java/src/org/cocos2dx/lib/GameControllerUtils.java", + "cocos/platform/android/java/src/org/cocos2dx/lib/ResizeLayout.java", "cocos/platform/android/javaactivity-android.cpp", "cocos/platform/android/jni/CocosPlayClient.cpp", "cocos/platform/android/jni/CocosPlayClient.h", From de9955b4cddd4a92b8dc9a99af53c2aa210733db Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 11 Nov 2015 06:22:22 +0000 Subject: [PATCH 069/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 34 ++-- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 65 +++++--- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 3 +- .../lua-bindings/auto/api/Application.lua | 24 +-- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 150 ++++++++++++------ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 1 + 6 files changed, 181 insertions(+), 96 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 71ea0c5668..993733e0c6 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -20948,18 +20948,6 @@ char */ cc.Application = { -/** - * @method openURL - * @param {String} arg0 - * @return {bool} - */ -openURL : function ( -str -) -{ - return false; -}, - /** * @method getTargetPlatform * @return {cc.ApplicationProtocol::Platform} @@ -20980,6 +20968,28 @@ getCurrentLanguage : function ( return 0; }, +/** + * @method openURL + * @param {String} arg0 + * @return {bool} + */ +openURL : function ( +str +) +{ + return false; +}, + +/** + * @method getVersion + * @return {String} + */ +getVersion : function ( +) +{ + return ; +}, + /** * @method getInstance * @return {cc.Application} diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 6f89ef7989..5b6c247352 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -65525,28 +65525,6 @@ void js_register_cocos2dx_SAXParser(JSContext *cx, JS::HandleObject global) { JSClass *jsb_cocos2d_Application_class; JSObject *jsb_cocos2d_Application_prototype; -bool js_cocos2dx_Application_openURL(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::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_openURL : 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_Application_openURL : Error processing arguments"); - bool ret = cobj->openURL(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Application_openURL : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -65583,6 +65561,46 @@ bool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_Application_getCurrentLanguage : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Application_openURL(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::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_openURL : 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_Application_openURL : Error processing arguments"); + bool ret = cobj->openURL(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Application_openURL : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Application_getVersion(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::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_getVersion : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getVersion(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Application_getVersion : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -65627,9 +65645,10 @@ void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { - JS_FN("openURL", js_cocos2dx_Application_openURL, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTargetPlatform", js_cocos2dx_Application_getTargetPlatform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentLanguage", js_cocos2dx_Application_getCurrentLanguage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("openURL", js_cocos2dx_Application_openURL, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVersion", js_cocos2dx_Application_getVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 8ee7d60804..5cb07c92a4 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -3763,9 +3763,10 @@ bool js_cocos2dx_Application_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2dx_Application_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_Application_openURL(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Application_openURL(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Application_getVersion(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_AnimationCache_class; diff --git a/cocos/scripting/lua-bindings/auto/api/Application.lua b/cocos/scripting/lua-bindings/auto/api/Application.lua index b1ebdffc20..1b14874a9c 100644 --- a/cocos/scripting/lua-bindings/auto/api/Application.lua +++ b/cocos/scripting/lua-bindings/auto/api/Application.lua @@ -3,15 +3,6 @@ -- @module Application -- @parent_module cc --------------------------------- --- brief Open url in default browser
--- param String with url to open.
--- return true if the resource located by the URL was successfully opened; otherwise false. --- @function [parent=#Application] openURL --- @param self --- @param #string url --- @return bool#bool ret (return value: bool) - -------------------------------- -- brief Get target platform -- @function [parent=#Application] getTargetPlatform @@ -32,6 +23,21 @@ -- @param self -- @return char#char ret (return value: char) +-------------------------------- +-- brief Open url in default browser
+-- param String with url to open.
+-- return true if the resource located by the URL was successfully opened; otherwise false. +-- @function [parent=#Application] openURL +-- @param self +-- @param #string url +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- brief Get application version. +-- @function [parent=#Application] getVersion +-- @param self +-- @return string#string ret (return value: string) + -------------------------------- -- brief Callback by Director to limit FPS.
-- param interval The time, expressed in seconds, between current frame and next. diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 6eead82ba4..10468d3f61 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -87288,56 +87288,6 @@ int lua_register_cocos2dx_Device(lua_State* tolua_S) return 1; } -int lua_cocos2dx_Application_openURL(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Application* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_openURL'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Application:openURL"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Application_openURL'", nullptr); - return 0; - } - bool ret = cobj->openURL(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Application:openURL",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_openURL'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Application_getTargetPlatform(lua_State* tolua_S) { int argc = 0; @@ -87479,6 +87429,103 @@ int lua_cocos2dx_Application_getCurrentLanguageCode(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Application_openURL(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Application* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_openURL'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Application:openURL"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Application_openURL'", nullptr); + return 0; + } + bool ret = cobj->openURL(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Application:openURL",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_openURL'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Application_getVersion(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Application* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_getVersion'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Application_getVersion'", nullptr); + return 0; + } + std::string ret = cobj->getVersion(); + tolua_pushcppstring(tolua_S,ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Application:getVersion",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_getVersion'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Application_setAnimationInterval(lua_State* tolua_S) { int argc = 0; @@ -87575,10 +87622,11 @@ int lua_register_cocos2dx_Application(lua_State* tolua_S) tolua_cclass(tolua_S,"Application","cc.Application","",nullptr); tolua_beginmodule(tolua_S,"Application"); - tolua_function(tolua_S,"openURL",lua_cocos2dx_Application_openURL); tolua_function(tolua_S,"getTargetPlatform",lua_cocos2dx_Application_getTargetPlatform); tolua_function(tolua_S,"getCurrentLanguage",lua_cocos2dx_Application_getCurrentLanguage); tolua_function(tolua_S,"getCurrentLanguageCode",lua_cocos2dx_Application_getCurrentLanguageCode); + tolua_function(tolua_S,"openURL",lua_cocos2dx_Application_openURL); + tolua_function(tolua_S,"getVersion",lua_cocos2dx_Application_getVersion); tolua_function(tolua_S,"setAnimationInterval",lua_cocos2dx_Application_setAnimationInterval); tolua_function(tolua_S,"getInstance", lua_cocos2dx_Application_getInstance); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 7bb4e20b98..cb389ce069 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2149,6 +2149,7 @@ int register_all_cocos2dx(lua_State* tolua_S); + #endif // __cocos2dx_h__ From 4ccc6ce5ded057ba69b82ebb4ebcd41564e486ff Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 11 Nov 2015 06:53:45 +0000 Subject: [PATCH 070/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 34 ++-- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 65 +++++--- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 3 +- .../lua-bindings/auto/api/Application.lua | 24 +-- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 150 ++++++++++++------ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 1 + 6 files changed, 181 insertions(+), 96 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 71ea0c5668..993733e0c6 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -20948,18 +20948,6 @@ char */ cc.Application = { -/** - * @method openURL - * @param {String} arg0 - * @return {bool} - */ -openURL : function ( -str -) -{ - return false; -}, - /** * @method getTargetPlatform * @return {cc.ApplicationProtocol::Platform} @@ -20980,6 +20968,28 @@ getCurrentLanguage : function ( return 0; }, +/** + * @method openURL + * @param {String} arg0 + * @return {bool} + */ +openURL : function ( +str +) +{ + return false; +}, + +/** + * @method getVersion + * @return {String} + */ +getVersion : function ( +) +{ + return ; +}, + /** * @method getInstance * @return {cc.Application} diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 6f89ef7989..5b6c247352 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -65525,28 +65525,6 @@ void js_register_cocos2dx_SAXParser(JSContext *cx, JS::HandleObject global) { JSClass *jsb_cocos2d_Application_class; JSObject *jsb_cocos2d_Application_prototype; -bool js_cocos2dx_Application_openURL(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::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_openURL : 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_Application_openURL : Error processing arguments"); - bool ret = cobj->openURL(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Application_openURL : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -65583,6 +65561,46 @@ bool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_Application_getCurrentLanguage : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Application_openURL(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::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_openURL : 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_Application_openURL : Error processing arguments"); + bool ret = cobj->openURL(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Application_openURL : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Application_getVersion(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::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_getVersion : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getVersion(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Application_getVersion : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -65627,9 +65645,10 @@ void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { - JS_FN("openURL", js_cocos2dx_Application_openURL, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTargetPlatform", js_cocos2dx_Application_getTargetPlatform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentLanguage", js_cocos2dx_Application_getCurrentLanguage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("openURL", js_cocos2dx_Application_openURL, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVersion", js_cocos2dx_Application_getVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 8ee7d60804..5cb07c92a4 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -3763,9 +3763,10 @@ bool js_cocos2dx_Application_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2dx_Application_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_Application_openURL(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Application_openURL(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Application_getVersion(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_AnimationCache_class; diff --git a/cocos/scripting/lua-bindings/auto/api/Application.lua b/cocos/scripting/lua-bindings/auto/api/Application.lua index b1ebdffc20..1b14874a9c 100644 --- a/cocos/scripting/lua-bindings/auto/api/Application.lua +++ b/cocos/scripting/lua-bindings/auto/api/Application.lua @@ -3,15 +3,6 @@ -- @module Application -- @parent_module cc --------------------------------- --- brief Open url in default browser
--- param String with url to open.
--- return true if the resource located by the URL was successfully opened; otherwise false. --- @function [parent=#Application] openURL --- @param self --- @param #string url --- @return bool#bool ret (return value: bool) - -------------------------------- -- brief Get target platform -- @function [parent=#Application] getTargetPlatform @@ -32,6 +23,21 @@ -- @param self -- @return char#char ret (return value: char) +-------------------------------- +-- brief Open url in default browser
+-- param String with url to open.
+-- return true if the resource located by the URL was successfully opened; otherwise false. +-- @function [parent=#Application] openURL +-- @param self +-- @param #string url +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- brief Get application version. +-- @function [parent=#Application] getVersion +-- @param self +-- @return string#string ret (return value: string) + -------------------------------- -- brief Callback by Director to limit FPS.
-- param interval The time, expressed in seconds, between current frame and next. diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 6eead82ba4..10468d3f61 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -87288,56 +87288,6 @@ int lua_register_cocos2dx_Device(lua_State* tolua_S) return 1; } -int lua_cocos2dx_Application_openURL(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Application* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_openURL'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Application:openURL"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Application_openURL'", nullptr); - return 0; - } - bool ret = cobj->openURL(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Application:openURL",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_openURL'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Application_getTargetPlatform(lua_State* tolua_S) { int argc = 0; @@ -87479,6 +87429,103 @@ int lua_cocos2dx_Application_getCurrentLanguageCode(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Application_openURL(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Application* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_openURL'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Application:openURL"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Application_openURL'", nullptr); + return 0; + } + bool ret = cobj->openURL(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Application:openURL",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_openURL'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Application_getVersion(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Application* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_getVersion'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Application_getVersion'", nullptr); + return 0; + } + std::string ret = cobj->getVersion(); + tolua_pushcppstring(tolua_S,ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Application:getVersion",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_getVersion'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Application_setAnimationInterval(lua_State* tolua_S) { int argc = 0; @@ -87575,10 +87622,11 @@ int lua_register_cocos2dx_Application(lua_State* tolua_S) tolua_cclass(tolua_S,"Application","cc.Application","",nullptr); tolua_beginmodule(tolua_S,"Application"); - tolua_function(tolua_S,"openURL",lua_cocos2dx_Application_openURL); tolua_function(tolua_S,"getTargetPlatform",lua_cocos2dx_Application_getTargetPlatform); tolua_function(tolua_S,"getCurrentLanguage",lua_cocos2dx_Application_getCurrentLanguage); tolua_function(tolua_S,"getCurrentLanguageCode",lua_cocos2dx_Application_getCurrentLanguageCode); + tolua_function(tolua_S,"openURL",lua_cocos2dx_Application_openURL); + tolua_function(tolua_S,"getVersion",lua_cocos2dx_Application_getVersion); tolua_function(tolua_S,"setAnimationInterval",lua_cocos2dx_Application_setAnimationInterval); tolua_function(tolua_S,"getInstance", lua_cocos2dx_Application_getInstance); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 7bb4e20b98..cb389ce069 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2149,6 +2149,7 @@ int register_all_cocos2dx(lua_State* tolua_S); + #endif // __cocos2dx_h__ From 9ec1e2069a0cbe9794c32c5a1b78aaba7f8ee8b0 Mon Sep 17 00:00:00 2001 From: mogemimi Date: Fri, 13 Nov 2015 14:38:48 +0900 Subject: [PATCH 071/192] Fix deprecated warnings --- cocos/editor-support/cocostudio/CCArmatureDataManager.cpp | 4 ++-- .../WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp index d0d7639a6e..5638bbbbb9 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp @@ -250,7 +250,7 @@ const cocos2d::Map& ArmatureDataManager::getTextureDa return _textureDatas; } -void CCArmatureDataManager::addRelativeData(const std::string& configFilePath) +void ArmatureDataManager::addRelativeData(const std::string& configFilePath) { if (_relativeDatas.find(configFilePath) == _relativeDatas.end()) { @@ -258,7 +258,7 @@ void CCArmatureDataManager::addRelativeData(const std::string& configFilePath) } } -RelativeData *CCArmatureDataManager::getRelativeData(const std::string& configFilePath) +RelativeData *ArmatureDataManager::getRelativeData(const std::string& configFilePath) { return &_relativeDatas[configFilePath]; } diff --git a/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp index 27ff13c4cf..4c2eeda87b 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp @@ -165,7 +165,7 @@ void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node, cocos2d::Node* ArmatureNodeReader::createNodeWithFlatBuffers(const flatbuffers::Table *nodeOptions) { - auto node = CCArmature::create(); + auto node = Armature::create(); // self auto options = (flatbuffers::CSArmatureNodeOption*)nodeOptions; From ad134a63637b45a8ba5821979aabb94f916f4b42 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Tue, 10 Nov 2015 22:31:31 +0900 Subject: [PATCH 072/192] PageView - Fix that the indicator's direction is not appropriate when `PageView::setDirection()` is called before `PageView::setIndicatorEnabled(true)`. --- cocos/ui/UIPageView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index ac281c0424..08a36f649b 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -348,6 +348,7 @@ void PageView::setIndicatorEnabled(bool enabled) else { _indicator = PageViewIndicator::create(); + _indicator->setDirection(getDirection()); addProtectedChild(_indicator, 10000); setIndicatorSelectedIndexColor(Color3B(100, 100, 255)); refreshIndicatorPosition(); From b0ae23d567b0082d446b3b262116d8c372e2693b Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 15 Nov 2015 19:32:41 +0900 Subject: [PATCH 073/192] PageView - Add more comments --- cocos/ui/UIPageView.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 08a36f649b..a6721351e1 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -210,19 +210,21 @@ void PageView::handleReleaseLogic(Touch *touch) Vec2 touchMoveVelocity = flattenVectorByDirection(calculateTouchMoveVelocity()); - static const float DEFAULT_THRESHOLD = 500; - if(touchMoveVelocity.length() < DEFAULT_THRESHOLD) + static const float INERTIA_THRESHOLD = 500; + if(touchMoveVelocity.length() < INERTIA_THRESHOLD) { startMagneticScroll(); } else { + // Handle paging by inertia force. Widget* currentPage = getItem(_currentPageIndex); Vec2 destination = calculateItemDestination(Vec2::ANCHOR_MIDDLE, currentPage, Vec2::ANCHOR_MIDDLE); - Vec2 deltaToCurrentpage; - deltaToCurrentpage = destination - getInnerContainerPosition(); + Vec2 deltaToCurrentpage = destination - getInnerContainerPosition(); deltaToCurrentpage = flattenVectorByDirection(deltaToCurrentpage); + // If the direction of displacement to current page and the direction of touch are same, just start magnetic scroll to the current page. + // Otherwise, move to the next page of touch direction. if(touchMoveVelocity.x * deltaToCurrentpage.x > 0 || touchMoveVelocity.y * deltaToCurrentpage.y > 0) { startMagneticScroll(); From 603d788fbffe0add7dd8c7bdf59f46315dccb785 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 15 Nov 2015 22:48:42 +0900 Subject: [PATCH 074/192] PageView - Fix that page indicator was not working well in vertical page view. --- cocos/ui/UIListView.cpp | 2 +- cocos/ui/UIPageView.cpp | 19 +++++++++++++++++-- cocos/ui/UIPageView.h | 3 +++ cocos/ui/UIPageViewIndicator.cpp | 3 +-- cocos/ui/UIPageViewIndicator.h | 2 +- .../UIPageViewTest/UIPageViewTest.cpp | 9 ++++----- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index 96795f7cbc..3fe85a218a 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -484,8 +484,8 @@ void ListView::doLayout() item->setLocalZOrder(i); remedyLayoutParameter(item); } - _innerContainer->forceDoLayout(); updateInnerContainerSize(); + _innerContainer->forceDoLayout(); _innerContainerDoLayoutDirty = false; } diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index a6721351e1..42198f6f0c 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -72,6 +72,22 @@ bool PageView::init() return false; } +void PageView::doLayout() +{ + if(!_innerContainerDoLayoutDirty) + { + return; + } + + ListView::doLayout(); + if(_indicator != nullptr) + { + ssize_t index = getIndex(getCenterItemInCurrentView()); + _indicator->indicate(index); + } + _innerContainerDoLayoutDirty = false; +} + void PageView::setDirection(PageView::Direction direction) { ListView::setDirection(direction); @@ -174,10 +190,9 @@ void PageView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack void PageView::onItemListChanged() { ListView::onItemListChanged(); - ssize_t index = getIndex(getCenterItemInCurrentView()); if(_indicator != nullptr) { - _indicator->reset(_items.size(), index); + _indicator->reset(_items.size()); } } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 65d6724ad3..c2129ccdda 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -344,6 +344,9 @@ public: CC_CONSTRUCTOR_ACCESS: virtual bool init() override; + //override methods + virtual void doLayout() override; + protected: void pageTurningEvent(); diff --git a/cocos/ui/UIPageViewIndicator.cpp b/cocos/ui/UIPageViewIndicator.cpp index 1389a3002a..6931b75ca8 100644 --- a/cocos/ui/UIPageViewIndicator.cpp +++ b/cocos/ui/UIPageViewIndicator.cpp @@ -71,7 +71,7 @@ void PageViewIndicator::setDirection(PageView::Direction direction) rearrange(); } -void PageViewIndicator::reset(ssize_t numberOfTotalPages, ssize_t currentIndex) +void PageViewIndicator::reset(ssize_t numberOfTotalPages) { while(_indexNodes.size() < numberOfTotalPages) { @@ -82,7 +82,6 @@ void PageViewIndicator::reset(ssize_t numberOfTotalPages, ssize_t currentIndex) decreaseNumberOfPages(); } rearrange(); - indicate(currentIndex); _currentIndexNode->setVisible(!_indexNodes.empty()); } diff --git a/cocos/ui/UIPageViewIndicator.h b/cocos/ui/UIPageViewIndicator.h index c72688bd2e..6adb2f7a98 100644 --- a/cocos/ui/UIPageViewIndicator.h +++ b/cocos/ui/UIPageViewIndicator.h @@ -49,7 +49,7 @@ public: virtual ~PageViewIndicator(); void setDirection(PageView::Direction direction); - void reset(ssize_t numberOfTotalPages, ssize_t currentIndex); + void reset(ssize_t numberOfTotalPages); void indicate(ssize_t index); void clear(); void setSpaceBetweenIndexNodes(float spaceBetweenIndexNodes); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index 6b0b167d6b..20040dfdb2 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -452,6 +452,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init() // Create the page view PageView* pageView = PageView::create(); + pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setContentSize(Size(240.0f, 130.0f)); pageView->setAnchorPoint(Vec2(0.5,0.5)); Size backgroundSize = background->getContentSize(); @@ -459,7 +460,8 @@ bool UIPageViewDynamicAddAndRemoveTest::init() pageView->setBackGroundColor(Color3B::GREEN); pageView->setBackGroundColorType(Layout::BackGroundColorType::SOLID); pageView->setIndicatorEnabled(true); - + pageView->setIndicatorSpaceBetweenIndexNodes(10); + int pageCount = 4; for (int i = 0; i < pageCount; ++i) { @@ -751,10 +753,7 @@ bool UIPageViewVerticalTest::init() pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); - pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + - (backgroundSize.width - pageView->getContentSize().width) / 2.0f, - (widgetSize.height - backgroundSize.height) / 2.0f + - (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); + pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); pageView->removeAllItems(); int pageCount = 4; From b99b3d11127ffdef16c24d213811aca52dd702ec Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Sun, 15 Nov 2015 23:02:43 +0900 Subject: [PATCH 075/192] Remove `CC_DLL` in front of `createSpriteFromBase64()` in ccUtils.h to avoid compilation error on windows platform --- cocos/base/ccUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/base/ccUtils.h b/cocos/base/ccUtils.h index eb7aee6d6f..1617e413aa 100644 --- a/cocos/base/ccUtils.h +++ b/cocos/base/ccUtils.h @@ -108,7 +108,7 @@ namespace utils * @return Returns an instance of sprite */ - Sprite* CC_DLL createSpriteFromBase64(const char* base64String); + Sprite* createSpriteFromBase64(const char* base64String); } From 974bdba154826ea89c09a63500c745387fd85bf5 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 16 Nov 2015 11:50:48 +0800 Subject: [PATCH 076/192] Fix issue in ComponentJS::~ComponentJS --- cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp index 29f98078f1..643a3abde3 100644 --- a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp +++ b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp @@ -94,7 +94,7 @@ ComponentJS::ComponentJS(const std::string& scriptFileName) ComponentJS::~ComponentJS() { mozilla::Maybe* jsObj = static_cast*>(_jsObj); - if (jsObj == nullptr) + if (jsObj != nullptr) { delete jsObj; } From eb644ee79f510b6628e10366e56bc1e489df1ef6 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 13 Nov 2015 17:44:23 +0800 Subject: [PATCH 077/192] Combine Studio change for 3d components --- cocos/3d/CCBundle3D.cpp | 2 ++ cocos/3d/CCMesh.cpp | 27 +++++++++++++++++++++++++++ cocos/3d/CCMesh.h | 4 ++++ cocos/3d/CCPlane.cpp | 13 +++++++++++++ cocos/3d/CCPlane.h | 5 +++++ cocos/3d/CCSprite3D.cpp | 29 +++++++++++++++++++++++++++++ cocos/3d/CCSprite3D.h | 3 +++ cocos/3d/CCTerrain.h | 6 +++--- cocos/renderer/CCTexture2D.h | 12 ++++++++++++ cocos/renderer/CCTextureCache.cpp | 22 ++++++++++++++++++++++ cocos/renderer/CCTextureCache.h | 10 ++++++++++ 11 files changed, 130 insertions(+), 3 deletions(-) diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index 8be4e25243..f6510ea58a 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -1048,7 +1048,9 @@ bool Bundle3D::loadJson(const std::string& path) if (_jsonReader.ParseInsitu<0>(_jsonBuffer).HasParseError()) { clear(); +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only CCASSERT(false, "Parse json failed"); +#endif return false; } diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index c6e81189ec..1abf4ad5b5 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -80,7 +80,11 @@ void Mesh::resetLightUniformValues() _spotLightUniformColorValues.assign(maxSpotLight, Vec3::ZERO); _spotLightUniformPositionValues.assign(maxSpotLight, Vec3::ZERO); _spotLightUniformDirValues.assign(maxSpotLight, Vec3::ZERO); +#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + _spotLightUniformInnerAngleCosValues.assign(maxSpotLight, 0.0f); +#else _spotLightUniformInnerAngleCosValues.assign(maxSpotLight, 1.0f); +#endif // CC_STUDIO_ENABLED_VIEW _spotLightUniformOuterAngleCosValues.assign(maxSpotLight, 0.0f); _spotLightUniformRangeInverseValues.assign(maxSpotLight, 0.0f); } @@ -117,6 +121,7 @@ Mesh::Mesh() , _visibleChanged(nullptr) , _blendDirty(true) , _force2DQueue(false) +, _texFile("") { } @@ -253,6 +258,7 @@ bool Mesh::isVisible() const void Mesh::setTexture(const std::string& texPath) { + _texFile = texPath; auto tex = Director::getInstance()->getTextureCache()->addImage(texPath); setTexture(tex); } @@ -284,6 +290,8 @@ void Mesh::setTexture(Texture2D* tex) } bindMeshCommand(); + + _texFile = _texture->getPath(); } Texture2D* Mesh::getTexture() const @@ -657,4 +665,23 @@ GLuint Mesh::getIndexBuffer() const { return _meshIndexData->getIndexBuffer()->getVBO(); } + +GLuint Mesh::checkTextureName() +{ + if (TextureCache::getInstance()->isDirty()) + { + Texture2D* cacheTex = TextureCache::getInstance()->getTextureForKey(_texFile); + _texture = cacheTex; + } + + if (_texture == nullptr || !_texture->isValid()) + { + _texture = nullptr; + Texture2D* dummyTex = getDummyTexture(); + return dummyTex->getName(); + } + + return _texture->getName(); +} + NS_CC_END diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index f4eb873620..ad5cff369d 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -194,6 +194,8 @@ public: */ void setForce2DQueue(bool force2D) { _force2DQueue = force2D; } + GLuint checkTextureName(); + CC_CONSTRUCTOR_ACCESS: Mesh(); @@ -234,6 +236,8 @@ protected: std::vector _spotLightUniformInnerAngleCosValues; std::vector _spotLightUniformOuterAngleCosValues; std::vector _spotLightUniformRangeInverseValues; + + std::string _texFile; }; // end of 3d group diff --git a/cocos/3d/CCPlane.cpp b/cocos/3d/CCPlane.cpp index 722ed2e91d..5b8acc4a94 100755 --- a/cocos/3d/CCPlane.cpp +++ b/cocos/3d/CCPlane.cpp @@ -92,4 +92,17 @@ PointSide Plane::getSide(const Vec3& point) const return PointSide::IN_PLANE; } +PointSide Plane::getSide(const Vec3& point, const Vec3& halfSize) const +{ + float dist = dist2Plane(point); + float maxAbsDist = fabs(_normal.x * halfSize.x) + fabs(_normal.y * halfSize.y) + fabs(_normal.z * halfSize.z); + + if (dist > maxAbsDist) + return PointSide::FRONT_PLANE; + else if (dist < -maxAbsDist) + return PointSide::BEHIND_PLANE; + else + return PointSide::IN_PLANE; +} + NS_CC_END diff --git a/cocos/3d/CCPlane.h b/cocos/3d/CCPlane.h index cc1baf822c..650c9c8655 100755 --- a/cocos/3d/CCPlane.h +++ b/cocos/3d/CCPlane.h @@ -100,6 +100,11 @@ public: */ PointSide getSide(const Vec3& point) const; + /** + * Return the side where the point is. + */ + PointSide getSide(const Vec3& point, const Vec3& halfSize) const; + protected: Vec3 _normal; // the normal line of the plane float _dist; // original displacement of the normal diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index f5178acc02..0e8e4198fa 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -895,6 +895,35 @@ void Sprite3D::setForce2DQueue(bool force2D) } } +const AABB& Sprite3D::getAABB(bool world) const +{ + _aabbDirty = true; + + Mat4 nodeToWorldTransform(getNodeToWorldTransform()); + + // If nodeToWorldTransform matrix isn't changed, we don't need to transform aabb. + if (memcmp(_nodeToWorldTransform.m, nodeToWorldTransform.m, sizeof(Mat4)) == 0 && !_aabbDirty) + { + return _aabb; + } + else + { + _aabb.reset(); + Mat4 transform(nodeToWorldTransform); + for (const auto& it : _meshes) { + if (it->isVisible()) + _aabb.merge(it->getAABB()); + } + + if (world) + _aabb.transform(transform); + + _nodeToWorldTransform = nodeToWorldTransform; + } + + return _aabb; +} + /////////////////////////////////////////////////////////////////////////////////// Sprite3DCache* Sprite3DCache::_cacheInstance = nullptr; Sprite3DCache* Sprite3DCache::getInstance() diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 77809a4438..c9f729d70f 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -200,6 +200,9 @@ public: */ void setForce2DQueue(bool force2D); + Vector& getMeshes() { return _meshes; } + const AABB& getAABB(bool world) const; + CC_CONSTRUCTOR_ACCESS: Sprite3D(); diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index 2220fecbd5..34cb6737ae 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -177,7 +177,7 @@ private: /* *terrain vertices internal data format **/ - struct TerrainVertexData + struct CC_DLL TerrainVertexData { /*constructor*/ TerrainVertexData(){}; @@ -192,7 +192,7 @@ private: cocos2d::Vec3 _normal; }; - struct QuadTree; + struct CC_DLL QuadTree; /* *the terminal node of quad, use to subdivision terrain mesh and LOD **/ @@ -267,7 +267,7 @@ private: *QuadTree * @breif use to hierarchically frustum culling and set LOD **/ - struct QuadTree + struct CC_DLL QuadTree { /**constructor*/ QuadTree(int x, int y, int width, int height, Terrain * terrain); diff --git a/cocos/renderer/CCTexture2D.h b/cocos/renderer/CCTexture2D.h index d429b3c987..e4c197fc23 100644 --- a/cocos/renderer/CCTexture2D.h +++ b/cocos/renderer/CCTexture2D.h @@ -406,6 +406,15 @@ public: /** Get a shader program from the texture.*/ GLProgram* getGLProgram() const; + void setValid(bool valid) { _valid = valid; } + bool isValid() const { return _valid; } + std::string getPath()const { return _filePath; } + +#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + // Following function must be use carefully, it may cause resource management issue. + // So it limited to use as cocostudio internal. + void setPath(std::string file) { _filePath = file; } +#endif public: /** Get pixel info map, the key-value pairs is PixelFormat and PixelFormatInfo.*/ @@ -540,6 +549,9 @@ protected: friend class SpriteFrameCache; friend class TextureCache; friend class ui::Scale9Sprite; + + bool _valid; + std::string _filePath; }; diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index ae4af57268..cd2896c007 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -598,6 +598,28 @@ std::string TextureCache::getCachedTextureInfo() const return buffer; } +#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only +void TextureCache::renameTextureWithKey(std::string srcName, std::string dstName) +{ + std::string key = srcName; + auto it = _textures.find(key); + + if( it == _textures.end() ) { + key = FileUtils::getInstance()->fullPathForFilename(srcName); + it = _textures.find(key); + } + + if( it != _textures.end() ) { + std::string fullpath = FileUtils::getInstance()->fullPathForFilename(dstName); + Texture2D* tex = it->second; + tex->setPath(key); + _textures.insert(std::make_pair(fullpath, tex)); + _textures.erase(it); + this->setDirty(true); + } +} +#endif + #if CC_ENABLE_CACHE_TEXTURE_DATA std::list VolatileTextureMgr::_textures; diff --git a/cocos/renderer/CCTextureCache.h b/cocos/renderer/CCTextureCache.h index 37631bc207..51dcdc3968 100644 --- a/cocos/renderer/CCTextureCache.h +++ b/cocos/renderer/CCTextureCache.h @@ -204,6 +204,14 @@ public: */ const std::string getTextureFilePath(Texture2D* texture)const; + void setDirty(bool dirty) { _dirty = dirty; } + bool isDirty() const { return _dirty; } +#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + // This function use Texture2D::setPath function, which set to use in + // CococsStudio internal only, so this function also been set internal only + void renameTextureWithKey(std::string srcName, std::string dstName); +#endif + private: void addImageAsyncCallBack(float dt); void loadImage(); @@ -228,6 +236,8 @@ protected: int _asyncRefCount; std::unordered_map _textures; + + bool _dirty; }; #if CC_ENABLE_CACHE_TEXTURE_DATA From e313f7be8b275bb0a7379caca772b2ffb60f4508 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 16 Nov 2015 15:56:23 +0800 Subject: [PATCH 078/192] Combine Studio change for ActionTimeline --- .../cocostudio/ActionTimeline/CCFrame.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index 1cbc10f4b6..125b649936 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -618,20 +618,44 @@ void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex) void InnerActionFrame::setStartFrameIndex(int frameIndex) { +#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + if (_enterWithName) + { + CCLOG(" cannot set start when enter frame with name. setEnterWithName false firstly!"); + throw std::exception(); + } +#else CCASSERT(!_enterWithName, " cannot setStartFrameIndex when enterWithName is set"); +#endif _startFrameIndex = frameIndex; } void InnerActionFrame::setEndFrameIndex(int frameIndex) { +#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + if (_enterWithName) + { + CCLOG(" cannot set end when enter frame with name. setEnterWithName false firstly!"); + throw std::exception(); + } +#else CCASSERT(!_enterWithName, " cannot setEndFrameIndex when enterWithName is set"); +#endif _endFrameIndex = frameIndex; } void InnerActionFrame::setAnimationName(const std::string& animationName) { +#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + if (!_enterWithName) + { + CCLOG(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!"); + throw std::exception(); + } +#else CCASSERT(_enterWithName, " cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!"); +#endif _animationName = animationName; } From e3c120eef45a1c2015e14d62c189b5d1750f0001 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 16 Nov 2015 18:25:26 +0800 Subject: [PATCH 079/192] Combine Studio change for compatible with 32 bit Mac System --- cocos/network/HttpAsynConnection-apple.h | 12 ++++++++++++ cocos/network/HttpAsynConnection-apple.m | 24 ++++++++++++------------ cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm | 21 +++++++++++++++++++++ 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/cocos/network/HttpAsynConnection-apple.h b/cocos/network/HttpAsynConnection-apple.h index 3de2b9b6db..3995cf2c09 100644 --- a/cocos/network/HttpAsynConnection-apple.h +++ b/cocos/network/HttpAsynConnection-apple.h @@ -34,6 +34,18 @@ /// @cond @interface HttpAsynConnection : NSObject { + NSString *srcURL; + NSString *sslFile; + NSDictionary *responseHeader; + NSMutableData *responseData; + NSInteger getDataTime; + NSInteger responseCode; + NSString *statusString; + NSError *responseError; + NSError *connError; + NSURLConnection *conn; + bool finish; + NSRunLoop *runLoop; } // The original URL to download. Due to redirects the actual content may come from another URL diff --git a/cocos/network/HttpAsynConnection-apple.m b/cocos/network/HttpAsynConnection-apple.m index b119d781cf..4f1faa9efe 100755 --- a/cocos/network/HttpAsynConnection-apple.m +++ b/cocos/network/HttpAsynConnection-apple.m @@ -35,18 +35,18 @@ @implementation HttpAsynConnection -@synthesize srcURL; -@synthesize sslFile; -@synthesize responseHeader; -@synthesize responseData; -@synthesize getDataTime; -@synthesize responseCode; -@synthesize statusString; -@synthesize responseError; -@synthesize connError; -@synthesize conn; -@synthesize finish; -@synthesize runLoop; +@synthesize srcURL = srcURL; +@synthesize sslFile = sslFile; +@synthesize responseHeader = responseHeader; +@synthesize responseData = responseData; +@synthesize getDataTime = getDataTime; +@synthesize responseCode = responseCode; +@synthesize statusString = statusString; +@synthesize responseError = responseError; +@synthesize connError = connError; +@synthesize conn = conn; +@synthesize finish = finish; +@synthesize runLoop = runLoop; - (void)dealloc { diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm b/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm index 230a3e00b3..b5afaadf98 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-mac.mm @@ -41,12 +41,16 @@ /** TODO: Missing doc - What does "CustomTextFieldFormatter" do? */ @interface CustomTextFieldFormatter : NSFormatter +{ + int _maximumLength; +} @property (nonatomic, assign) int maximumLength; @end @implementation CustomTextFieldFormatter +@synthesize maximumLength = _maximumLength; - (instancetype)init { @@ -88,6 +92,16 @@ #pragma mark - UIEditBox mac implementation @interface UIEditBoxImplMac : NSObject +{ + NSTextField* _textField; + NSSecureTextField* _secureTextField; + NSMutableDictionary* _placeholderAttributes; + NSWindow* _window; + + BOOL _editState; + BOOL _secure; + void* _editBox; +} @property (nonatomic, retain) NSTextField* textField; @property (nonatomic, retain) NSSecureTextField *secureTextField; @@ -110,6 +124,13 @@ @implementation UIEditBoxImplMac +@synthesize textField = _textField; +@synthesize secureTextField = _secureTextField; +@synthesize placeholderAttributes = _placeholderAttributes; +@synthesize window = _window; +@synthesize editState = _editState; +@synthesize secure = _secure; +@synthesize editBox = _editBox; - (instancetype)initWithFrame:(NSRect)frameRect editBox:(void *)editBox { From 3ee2e7a490f28473b146a2c49a26b9189fe649a1 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 17 Nov 2015 02:56:26 +0000 Subject: [PATCH 080/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_ui_auto_api.js | 20 ++++ .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 40 ++++++++ .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 2 + .../lua-bindings/auto/api/PolygonInfo.lua | 10 ++ .../lua-bindings/auto/api/Scale9Sprite.lua | 54 +++++----- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 52 ++++++++++ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 1 + .../auto/lua_cocos2dx_ui_auto.cpp | 99 +++++++++++++++++++ .../auto/lua_cocos2dx_ui_auto.hpp | 2 + 9 files changed, 258 insertions(+), 22 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index 5e4e35e850..b80d8118b7 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -5574,6 +5574,16 @@ float { }, +/** + * @method setRenderingType + * @param {ccui.Scale9Sprite::RenderingType} arg0 + */ +setRenderingType : function ( +renderingtype +) +{ +}, + /** * @method init * @param {cc.Sprite|cc.Sprite|cc.Sprite} sprite @@ -5658,6 +5668,16 @@ isScale9Enabled : function ( return false; }, +/** + * @method getRenderingType + * @return {ccui.Scale9Sprite::RenderingType} + */ +getRenderingType : function ( +) +{ + return 0; +}, + /** * @method getInsetRight * @return {float} diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 74538c2334..f2bae23c52 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -14793,6 +14793,26 @@ bool js_cocos2dx_ui_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setInsetTop : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Scale9Sprite_setRenderingType(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::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setRenderingType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Scale9Sprite::RenderingType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setRenderingType : Error processing arguments"); + cobj->setRenderingType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setRenderingType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) { bool ok = true; @@ -15036,6 +15056,24 @@ bool js_cocos2dx_ui_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, j JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Scale9Sprite_getRenderingType(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::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getRenderingType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getRenderingType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getRenderingType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -15675,6 +15713,7 @@ void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JS::HandleObject global JS_FN("initWithSpriteFrameName", js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSprite", js_cocos2dx_ui_Scale9Sprite_getSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInsetTop", js_cocos2dx_ui_Scale9Sprite_setInsetTop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRenderingType", js_cocos2dx_ui_Scale9Sprite_setRenderingType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_ui_Scale9Sprite_init, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPreferredSize", js_cocos2dx_ui_Scale9Sprite_setPreferredSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSpriteFrame", js_cocos2dx_ui_Scale9Sprite_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -15682,6 +15721,7 @@ void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JS::HandleObject global JS_FN("getInsetBottom", js_cocos2dx_ui_Scale9Sprite_getInsetBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsets", js_cocos2dx_ui_Scale9Sprite_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isScale9Enabled", js_cocos2dx_ui_Scale9Sprite_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderingType", js_cocos2dx_ui_Scale9Sprite_getRenderingType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInsetRight", js_cocos2dx_ui_Scale9Sprite_getInsetRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOriginalSize", js_cocos2dx_ui_Scale9Sprite_getOriginalSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithFile", js_cocos2dx_ui_Scale9Sprite_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index 08017797bc..ec3970e86e 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -756,6 +756,7 @@ bool js_cocos2dx_ui_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, js bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getSprite(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setRenderingType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); @@ -763,6 +764,7 @@ bool js_cocos2dx_ui_Scale9Sprite_getBlendFunc(JSContext *cx, uint32_t argc, jsva bool js_cocos2dx_ui_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getRenderingType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua b/cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua index 2be391e4b5..7a8be292b7 100644 --- a/cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua +++ b/cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua @@ -34,6 +34,16 @@ -- @param #cc.V3F_C4B_T2F_Quad quad -- @return PolygonInfo#PolygonInfo self (return value: cc.PolygonInfo) +-------------------------------- +-- set the data to be a pointer to a triangles
+-- the member verts will not be released when this PolygonInfo destructs
+-- as the verts memory are managed by other objects
+-- param triangles a pointer to the TrianglesCommand::Triangles object +-- @function [parent=#PolygonInfo] setTriangles +-- @param self +-- @param #cc.TrianglesCommand::Triangles triangles +-- @return PolygonInfo#PolygonInfo self (return value: cc.PolygonInfo) + -------------------------------- -- / @name Creators/ @{
-- Creates an empty Polygon info
diff --git a/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua b/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua index 82476db54f..48de7efb06 100644 --- a/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua +++ b/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua @@ -128,6 +128,16 @@ -- @param #float topInset -- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) +-------------------------------- +-- Set the slice sprite rendering type.
+-- When setting to SIMPLE, only 4 vertexes is used to rendering.
+-- otherwise 16 vertexes will be used to rendering.
+-- see RenderingType +-- @function [parent=#Scale9Sprite] setRenderingType +-- @param self +-- @param #int type +-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) + -------------------------------- -- @overload self, cc.Sprite, rect_table, rect_table -- @overload self, cc.Sprite, rect_table, bool, rect_table @@ -191,6 +201,12 @@ -- @param self -- @return bool#bool ret (return value: bool) +-------------------------------- +-- Return the slice sprite rendering type. +-- @function [parent=#Scale9Sprite] getRenderingType +-- @param self +-- @return int#int ret (return value: int) + -------------------------------- -- brief Query the right sprite's cap inset.
-- return The right sprite's cap inset. @@ -344,6 +360,14 @@ -- @param #float scaleX -- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) +-------------------------------- +-- +-- @function [parent=#Scale9Sprite] setCameraMask +-- @param self +-- @param #unsigned short mask +-- @param #bool applyChildren +-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) + -------------------------------- -- -- @function [parent=#Scale9Sprite] getScaleY @@ -356,25 +380,6 @@ -- @param self -- @return float#float ret (return value: float) --------------------------------- --- --- @function [parent=#Scale9Sprite] updateDisplayedOpacity --- @param self --- @param #unsigned char parentOpacity --- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) - --------------------------------- --- --- @function [parent=#Scale9Sprite] init --- @param self --- @return bool#bool ret (return value: bool) - --------------------------------- --- --- @function [parent=#Scale9Sprite] cleanup --- @param self --- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) - -------------------------------- -- @overload self, float, float -- @overload self, float @@ -386,12 +391,17 @@ -------------------------------- -- --- @function [parent=#Scale9Sprite] setCameraMask +-- @function [parent=#Scale9Sprite] updateDisplayedOpacity -- @param self --- @param #unsigned short mask --- @param #bool applyChildren +-- @param #unsigned char parentOpacity -- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) +-------------------------------- +-- +-- @function [parent=#Scale9Sprite] init +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- -- @function [parent=#Scale9Sprite] updateDisplayedColor diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 10468d3f61..53bbc062c0 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -20395,6 +20395,57 @@ int lua_cocos2dx_PolygonInfo_setQuad(lua_State* tolua_S) return 0; } +int lua_cocos2dx_PolygonInfo_setTriangles(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PolygonInfo*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_PolygonInfo_setTriangles'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::TrianglesCommand::Triangles arg0; + + #pragma warning NO CONVERSION TO NATIVE FOR Triangles + ok = false; + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_PolygonInfo_setTriangles'", nullptr); + return 0; + } + cobj->setTriangles(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PolygonInfo:setTriangles",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_PolygonInfo_setTriangles'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_PolygonInfo_constructor(lua_State* tolua_S) { int argc = 0; @@ -20447,6 +20498,7 @@ int lua_register_cocos2dx_PolygonInfo(lua_State* tolua_S) tolua_function(tolua_S,"getTriaglesCount",lua_cocos2dx_PolygonInfo_getTriaglesCount); tolua_function(tolua_S,"getVertCount",lua_cocos2dx_PolygonInfo_getVertCount); tolua_function(tolua_S,"setQuad",lua_cocos2dx_PolygonInfo_setQuad); + tolua_function(tolua_S,"setTriangles",lua_cocos2dx_PolygonInfo_setTriangles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PolygonInfo).name(); g_luaType[typeName] = "cc.PolygonInfo"; diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index cb389ce069..9cc34867e0 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2150,6 +2150,7 @@ int register_all_cocos2dx(lua_State* tolua_S); + #endif // __cocos2dx_h__ diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index c956bd8395..1b3ab7b6f0 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -24858,6 +24858,56 @@ int lua_cocos2dx_ui_Scale9Sprite_setInsetTop(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Scale9Sprite_setRenderingType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Scale9Sprite* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Scale9Sprite_setRenderingType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ui::Scale9Sprite::RenderingType arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.Scale9Sprite:setRenderingType"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Scale9Sprite_setRenderingType'", nullptr); + return 0; + } + cobj->setRenderingType(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Scale9Sprite:setRenderingType",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Scale9Sprite_setRenderingType'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Scale9Sprite_init(lua_State* tolua_S) { int argc = 0; @@ -25270,6 +25320,53 @@ int lua_cocos2dx_ui_Scale9Sprite_isScale9Enabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Scale9Sprite_getRenderingType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Scale9Sprite* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Scale9Sprite_getRenderingType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Scale9Sprite_getRenderingType'", nullptr); + return 0; + } + int ret = (int)cobj->getRenderingType(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Scale9Sprite:getRenderingType",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Scale9Sprite_getRenderingType'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Scale9Sprite_getInsetRight(lua_State* tolua_S) { int argc = 0; @@ -26168,6 +26265,7 @@ int lua_register_cocos2dx_ui_Scale9Sprite(lua_State* tolua_S) tolua_function(tolua_S,"initWithSpriteFrameName",lua_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName); tolua_function(tolua_S,"getSprite",lua_cocos2dx_ui_Scale9Sprite_getSprite); tolua_function(tolua_S,"setInsetTop",lua_cocos2dx_ui_Scale9Sprite_setInsetTop); + tolua_function(tolua_S,"setRenderingType",lua_cocos2dx_ui_Scale9Sprite_setRenderingType); tolua_function(tolua_S,"init",lua_cocos2dx_ui_Scale9Sprite_init); tolua_function(tolua_S,"setPreferredSize",lua_cocos2dx_ui_Scale9Sprite_setPreferredSize); tolua_function(tolua_S,"setSpriteFrame",lua_cocos2dx_ui_Scale9Sprite_setSpriteFrame); @@ -26175,6 +26273,7 @@ int lua_register_cocos2dx_ui_Scale9Sprite(lua_State* tolua_S) tolua_function(tolua_S,"getInsetBottom",lua_cocos2dx_ui_Scale9Sprite_getInsetBottom); tolua_function(tolua_S,"getCapInsets",lua_cocos2dx_ui_Scale9Sprite_getCapInsets); tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_Scale9Sprite_isScale9Enabled); + tolua_function(tolua_S,"getRenderingType",lua_cocos2dx_ui_Scale9Sprite_getRenderingType); tolua_function(tolua_S,"getInsetRight",lua_cocos2dx_ui_Scale9Sprite_getInsetRight); tolua_function(tolua_S,"getOriginalSize",lua_cocos2dx_ui_Scale9Sprite_getOriginalSize); tolua_function(tolua_S,"initWithFile",lua_cocos2dx_ui_Scale9Sprite_initWithFile); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 4901bde69f..15e87279e6 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -626,6 +626,8 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + From ec86ea47a595f825017a7f71d93e62cd778d42f3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 17 Nov 2015 03:32:26 +0000 Subject: [PATCH 081/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_ui_auto_api.js | 20 ++--- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 48 +++++------ .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 2 +- .../lua-bindings/auto/api/Widget.lua | 14 ++-- .../auto/lua_cocos2dx_ui_auto.cpp | 83 ++++++++----------- 5 files changed, 75 insertions(+), 92 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index b80d8118b7..fcfde192e9 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -692,16 +692,6 @@ isPropagateTouchEvents : function ( return false; }, -/** - * @method getCurrentFocusedWidget - * @return {ccui.Widget} - */ -getCurrentFocusedWidget : function ( -) -{ - return ccui.Widget; -}, - /** * @method hitTest * @param {vec2_object} arg0 @@ -928,6 +918,16 @@ bool { }, +/** + * @method getCurrentFocusedWidget + * @return {ccui.Widget} + */ +getCurrentFocusedWidget : function ( +) +{ + return ccui.Widget; +}, + /** * @method create * @return {ccui.Widget} diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index f2bae23c52..bed3ab2c22 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -1642,31 +1642,6 @@ bool js_cocos2dx_ui_Widget_isPropagateTouchEvents(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_ui_Widget_isPropagateTouchEvents : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(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::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_getCurrentFocusedWidget : Invalid Native Object"); - if (argc == 0) { - cocos2d::ui::Widget* ret = cobj->getCurrentFocusedWidget(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCurrentFocusedWidget : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2184,6 +2159,27 @@ bool js_cocos2dx_ui_Widget_enableDpadNavigation(JSContext *cx, uint32_t argc, js return false; } +bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::Widget* ret = cocos2d::ui::Widget::getCurrentFocusedWidget(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCurrentFocusedWidget : wrong number of arguments"); + return false; +} + bool js_cocos2dx_ui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2321,7 +2317,6 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { JS_FN("dispatchFocusEvent", js_cocos2dx_ui_Widget_dispatchFocusEvent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUnifySizeEnabled", js_cocos2dx_ui_Widget_setUnifySizeEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPropagateTouchEvents", js_cocos2dx_ui_Widget_isPropagateTouchEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCurrentFocusedWidget", js_cocos2dx_ui_Widget_getCurrentFocusedWidget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hitTest", js_cocos2dx_ui_Widget_hitTest, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isLayoutComponentEnabled", js_cocos2dx_ui_Widget_isLayoutComponentEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestFocus", js_cocos2dx_ui_Widget_requestFocus, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2348,6 +2343,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec st_funcs[] = { JS_FN("enableDpadNavigation", js_cocos2dx_ui_Widget_enableDpadNavigation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentFocusedWidget", js_cocos2dx_ui_Widget_getCurrentFocusedWidget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("create", js_cocos2dx_ui_Widget_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index ec3970e86e..e4f6d7a9b1 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -102,7 +102,6 @@ bool js_cocos2dx_ui_Widget_isBright(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setUnifySizeEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isPropagateTouchEvents(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isLayoutComponentEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_requestFocus(JSContext *cx, uint32_t argc, jsval *vp); @@ -124,6 +123,7 @@ bool js_cocos2dx_ui_Widget_setBright(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setCallbackType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_enableDpadNavigation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_Widget(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/Widget.lua b/cocos/scripting/lua-bindings/auto/api/Widget.lua index 0a035ad5bd..e4cdc1ea47 100644 --- a/cocos/scripting/lua-bindings/auto/api/Widget.lua +++ b/cocos/scripting/lua-bindings/auto/api/Widget.lua @@ -376,13 +376,6 @@ -- @param self -- @return bool#bool ret (return value: bool) --------------------------------- --- Return a current focused widget in your UI scene.
--- No matter what widget object you call this method on , it will return you the exact one focused widget. --- @function [parent=#Widget] getCurrentFocusedWidget --- @param self --- @return Widget#Widget ret (return value: ccui.Widget) - -------------------------------- -- Checks a point is in widget's content space.
-- This function is used for determining touch area of widget.
@@ -551,6 +544,13 @@ -- @param #bool enable -- @return Widget#Widget self (return value: ccui.Widget) +-------------------------------- +-- Return a current focused widget in your UI scene.
+-- No matter what widget object you call this method on , it will return you the exact one focused widget. +-- @function [parent=#Widget] getCurrentFocusedWidget +-- @param self +-- @return Widget#Widget ret (return value: ccui.Widget) + -------------------------------- -- Create and return a empty Widget instance pointer. -- @function [parent=#Widget] create diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 1b3ab7b6f0..aff0f3f462 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -3102,53 +3102,6 @@ int lua_cocos2dx_ui_Widget_isPropagateTouchEvents(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_getCurrentFocusedWidget(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Widget* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'", nullptr); - return 0; - } - cocos2d::ui::Widget* ret = cobj->getCurrentFocusedWidget(); - object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Widget:getCurrentFocusedWidget",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Widget_hitTest(lua_State* tolua_S) { int argc = 0; @@ -4127,6 +4080,40 @@ int lua_cocos2dx_ui_Widget_enableDpadNavigation(lua_State* tolua_S) #endif return 0; } +int lua_cocos2dx_ui_Widget_getCurrentFocusedWidget(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'", nullptr); + return 0; + } + cocos2d::ui::Widget* ret = cocos2d::ui::Widget::getCurrentFocusedWidget(); + object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.Widget:getCurrentFocusedWidget",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'.",&tolua_err); +#endif + return 0; +} int lua_cocos2dx_ui_Widget_create(lua_State* tolua_S) { int argc = 0; @@ -4257,7 +4244,6 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S) tolua_function(tolua_S,"dispatchFocusEvent",lua_cocos2dx_ui_Widget_dispatchFocusEvent); tolua_function(tolua_S,"setUnifySizeEnabled",lua_cocos2dx_ui_Widget_setUnifySizeEnabled); tolua_function(tolua_S,"isPropagateTouchEvents",lua_cocos2dx_ui_Widget_isPropagateTouchEvents); - tolua_function(tolua_S,"getCurrentFocusedWidget",lua_cocos2dx_ui_Widget_getCurrentFocusedWidget); tolua_function(tolua_S,"hitTest",lua_cocos2dx_ui_Widget_hitTest); tolua_function(tolua_S,"isLayoutComponentEnabled",lua_cocos2dx_ui_Widget_isLayoutComponentEnabled); tolua_function(tolua_S,"requestFocus",lua_cocos2dx_ui_Widget_requestFocus); @@ -4278,6 +4264,7 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S) tolua_function(tolua_S,"setCallbackType",lua_cocos2dx_ui_Widget_setCallbackType); tolua_function(tolua_S,"isSwallowTouches",lua_cocos2dx_ui_Widget_isSwallowTouches); tolua_function(tolua_S,"enableDpadNavigation", lua_cocos2dx_ui_Widget_enableDpadNavigation); + tolua_function(tolua_S,"getCurrentFocusedWidget", lua_cocos2dx_ui_Widget_getCurrentFocusedWidget); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Widget_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::Widget).name(); From 0794c7a43c7506c59dc22a655a03cd516d536c9e Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 17 Nov 2015 04:09:43 +0000 Subject: [PATCH 082/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_ui_auto_api.js | 256 ++--- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 633 ++++++------ .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 32 +- .../lua-bindings/auto/api/ListView.lua | 8 +- .../lua-bindings/auto/api/PageView.lua | 222 ++-- .../lua-bindings/auto/api/Widget.lua | 14 +- .../auto/lua_cocos2dx_ui_auto.cpp | 948 ++++++++++-------- .../auto/lua_cocos2dx_ui_auto.hpp | 2 + 8 files changed, 1114 insertions(+), 1001 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index b80d8118b7..ef1bdc4d44 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -692,16 +692,6 @@ isPropagateTouchEvents : function ( return false; }, -/** - * @method getCurrentFocusedWidget - * @return {ccui.Widget} - */ -getCurrentFocusedWidget : function ( -) -{ - return ccui.Widget; -}, - /** * @method hitTest * @param {vec2_object} arg0 @@ -928,6 +918,16 @@ bool { }, +/** + * @method getCurrentFocusedWidget + * @return {ccui.Widget} + */ +getCurrentFocusedWidget : function ( +) +{ + return ccui.Widget; +}, + /** * @method create * @return {ccui.Widget} @@ -3353,12 +3353,12 @@ getItemsMargin : function ( /** * @method jumpToItem - * @param {int} arg0 + * @param {long} arg0 * @param {vec2_object} arg1 * @param {vec2_object} arg2 */ jumpToItem : function ( -int, +long, vec2, vec2 ) @@ -3517,13 +3517,13 @@ long /** * @method scrollToItem -* @param {int|int} int +* @param {long|long} long * @param {vec2_object|vec2_object} vec2 * @param {vec2_object|vec2_object} vec2 * @param {float} float */ scrollToItem : function( -int, +long, vec2, vec2, float @@ -4706,121 +4706,117 @@ TextBMFont : function ( ccui.PageView = { /** - * @method getCustomScrollThreshold - * @return {float} - */ -getCustomScrollThreshold : function ( -) -{ - return 0; -}, - -/** - * @method getCurPageIndex - * @return {long} - */ -getCurPageIndex : function ( -) -{ - return 0; -}, - -/** - * @method setDirection - * @param {ccui.PageView::Direction} arg0 - */ -setDirection : function ( -direction -) -{ -}, - -/** - * @method addWidgetToPage - * @param {ccui.Widget} arg0 - * @param {long} arg1 - * @param {bool} arg2 - */ -addWidgetToPage : function ( -widget, -long, -bool -) -{ -}, - -/** - * @method isUsingCustomScrollThreshold - * @return {bool} - */ -isUsingCustomScrollThreshold : function ( -) -{ - return false; -}, - -/** - * @method setCurPageIndex - * @param {long} arg0 - */ -setCurPageIndex : function ( -long -) -{ -}, - -/** - * @method removePage - * @param {ccui.Layout} arg0 - */ -removePage : function ( -layout -) -{ -}, - -/** - * @method setUsingCustomScrollThreshold - * @param {bool} arg0 - */ -setUsingCustomScrollThreshold : function ( -bool -) -{ -}, - -/** - * @method setCustomScrollThreshold + * @method setIndicatorSpaceBetweenIndexNodes * @param {float} arg0 */ -setCustomScrollThreshold : function ( +setIndicatorSpaceBetweenIndexNodes : function ( float ) { }, +/** + * @method setIndicatorSelectedIndexColor + * @param {color3b_object} arg0 + */ +setIndicatorSelectedIndexColor : function ( +color3b +) +{ +}, + +/** + * @method getIndicatorSelectedIndexColor + * @return {color3b_object} + */ +getIndicatorSelectedIndexColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method getIndicatorPositionAsAnchorPoint + * @return {vec2_object} + */ +getIndicatorPositionAsAnchorPoint : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setIndicatorPosition + * @param {vec2_object} arg0 + */ +setIndicatorPosition : function ( +vec2 +) +{ +}, + +/** + * @method getIndicatorPosition + * @return {vec2_object} + */ +getIndicatorPosition : function ( +) +{ + return cc.Vec2; +}, + /** * @method insertPage - * @param {ccui.Layout} arg0 + * @param {ccui.Widget} arg0 * @param {int} arg1 */ insertPage : function ( -layout, +widget, int ) { }, /** - * @method getDirection - * @return {ccui.PageView::Direction} + * @method getCurrentPageIndex + * @return {long} */ -getDirection : function ( +getCurrentPageIndex : function ( ) { return 0; }, +/** + * @method removePage + * @param {ccui.Widget} arg0 + */ +removePage : function ( +widget +) +{ +}, + +/** + * @method setCurrentPageIndex + * @param {long} arg0 + */ +setCurrentPageIndex : function ( +long +) +{ +}, + +/** + * @method getIndicatorEnabled + * @return {bool} + */ +getIndicatorEnabled : function ( +) +{ + return false; +}, + /** * @method scrollToPage * @param {long} arg0 @@ -4832,35 +4828,53 @@ long }, /** - * @method getPage - * @param {long} arg0 - * @return {ccui.Layout} + * @method setIndicatorPositionAsAnchorPoint + * @param {vec2_object} arg0 */ -getPage : function ( -long +setIndicatorPositionAsAnchorPoint : function ( +vec2 ) { - return ccui.Layout; }, /** - * @method removePageAtIndex + * @method scrollToItem * @param {long} arg0 */ -removePageAtIndex : function ( +scrollToItem : function ( long ) { }, /** - * @method getPages - * @return {Array} + * @method setIndicatorEnabled + * @param {bool} arg0 */ -getPages : function ( +setIndicatorEnabled : function ( +bool ) { - return new Array(); +}, + +/** + * @method addPage + * @param {ccui.Widget} arg0 + */ +addPage : function ( +widget +) +{ +}, + +/** + * @method getIndicatorSpaceBetweenIndexNodes + * @return {float} + */ +getIndicatorSpaceBetweenIndexNodes : function ( +) +{ + return 0; }, /** @@ -4872,11 +4886,11 @@ removeAllPages : function ( }, /** - * @method addPage - * @param {ccui.Layout} arg0 + * @method removePageAtIndex + * @param {long} arg0 */ -addPage : function ( -layout +removePageAtIndex : function ( +long ) { }, diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index f2bae23c52..5806452cd8 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -1642,31 +1642,6 @@ bool js_cocos2dx_ui_Widget_isPropagateTouchEvents(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_ui_Widget_isPropagateTouchEvents : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(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::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_getCurrentFocusedWidget : Invalid Native Object"); - if (argc == 0) { - cocos2d::ui::Widget* ret = cobj->getCurrentFocusedWidget(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCurrentFocusedWidget : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2184,6 +2159,27 @@ bool js_cocos2dx_ui_Widget_enableDpadNavigation(JSContext *cx, uint32_t argc, js return false; } +bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::Widget* ret = cocos2d::ui::Widget::getCurrentFocusedWidget(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCurrentFocusedWidget : wrong number of arguments"); + return false; +} + bool js_cocos2dx_ui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2321,7 +2317,6 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { JS_FN("dispatchFocusEvent", js_cocos2dx_ui_Widget_dispatchFocusEvent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUnifySizeEnabled", js_cocos2dx_ui_Widget_setUnifySizeEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPropagateTouchEvents", js_cocos2dx_ui_Widget_isPropagateTouchEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCurrentFocusedWidget", js_cocos2dx_ui_Widget_getCurrentFocusedWidget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hitTest", js_cocos2dx_ui_Widget_hitTest, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isLayoutComponentEnabled", js_cocos2dx_ui_Widget_isLayoutComponentEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestFocus", js_cocos2dx_ui_Widget_requestFocus, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2348,6 +2343,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec st_funcs[] = { JS_FN("enableDpadNavigation", js_cocos2dx_ui_Widget_enableDpadNavigation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentFocusedWidget", js_cocos2dx_ui_Widget_getCurrentFocusedWidget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("create", js_cocos2dx_ui_Widget_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -8795,10 +8791,10 @@ bool js_cocos2dx_ui_ListView_jumpToItem(JSContext *cx, uint32_t argc, jsval *vp) cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_jumpToItem : Invalid Native Object"); if (argc == 3) { - int arg0 = 0; + ssize_t arg0 = 0; cocos2d::Vec2 arg1; cocos2d::Vec2 arg2; - ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_ssize(cx, args.get(0), &arg0); ok &= jsval_to_vector2(cx, args.get(1), &arg1); ok &= jsval_to_vector2(cx, args.get(2), &arg2); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_jumpToItem : Error processing arguments"); @@ -9153,8 +9149,8 @@ bool js_cocos2dx_ui_ListView_scrollToItem(JSContext *cx, uint32_t argc, jsval *v JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_scrollToItem : Invalid Native Object"); do { if (argc == 4) { - int arg0 = 0; - ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ssize_t arg0 = 0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); if (!ok) { ok = true; break; } cocos2d::Vec2 arg1; ok &= jsval_to_vector2(cx, args.get(1), &arg1); @@ -9173,8 +9169,8 @@ bool js_cocos2dx_ui_ListView_scrollToItem(JSContext *cx, uint32_t argc, jsval *v do { if (argc == 3) { - int arg0 = 0; - ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ssize_t arg0 = 0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); if (!ok) { ok = true; break; } cocos2d::Vec2 arg1; ok &= jsval_to_vector2(cx, args.get(1), &arg1); @@ -12143,198 +12139,118 @@ void js_register_cocos2dx_ui_TextBMFont(JSContext *cx, JS::HandleObject global) JSClass *jsb_cocos2d_ui_PageView_class; JSObject *jsb_cocos2d_ui_PageView_prototype; -bool js_cocos2dx_ui_PageView_getCustomScrollThreshold(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getCustomScrollThreshold : Invalid Native Object"); - if (argc == 0) { - double ret = cobj->getCustomScrollThreshold(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_getCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_PageView_getCurPageIndex(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getCurPageIndex : Invalid Native Object"); - if (argc == 0) { - ssize_t ret = cobj->getCurPageIndex(); - jsval jsret = JSVAL_NULL; - jsret = ssize_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_getCurPageIndex : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_PageView_setDirection(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setDirection : Invalid Native Object"); - if (argc == 1) { - cocos2d::ui::PageView::Direction arg0; - ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setDirection : Error processing arguments"); - cobj->setDirection(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_ui_PageView_addWidgetToPage(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_addWidgetToPage : Invalid Native Object"); - if (argc == 3) { - cocos2d::ui::Widget* arg0 = nullptr; - ssize_t arg1 = 0; - bool arg2; - 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::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - ok &= jsval_to_ssize(cx, args.get(1), &arg1); - arg2 = JS::ToBoolean(args.get(2)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_addWidgetToPage : Error processing arguments"); - cobj->addWidgetToPage(arg0, arg1, arg2); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_addWidgetToPage : wrong number of arguments: %d, was expecting %d", argc, 3); - return false; -} -bool js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isUsingCustomScrollThreshold(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_PageView_setCurPageIndex(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setCurPageIndex : Invalid Native Object"); - if (argc == 1) { - ssize_t arg0 = 0; - ok &= jsval_to_ssize(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setCurPageIndex : Error processing arguments"); - cobj->setCurPageIndex(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_setCurPageIndex : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_ui_PageView_removePage(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_removePage : Invalid Native Object"); - if (argc == 1) { - cocos2d::ui::Layout* arg0 = nullptr; - 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::ui::Layout*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_removePage : Error processing arguments"); - cobj->removePage(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_removePage : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold : Error processing arguments"); - cobj->setUsingCustomScrollThreshold(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_ui_PageView_setCustomScrollThreshold(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setCustomScrollThreshold : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes : Invalid Native Object"); if (argc == 1) { double arg0 = 0; ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setCustomScrollThreshold : Error processing arguments"); - cobj->setCustomScrollThreshold(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes : Error processing arguments"); + cobj->setIndicatorSpaceBetweenIndexNodes(arg0); args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_PageView_setCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor : Error processing arguments"); + cobj->setIndicatorSelectedIndexColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getIndicatorSelectedIndexColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getIndicatorPositionAsAnchorPoint(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_setIndicatorPosition(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setIndicatorPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setIndicatorPosition : Error processing arguments"); + cobj->setIndicatorPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setIndicatorPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_getIndicatorPosition(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getIndicatorPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getIndicatorPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getIndicatorPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) @@ -12346,7 +12262,7 @@ bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_insertPage : Invalid Native Object"); if (argc == 2) { - cocos2d::ui::Layout* arg0 = nullptr; + cocos2d::ui::Widget* arg0 = nullptr; int arg1 = 0; do { if (args.get(0).isNull()) { arg0 = nullptr; break; } @@ -12354,7 +12270,7 @@ bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) js_proxy_t *jsProxy; JSObject *tmpObj = args.get(0).toObjectOrNull(); jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::ui::Layout*)(jsProxy ? jsProxy->ptr : NULL); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); @@ -12367,22 +12283,88 @@ bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_PageView_insertPage : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } -bool js_cocos2dx_ui_PageView_getDirection(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_PageView_getCurrentPageIndex(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getDirection : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getCurrentPageIndex : Invalid Native Object"); if (argc == 0) { - int ret = (int)cobj->getDirection(); + ssize_t ret = cobj->getCurrentPageIndex(); jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); + jsret = ssize_to_jsval(cx, ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_PageView_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getCurrentPageIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_removePage(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_removePage : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget* arg0 = nullptr; + 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::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_removePage : Error processing arguments"); + cobj->removePage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_removePage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_setCurrentPageIndex(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setCurrentPageIndex : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0 = 0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setCurrentPageIndex : Error processing arguments"); + cobj->setCurrentPageIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setCurrentPageIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_getIndicatorEnabled(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getIndicatorEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getIndicatorEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getIndicatorEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp) @@ -12405,33 +12387,126 @@ bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *v JS_ReportError(cx, "js_cocos2dx_ui_PageView_scrollToPage : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_PageView_getPage(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getPage : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint : Error processing arguments"); + cobj->setIndicatorPositionAsAnchorPoint(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_scrollToItem(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_scrollToItem : Invalid Native Object"); if (argc == 1) { ssize_t arg0 = 0; ok &= jsval_to_ssize(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_getPage : Error processing arguments"); - cocos2d::ui::Layout* ret = cobj->getPage(arg0); - jsval jsret = JSVAL_NULL; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_scrollToItem : Error processing arguments"); + cobj->scrollToItem(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_scrollToItem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_setIndicatorEnabled(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setIndicatorEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setIndicatorEnabled : Error processing arguments"); + cobj->setIndicatorEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setIndicatorEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_addPage(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_addPage : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget* arg0 = nullptr; do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Layout*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } + 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::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_addPage : Error processing arguments"); + cobj->addPage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_addPage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getIndicatorSpaceBetweenIndexNodes(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_PageView_getPage : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_removeAllPages(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_removeAllPages : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllPages(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_removeAllPages : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_ui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsval *vp) @@ -12454,68 +12529,6 @@ bool js_cocos2dx_ui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsv JS_ReportError(cx, "js_cocos2dx_ui_PageView_removePageAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_PageView_getPages(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getPages : Invalid Native Object"); - if (argc == 0) { - cocos2d::Vector& ret = cobj->getPages(); - jsval jsret = JSVAL_NULL; - jsret = ccvector_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_getPages : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_PageView_removeAllPages(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_removeAllPages : Invalid Native Object"); - if (argc == 0) { - cobj->removeAllPages(); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_removeAllPages : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_PageView_addPage(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_addPage : Invalid Native Object"); - if (argc == 1) { - cocos2d::ui::Layout* arg0 = nullptr; - 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::ui::Layout*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_addPage : Error processing arguments"); - cobj->addPage(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_PageView_addPage : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_ui_PageView_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -12601,7 +12614,7 @@ bool js_cocos2dx_ui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp return true; } -extern JSObject *jsb_cocos2d_ui_Layout_prototype; +extern JSObject *jsb_cocos2d_ui_ListView_prototype; void js_cocos2d_ui_PageView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PageView)", obj); @@ -12626,23 +12639,25 @@ void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { - JS_FN("getCustomScrollThreshold", js_cocos2dx_ui_PageView_getCustomScrollThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCurPageIndex", js_cocos2dx_ui_PageView_getCurPageIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setDirection", js_cocos2dx_ui_PageView_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("addWidgetToPage", js_cocos2dx_ui_PageView_addWidgetToPage, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isUsingCustomScrollThreshold", js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCurPageIndex", js_cocos2dx_ui_PageView_setCurPageIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removePage", js_cocos2dx_ui_PageView_removePage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setUsingCustomScrollThreshold", js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCustomScrollThreshold", js_cocos2dx_ui_PageView_setCustomScrollThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIndicatorSpaceBetweenIndexNodes", js_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIndicatorSelectedIndexColor", js_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndicatorSelectedIndexColor", js_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndicatorPositionAsAnchorPoint", js_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIndicatorPosition", js_cocos2dx_ui_PageView_setIndicatorPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndicatorPosition", js_cocos2dx_ui_PageView_getIndicatorPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertPage", js_cocos2dx_ui_PageView_insertPage, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getDirection", js_cocos2dx_ui_PageView_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentPageIndex", js_cocos2dx_ui_PageView_getCurrentPageIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removePage", js_cocos2dx_ui_PageView_removePage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCurrentPageIndex", js_cocos2dx_ui_PageView_setCurrentPageIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndicatorEnabled", js_cocos2dx_ui_PageView_getIndicatorEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToPage", js_cocos2dx_ui_PageView_scrollToPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getPage", js_cocos2dx_ui_PageView_getPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removePageAtIndex", js_cocos2dx_ui_PageView_removePageAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getPages", js_cocos2dx_ui_PageView_getPages, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeAllPages", js_cocos2dx_ui_PageView_removeAllPages, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIndicatorPositionAsAnchorPoint", js_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToItem", js_cocos2dx_ui_PageView_scrollToItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIndicatorEnabled", js_cocos2dx_ui_PageView_setIndicatorEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addPage", js_cocos2dx_ui_PageView_addPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndicatorSpaceBetweenIndexNodes", js_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllPages", js_cocos2dx_ui_PageView_removeAllPages, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removePageAtIndex", js_cocos2dx_ui_PageView_removePageAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_PageView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12655,7 +12670,7 @@ void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ui_PageView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + JS::RootedObject(cx, jsb_cocos2d_ui_ListView_prototype), jsb_cocos2d_ui_PageView_class, js_cocos2dx_ui_PageView_constructor, 0, // constructor properties, @@ -12676,7 +12691,7 @@ void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ui_PageView_class; p->proto = jsb_cocos2d_ui_PageView_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; + p->parentProto = jsb_cocos2d_ui_ListView_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } anonEvaluate(cx, global, "(function () { ccui.PageView.extend = cc.Class.extend; })()"); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index ec3970e86e..e90d2a5ace 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -102,7 +102,6 @@ bool js_cocos2dx_ui_Widget_isBright(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setUnifySizeEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isPropagateTouchEvents(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isLayoutComponentEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_requestFocus(JSContext *cx, uint32_t argc, jsval *vp); @@ -124,6 +123,7 @@ bool js_cocos2dx_ui_Widget_setBright(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setCallbackType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_enableDpadNavigation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_Widget(JSContext *cx, uint32_t argc, jsval *vp); @@ -607,23 +607,25 @@ bool js_cocos2dx_ui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2dx_ui_PageView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_ui_PageView_getCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_getCurPageIndex(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_setDirection(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_addWidgetToPage(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_setCurPageIndex(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_setCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setIndicatorPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getIndicatorPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_getDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getIndicatorEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_getPage(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_getPages(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_PageView_removeAllPages(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_scrollToItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setIndicatorEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_addPage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_removeAllPages(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_createInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_PageView(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/ListView.lua b/cocos/scripting/lua-bindings/auto/api/ListView.lua index 9710529b45..46a57edddc 100644 --- a/cocos/scripting/lua-bindings/auto/api/ListView.lua +++ b/cocos/scripting/lua-bindings/auto/api/ListView.lua @@ -46,7 +46,7 @@ -- param itemAnchorPoint Specifies an anchor point of each item for position to calculate distance. -- @function [parent=#ListView] jumpToItem -- @param self --- @param #int itemIndex +-- @param #long itemIndex -- @param #vec2_table positionRatioInView -- @param #vec2_table itemAnchorPoint -- @return ListView#ListView self (return value: ccui.ListView) @@ -171,11 +171,11 @@ -- @return ListView#ListView self (return value: ccui.ListView) -------------------------------- --- @overload self, int, vec2_table, vec2_table, float --- @overload self, int, vec2_table, vec2_table +-- @overload self, long, vec2_table, vec2_table, float +-- @overload self, long, vec2_table, vec2_table -- @function [parent=#ListView] scrollToItem -- @param self --- @param #int itemIndex +-- @param #long itemIndex -- @param #vec2_table positionRatioInView -- @param #vec2_table itemAnchorPoint -- @param #float timeInSec diff --git a/cocos/scripting/lua-bindings/auto/api/PageView.lua b/cocos/scripting/lua-bindings/auto/api/PageView.lua index 496a94045b..f323541202 100644 --- a/cocos/scripting/lua-bindings/auto/api/PageView.lua +++ b/cocos/scripting/lua-bindings/auto/api/PageView.lua @@ -1,67 +1,77 @@ -------------------------------- -- @module PageView --- @extend Layout +-- @extend ListView -- @parent_module ccui -------------------------------- --- brief Query the custom scroll threshold of the PageView.
--- return Custom scroll threshold in float. --- @function [parent=#PageView] getCustomScrollThreshold +-- brief Set space between page indicator's index nodes.
+-- param spaceBetweenIndexNodes Space between nodes in pixel. +-- @function [parent=#PageView] setIndicatorSpaceBetweenIndexNodes -- @param self --- @return float#float ret (return value: float) +-- @param #float spaceBetweenIndexNodes +-- @return PageView#PageView self (return value: ccui.PageView) + +-------------------------------- +-- brief Set color of page indicator's selected index.
+-- param spaceBetweenIndexNodes Space between nodes in pixel. +-- @function [parent=#PageView] setIndicatorSelectedIndexColor +-- @param self +-- @param #color3b_table color +-- @return PageView#PageView self (return value: ccui.PageView) + +-------------------------------- +-- brief Get the color of page indicator's selected index.
+-- return color +-- @function [parent=#PageView] getIndicatorSelectedIndexColor +-- @param self +-- @return color3b_table#color3b_table ret (return value: color3b_table) + +-------------------------------- +-- brief Get the page indicator's position as anchor point.
+-- return positionAsAnchorPoint +-- @function [parent=#PageView] getIndicatorPositionAsAnchorPoint +-- @param self +-- @return vec2_table#vec2_table ret (return value: vec2_table) + +-------------------------------- +-- brief Set the page indicator's position in page view.
+-- param position The position in page view +-- @function [parent=#PageView] setIndicatorPosition +-- @param self +-- @param #vec2_table position +-- @return PageView#PageView self (return value: ccui.PageView) + +-------------------------------- +-- brief Get the page indicator's position.
+-- return positionAsAnchorPoint +-- @function [parent=#PageView] getIndicatorPosition +-- @param self +-- @return vec2_table#vec2_table ret (return value: vec2_table) + +-------------------------------- +-- Insert a page into PageView at a given index.
+-- param page Page to be inserted.
+-- param idx A given index. +-- @function [parent=#PageView] insertPage +-- @param self +-- @param #ccui.Widget page +-- @param #int idx +-- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- -- Gets current displayed page index.
-- return current page index. --- @function [parent=#PageView] getCurPageIndex +-- @function [parent=#PageView] getCurrentPageIndex -- @param self -- @return long#long ret (return value: long) --------------------------------- --- Changes scroll direction of PageView
--- see `Direction`
--- param direction Scroll direction enum.
--- since v3.8 --- @function [parent=#PageView] setDirection --- @param self --- @param #int direction --- @return PageView#PageView self (return value: ccui.PageView) - --------------------------------- --- Add a widget as a page of PageView in a given index.
--- param widget Widget to be added to pageview.
--- param pageIdx A given index.
--- param forceCreate If `forceCreate` is true and `widget` isn't exists, pageview would create a default page and add it. --- @function [parent=#PageView] addWidgetToPage --- @param self --- @param #ccui.Widget widget --- @param #long pageIdx --- @param #bool forceCreate --- @return PageView#PageView self (return value: ccui.PageView) - --------------------------------- --- brief Query whether use user defined scroll page threshold or not.
--- return True if using custom scroll threshold, false otherwise. --- @function [parent=#PageView] isUsingCustomScrollThreshold --- @param self --- @return bool#bool ret (return value: bool) - --------------------------------- --- Jump to a page with a given index without scrolling.
--- This is the different between scrollToPage.
--- param index A given index in PageView. Index start from 0 to pageCount -1. --- @function [parent=#PageView] setCurPageIndex --- @param self --- @param #long index --- @return PageView#PageView self (return value: ccui.PageView) - -------------------------------- -- Remove a page of PageView.
-- param page Page to be removed. -- @function [parent=#PageView] removePage -- @param self --- @param #ccui.Layout page +-- @param #ccui.Widget page -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- @@ -73,40 +83,20 @@ -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- --- brief Set using user defined scroll page threshold or not.
--- If you set it to false, then the default scroll threshold is pageView.width / 2
--- param flag True if using custom scroll threshold, false otherwise. --- @function [parent=#PageView] setUsingCustomScrollThreshold +-- Jump to a page with a given index without scrolling.
+-- This is the different between scrollToPage.
+-- param index A given index in PageView. Index start from 0 to pageCount -1. +-- @function [parent=#PageView] setCurrentPageIndex -- @param self --- @param #bool flag +-- @param #long index -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- --- brief If you don't specify the value, the pageView will turn page when scrolling at the half width of a page.
--- param threshold A threshold in float. --- @function [parent=#PageView] setCustomScrollThreshold +-- brief Query page indicator state.
+-- return True if page indicator is enabled, false otherwise. +-- @function [parent=#PageView] getIndicatorEnabled -- @param self --- @param #float threshold --- @return PageView#PageView self (return value: ccui.PageView) - --------------------------------- --- Insert a page into PageView at a given index.
--- param page Page to be inserted.
--- param idx A given index. --- @function [parent=#PageView] insertPage --- @param self --- @param #ccui.Layout page --- @param #int idx --- @return PageView#PageView self (return value: ccui.PageView) - --------------------------------- --- Query scroll direction of PageView.
--- see `Direction`
--- since v3.8
--- return PageView scroll direction. --- @function [parent=#PageView] getDirection --- @param self --- @return int#int ret (return value: int) +-- @return bool#bool ret (return value: bool) -------------------------------- -- Scroll to a page with a given index.
@@ -117,28 +107,43 @@ -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- --- brief Get a page at a given index
--- param index A given index.
--- return A layout pointer in PageView container. --- @function [parent=#PageView] getPage +-- brief Set the page indicator's position using anchor point.
+-- param positionAsAnchorPoint The position as anchor point. +-- @function [parent=#PageView] setIndicatorPositionAsAnchorPoint -- @param self --- @param #long index --- @return Layout#Layout ret (return value: ccui.Layout) - --------------------------------- --- Remove a page at a given index of PageView.
--- param index A given index. --- @function [parent=#PageView] removePageAtIndex --- @param self --- @param #long index +-- @param #vec2_table positionAsAnchorPoint -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- --- brief Get all the pages in the PageView.
--- return A vector of Layout pointers. --- @function [parent=#PageView] getPages +-- Scroll to a page with a given index.
+-- param idx A given index in the PageView. Index start from 0 to pageCount -1. +-- @function [parent=#PageView] scrollToItem -- @param self --- @return array_table#array_table ret (return value: array_table) +-- @param #long itemIndex +-- @return PageView#PageView self (return value: ccui.PageView) + +-------------------------------- +-- brief Toggle page indicator enabled.
+-- param enabled True if enable page indicator, false otherwise. +-- @function [parent=#PageView] setIndicatorEnabled +-- @param self +-- @param #bool enabled +-- @return PageView#PageView self (return value: ccui.PageView) + +-------------------------------- +-- Insert a page into the end of PageView.
+-- param page Page to be inserted. +-- @function [parent=#PageView] addPage +-- @param self +-- @param #ccui.Widget page +-- @return PageView#PageView self (return value: ccui.PageView) + +-------------------------------- +-- brief Get the space between page indicator's index nodes.
+-- return spaceBetweenIndexNodes +-- @function [parent=#PageView] getIndicatorSpaceBetweenIndexNodes +-- @param self +-- @return float#float ret (return value: float) -------------------------------- -- brief Remove all pages of the PageView. @@ -147,11 +152,11 @@ -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- --- Insert a page into the end of PageView.
--- param page Page to be inserted. --- @function [parent=#PageView] addPage +-- Remove a page at a given index of PageView.
+-- param index A given index. +-- @function [parent=#PageView] removePageAtIndex -- @param self --- @param #ccui.Layout page +-- @param #long index -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- @@ -169,21 +174,8 @@ -------------------------------- -- --- @function [parent=#PageView] getLayoutType +-- @function [parent=#PageView] doLayout -- @param self --- @return int#int ret (return value: int) - --------------------------------- --- --- @function [parent=#PageView] getDescription --- @param self --- @return string#string ret (return value: string) - --------------------------------- --- --- @function [parent=#PageView] update --- @param self --- @param #float dt -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- @@ -194,9 +186,17 @@ -------------------------------- -- --- @function [parent=#PageView] setLayoutType +-- @function [parent=#PageView] getDescription -- @param self --- @param #int type +-- @return string#string ret (return value: string) + +-------------------------------- +-- Changes direction
+-- Direction Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll.
+-- param direction Set the page view's scroll direction. +-- @function [parent=#PageView] setDirection +-- @param self +-- @param #int direction -- @return PageView#PageView self (return value: ccui.PageView) -------------------------------- diff --git a/cocos/scripting/lua-bindings/auto/api/Widget.lua b/cocos/scripting/lua-bindings/auto/api/Widget.lua index 0a035ad5bd..e4cdc1ea47 100644 --- a/cocos/scripting/lua-bindings/auto/api/Widget.lua +++ b/cocos/scripting/lua-bindings/auto/api/Widget.lua @@ -376,13 +376,6 @@ -- @param self -- @return bool#bool ret (return value: bool) --------------------------------- --- Return a current focused widget in your UI scene.
--- No matter what widget object you call this method on , it will return you the exact one focused widget. --- @function [parent=#Widget] getCurrentFocusedWidget --- @param self --- @return Widget#Widget ret (return value: ccui.Widget) - -------------------------------- -- Checks a point is in widget's content space.
-- This function is used for determining touch area of widget.
@@ -551,6 +544,13 @@ -- @param #bool enable -- @return Widget#Widget self (return value: ccui.Widget) +-------------------------------- +-- Return a current focused widget in your UI scene.
+-- No matter what widget object you call this method on , it will return you the exact one focused widget. +-- @function [parent=#Widget] getCurrentFocusedWidget +-- @param self +-- @return Widget#Widget ret (return value: ccui.Widget) + -------------------------------- -- Create and return a empty Widget instance pointer. -- @function [parent=#Widget] create diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 1b3ab7b6f0..d6b2cf6c60 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -3102,53 +3102,6 @@ int lua_cocos2dx_ui_Widget_isPropagateTouchEvents(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_getCurrentFocusedWidget(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Widget* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'", nullptr); - return 0; - } - cocos2d::ui::Widget* ret = cobj->getCurrentFocusedWidget(); - object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Widget:getCurrentFocusedWidget",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Widget_hitTest(lua_State* tolua_S) { int argc = 0; @@ -4127,6 +4080,40 @@ int lua_cocos2dx_ui_Widget_enableDpadNavigation(lua_State* tolua_S) #endif return 0; } +int lua_cocos2dx_ui_Widget_getCurrentFocusedWidget(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'", nullptr); + return 0; + } + cocos2d::ui::Widget* ret = cocos2d::ui::Widget::getCurrentFocusedWidget(); + object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.Widget:getCurrentFocusedWidget",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getCurrentFocusedWidget'.",&tolua_err); +#endif + return 0; +} int lua_cocos2dx_ui_Widget_create(lua_State* tolua_S) { int argc = 0; @@ -4257,7 +4244,6 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S) tolua_function(tolua_S,"dispatchFocusEvent",lua_cocos2dx_ui_Widget_dispatchFocusEvent); tolua_function(tolua_S,"setUnifySizeEnabled",lua_cocos2dx_ui_Widget_setUnifySizeEnabled); tolua_function(tolua_S,"isPropagateTouchEvents",lua_cocos2dx_ui_Widget_isPropagateTouchEvents); - tolua_function(tolua_S,"getCurrentFocusedWidget",lua_cocos2dx_ui_Widget_getCurrentFocusedWidget); tolua_function(tolua_S,"hitTest",lua_cocos2dx_ui_Widget_hitTest); tolua_function(tolua_S,"isLayoutComponentEnabled",lua_cocos2dx_ui_Widget_isLayoutComponentEnabled); tolua_function(tolua_S,"requestFocus",lua_cocos2dx_ui_Widget_requestFocus); @@ -4278,6 +4264,7 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S) tolua_function(tolua_S,"setCallbackType",lua_cocos2dx_ui_Widget_setCallbackType); tolua_function(tolua_S,"isSwallowTouches",lua_cocos2dx_ui_Widget_isSwallowTouches); tolua_function(tolua_S,"enableDpadNavigation", lua_cocos2dx_ui_Widget_enableDpadNavigation); + tolua_function(tolua_S,"getCurrentFocusedWidget", lua_cocos2dx_ui_Widget_getCurrentFocusedWidget); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Widget_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::Widget).name(); @@ -16118,11 +16105,11 @@ int lua_cocos2dx_ui_ListView_jumpToItem(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 3) { - int arg0; + ssize_t arg0; cocos2d::Vec2 arg1; cocos2d::Vec2 arg2; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.ListView:jumpToItem"); + ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.ListView:jumpToItem"); ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ccui.ListView:jumpToItem"); @@ -16952,8 +16939,8 @@ int lua_cocos2dx_ui_ListView_scrollToItem(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; do{ if (argc == 4) { - int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.ListView:scrollToItem"); + ssize_t arg0; + ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.ListView:scrollToItem"); if (!ok) { break; } cocos2d::Vec2 arg1; @@ -16976,8 +16963,8 @@ int lua_cocos2dx_ui_ListView_scrollToItem(lua_State* tolua_S) ok = true; do{ if (argc == 3) { - int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.ListView:scrollToItem"); + ssize_t arg0; + ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.ListView:scrollToItem"); if (!ok) { break; } cocos2d::Vec2 arg1; @@ -21342,7 +21329,7 @@ int lua_register_cocos2dx_ui_TextBMFont(lua_State* tolua_S) return 1; } -int lua_cocos2dx_ui_PageView_getCustomScrollThreshold(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -21362,101 +21349,7 @@ int lua_cocos2dx_ui_PageView_getCustomScrollThreshold(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getCustomScrollThreshold'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getCustomScrollThreshold'", nullptr); - return 0; - } - double ret = cobj->getCustomScrollThreshold(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getCustomScrollThreshold",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getCustomScrollThreshold'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_PageView_getCurPageIndex(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::PageView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getCurPageIndex'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getCurPageIndex'", nullptr); - return 0; - } - ssize_t ret = cobj->getCurPageIndex(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getCurPageIndex",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getCurPageIndex'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_PageView_setDirection(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::PageView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setDirection'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes'", nullptr); return 0; } #endif @@ -21464,29 +21357,29 @@ int lua_cocos2dx_ui_PageView_setDirection(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::ui::PageView::Direction arg0; + double arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.PageView:setDirection"); + ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.PageView:setIndicatorSpaceBetweenIndexNodes"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setDirection'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes'", nullptr); return 0; } - cobj->setDirection(arg0); + cobj->setIndicatorSpaceBetweenIndexNodes(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setDirection",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setIndicatorSpaceBetweenIndexNodes",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setDirection'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_ui_PageView_addWidgetToPage(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -21506,43 +21399,281 @@ int lua_cocos2dx_ui_PageView_addWidgetToPage(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_addWidgetToPage'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 3) + if (argc == 1) + { + cocos2d::Color3B arg0; + + ok &= luaval_to_color3b(tolua_S, 2, &arg0, "ccui.PageView:setIndicatorSelectedIndexColor"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor'", nullptr); + return 0; + } + cobj->setIndicatorSelectedIndexColor(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setIndicatorSelectedIndexColor",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor'", nullptr); + return 0; + } + const cocos2d::Color3B& ret = cobj->getIndicatorSelectedIndexColor(); + color3b_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getIndicatorSelectedIndexColor",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint'", nullptr); + return 0; + } + const cocos2d::Vec2& ret = cobj->getIndicatorPositionAsAnchorPoint(); + vec2_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getIndicatorPositionAsAnchorPoint",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_setIndicatorPosition(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setIndicatorPosition'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccui.PageView:setIndicatorPosition"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setIndicatorPosition'", nullptr); + return 0; + } + cobj->setIndicatorPosition(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setIndicatorPosition",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setIndicatorPosition'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_getIndicatorPosition(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getIndicatorPosition'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getIndicatorPosition'", nullptr); + return 0; + } + const cocos2d::Vec2& ret = cobj->getIndicatorPosition(); + vec2_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getIndicatorPosition",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getIndicatorPosition'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_insertPage(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_insertPage'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) { cocos2d::ui::Widget* arg0; - ssize_t arg1; - bool arg2; + int arg1; - ok &= luaval_to_object(tolua_S, 2, "ccui.Widget",&arg0, "ccui.PageView:addWidgetToPage"); + ok &= luaval_to_object(tolua_S, 2, "ccui.Widget",&arg0, "ccui.PageView:insertPage"); - ok &= luaval_to_ssize(tolua_S, 3, &arg1, "ccui.PageView:addWidgetToPage"); - - ok &= luaval_to_boolean(tolua_S, 4,&arg2, "ccui.PageView:addWidgetToPage"); + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.PageView:insertPage"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_addWidgetToPage'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_insertPage'", nullptr); return 0; } - cobj->addWidgetToPage(arg0, arg1, arg2); + cobj->insertPage(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:addWidgetToPage",argc, 3); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:insertPage",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_addWidgetToPage'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_insertPage'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_getCurrentPageIndex(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -21562,7 +21693,7 @@ int lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getCurrentPageIndex'", nullptr); return 0; } #endif @@ -21572,69 +21703,19 @@ int lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getCurrentPageIndex'", nullptr); return 0; } - bool ret = cobj->isUsingCustomScrollThreshold(); - tolua_pushboolean(tolua_S,(bool)ret); + ssize_t ret = cobj->getCurrentPageIndex(); + tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:isUsingCustomScrollThreshold",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getCurrentPageIndex",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_PageView_setCurPageIndex(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::PageView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setCurPageIndex'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - ssize_t arg0; - - ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.PageView:setCurPageIndex"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setCurPageIndex'", nullptr); - return 0; - } - cobj->setCurPageIndex(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setCurPageIndex",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setCurPageIndex'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getCurrentPageIndex'.",&tolua_err); #endif return 0; @@ -21667,9 +21748,9 @@ int lua_cocos2dx_ui_PageView_removePage(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::ui::Layout* arg0; + cocos2d::ui::Widget* arg0; - ok &= luaval_to_object(tolua_S, 2, "ccui.Layout",&arg0, "ccui.PageView:removePage"); + ok &= luaval_to_object(tolua_S, 2, "ccui.Widget",&arg0, "ccui.PageView:removePage"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_removePage'", nullptr); @@ -21743,7 +21824,7 @@ int lua_cocos2dx_ui_PageView_addEventListener(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_setCurrentPageIndex(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -21763,7 +21844,7 @@ int lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setCurrentPageIndex'", nullptr); return 0; } #endif @@ -21771,29 +21852,29 @@ int lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - bool arg0; + ssize_t arg0; - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.PageView:setUsingCustomScrollThreshold"); + ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.PageView:setCurrentPageIndex"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setCurrentPageIndex'", nullptr); return 0; } - cobj->setUsingCustomScrollThreshold(arg0); + cobj->setCurrentPageIndex(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setUsingCustomScrollThreshold",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setCurrentPageIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setCurrentPageIndex'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_ui_PageView_setCustomScrollThreshold(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_getIndicatorEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -21813,110 +21894,7 @@ int lua_cocos2dx_ui_PageView_setCustomScrollThreshold(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setCustomScrollThreshold'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.PageView:setCustomScrollThreshold"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setCustomScrollThreshold'", nullptr); - return 0; - } - cobj->setCustomScrollThreshold(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setCustomScrollThreshold",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setCustomScrollThreshold'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_PageView_insertPage(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::PageView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_insertPage'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - cocos2d::ui::Layout* arg0; - int arg1; - - ok &= luaval_to_object(tolua_S, 2, "ccui.Layout",&arg0, "ccui.PageView:insertPage"); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.PageView:insertPage"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_insertPage'", nullptr); - return 0; - } - cobj->insertPage(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:insertPage",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_insertPage'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_PageView_getDirection(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::PageView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getDirection'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getIndicatorEnabled'", nullptr); return 0; } #endif @@ -21926,19 +21904,19 @@ int lua_cocos2dx_ui_PageView_getDirection(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getDirection'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getIndicatorEnabled'", nullptr); return 0; } - int ret = (int)cobj->getDirection(); - tolua_pushnumber(tolua_S,(lua_Number)ret); + bool ret = cobj->getIndicatorEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getDirection",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getIndicatorEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getDirection'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getIndicatorEnabled'.",&tolua_err); #endif return 0; @@ -21993,7 +21971,7 @@ int lua_cocos2dx_ui_PageView_scrollToPage(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_PageView_getPage(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -22013,7 +21991,7 @@ int lua_cocos2dx_ui_PageView_getPage(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getPage'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint'", nullptr); return 0; } #endif @@ -22021,79 +21999,29 @@ int lua_cocos2dx_ui_PageView_getPage(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - ssize_t arg0; + cocos2d::Vec2 arg0; - ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.PageView:getPage"); + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ccui.PageView:setIndicatorPositionAsAnchorPoint"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getPage'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint'", nullptr); return 0; } - cocos2d::ui::Layout* ret = cobj->getPage(arg0); - object_to_luaval(tolua_S, "ccui.Layout",(cocos2d::ui::Layout*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getPage",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getPage'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_PageView_removePageAtIndex(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::PageView* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_removePageAtIndex'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - ssize_t arg0; - - ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.PageView:removePageAtIndex"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_removePageAtIndex'", nullptr); - return 0; - } - cobj->removePageAtIndex(arg0); + cobj->setIndicatorPositionAsAnchorPoint(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:removePageAtIndex",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setIndicatorPositionAsAnchorPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_removePageAtIndex'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_ui_PageView_getPages(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_scrollToItem(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -22113,7 +22041,157 @@ int lua_cocos2dx_ui_PageView_getPages(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getPages'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_scrollToItem'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + ssize_t arg0; + + ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.PageView:scrollToItem"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_scrollToItem'", nullptr); + return 0; + } + cobj->scrollToItem(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:scrollToItem",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_scrollToItem'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_setIndicatorEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setIndicatorEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.PageView:setIndicatorEnabled"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_setIndicatorEnabled'", nullptr); + return 0; + } + cobj->setIndicatorEnabled(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setIndicatorEnabled",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setIndicatorEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_addPage(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_addPage'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ui::Widget* arg0; + + ok &= luaval_to_object(tolua_S, 2, "ccui.Widget",&arg0, "ccui.PageView:addPage"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_addPage'", nullptr); + return 0; + } + cobj->addPage(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:addPage",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_addPage'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes'", nullptr); return 0; } #endif @@ -22123,19 +22201,19 @@ int lua_cocos2dx_ui_PageView_getPages(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getPages'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes'", nullptr); return 0; } - cocos2d::Vector& ret = cobj->getPages(); - ccvector_to_luaval(tolua_S, ret); + double ret = cobj->getIndicatorSpaceBetweenIndexNodes(); + tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getPages",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getIndicatorSpaceBetweenIndexNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getPages'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes'.",&tolua_err); #endif return 0; @@ -22187,7 +22265,7 @@ int lua_cocos2dx_ui_PageView_removeAllPages(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_PageView_addPage(lua_State* tolua_S) +int lua_cocos2dx_ui_PageView_removePageAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::ui::PageView* cobj = nullptr; @@ -22207,7 +22285,7 @@ int lua_cocos2dx_ui_PageView_addPage(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_addPage'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_removePageAtIndex'", nullptr); return 0; } #endif @@ -22215,24 +22293,24 @@ int lua_cocos2dx_ui_PageView_addPage(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::ui::Layout* arg0; + ssize_t arg0; - ok &= luaval_to_object(tolua_S, 2, "ccui.Layout",&arg0, "ccui.PageView:addPage"); + ok &= luaval_to_ssize(tolua_S, 2, &arg0, "ccui.PageView:removePageAtIndex"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_addPage'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_PageView_removePageAtIndex'", nullptr); return 0; } - cobj->addPage(arg0); + cobj->removePageAtIndex(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:addPage",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:removePageAtIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_addPage'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_removePageAtIndex'.",&tolua_err); #endif return 0; @@ -22351,28 +22429,30 @@ static int lua_cocos2dx_ui_PageView_finalize(lua_State* tolua_S) int lua_register_cocos2dx_ui_PageView(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.PageView"); - tolua_cclass(tolua_S,"PageView","ccui.PageView","ccui.Layout",nullptr); + tolua_cclass(tolua_S,"PageView","ccui.PageView","ccui.ListView",nullptr); tolua_beginmodule(tolua_S,"PageView"); tolua_function(tolua_S,"new",lua_cocos2dx_ui_PageView_constructor); - tolua_function(tolua_S,"getCustomScrollThreshold",lua_cocos2dx_ui_PageView_getCustomScrollThreshold); - tolua_function(tolua_S,"getCurPageIndex",lua_cocos2dx_ui_PageView_getCurPageIndex); - tolua_function(tolua_S,"setDirection",lua_cocos2dx_ui_PageView_setDirection); - tolua_function(tolua_S,"addWidgetToPage",lua_cocos2dx_ui_PageView_addWidgetToPage); - tolua_function(tolua_S,"isUsingCustomScrollThreshold",lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold); - tolua_function(tolua_S,"setCurPageIndex",lua_cocos2dx_ui_PageView_setCurPageIndex); + tolua_function(tolua_S,"setIndicatorSpaceBetweenIndexNodes",lua_cocos2dx_ui_PageView_setIndicatorSpaceBetweenIndexNodes); + tolua_function(tolua_S,"setIndicatorSelectedIndexColor",lua_cocos2dx_ui_PageView_setIndicatorSelectedIndexColor); + tolua_function(tolua_S,"getIndicatorSelectedIndexColor",lua_cocos2dx_ui_PageView_getIndicatorSelectedIndexColor); + tolua_function(tolua_S,"getIndicatorPositionAsAnchorPoint",lua_cocos2dx_ui_PageView_getIndicatorPositionAsAnchorPoint); + tolua_function(tolua_S,"setIndicatorPosition",lua_cocos2dx_ui_PageView_setIndicatorPosition); + tolua_function(tolua_S,"getIndicatorPosition",lua_cocos2dx_ui_PageView_getIndicatorPosition); + tolua_function(tolua_S,"insertPage",lua_cocos2dx_ui_PageView_insertPage); + tolua_function(tolua_S,"getCurrentPageIndex",lua_cocos2dx_ui_PageView_getCurrentPageIndex); tolua_function(tolua_S,"removePage",lua_cocos2dx_ui_PageView_removePage); tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_PageView_addEventListener); - tolua_function(tolua_S,"setUsingCustomScrollThreshold",lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold); - tolua_function(tolua_S,"setCustomScrollThreshold",lua_cocos2dx_ui_PageView_setCustomScrollThreshold); - tolua_function(tolua_S,"insertPage",lua_cocos2dx_ui_PageView_insertPage); - tolua_function(tolua_S,"getDirection",lua_cocos2dx_ui_PageView_getDirection); + tolua_function(tolua_S,"setCurrentPageIndex",lua_cocos2dx_ui_PageView_setCurrentPageIndex); + tolua_function(tolua_S,"getIndicatorEnabled",lua_cocos2dx_ui_PageView_getIndicatorEnabled); tolua_function(tolua_S,"scrollToPage",lua_cocos2dx_ui_PageView_scrollToPage); - tolua_function(tolua_S,"getPage",lua_cocos2dx_ui_PageView_getPage); - tolua_function(tolua_S,"removePageAtIndex",lua_cocos2dx_ui_PageView_removePageAtIndex); - tolua_function(tolua_S,"getPages",lua_cocos2dx_ui_PageView_getPages); - tolua_function(tolua_S,"removeAllPages",lua_cocos2dx_ui_PageView_removeAllPages); + tolua_function(tolua_S,"setIndicatorPositionAsAnchorPoint",lua_cocos2dx_ui_PageView_setIndicatorPositionAsAnchorPoint); + tolua_function(tolua_S,"scrollToItem",lua_cocos2dx_ui_PageView_scrollToItem); + tolua_function(tolua_S,"setIndicatorEnabled",lua_cocos2dx_ui_PageView_setIndicatorEnabled); tolua_function(tolua_S,"addPage",lua_cocos2dx_ui_PageView_addPage); + tolua_function(tolua_S,"getIndicatorSpaceBetweenIndexNodes",lua_cocos2dx_ui_PageView_getIndicatorSpaceBetweenIndexNodes); + tolua_function(tolua_S,"removeAllPages",lua_cocos2dx_ui_PageView_removeAllPages); + tolua_function(tolua_S,"removePageAtIndex",lua_cocos2dx_ui_PageView_removePageAtIndex); tolua_function(tolua_S,"create", lua_cocos2dx_ui_PageView_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_PageView_createInstance); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 15e87279e6..0730c1684c 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -628,6 +628,8 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + From 42fa33dc6ebe729b6b19c4c372fce06e4772ffd4 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 17 Nov 2015 23:44:52 +0800 Subject: [PATCH 083/192] AudioEngine[WIN32]:Fixed `FinishCallback` may not been invoked when the sound play completes. --- cocos/audio/win32/AudioEngine-win32.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos/audio/win32/AudioEngine-win32.cpp b/cocos/audio/win32/AudioEngine-win32.cpp index 8eb83c11bc..ad0e851bc3 100644 --- a/cocos/audio/win32/AudioEngine-win32.cpp +++ b/cocos/audio/win32/AudioEngine-win32.cpp @@ -322,6 +322,7 @@ bool AudioEngineImpl::stop(int audioID) _alSourceUsed[player._alSource] = false; if (player._streamingSource) { + player._ready = false; player.notifyExitThread(); } else @@ -346,6 +347,7 @@ void AudioEngineImpl::stopAll() auto& player = it->second; if (player._streamingSource) { + player._ready = false; player.notifyExitThread(); ++it; } @@ -457,7 +459,7 @@ void AudioEngineImpl::update(float dt) auto& player = it->second; alGetSourcei(player._alSource, AL_SOURCE_STATE, &sourceState); - if (player._readForRemove) + if (player._readForRemove && !player._ready) { it = _audioPlayers.erase(it); } @@ -472,6 +474,7 @@ void AudioEngineImpl::update(float dt) if (player._streamingSource) { + player._ready = false; player.notifyExitThread(); ++it; } From 2d9764717715de229b9e3b1b4d3c36d94cf40cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=B3=B0?= Date: Wed, 18 Nov 2015 10:55:10 +0800 Subject: [PATCH 084/192] update framework number --- cocos/cocos2d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 282321f4fb..1f3a539d2c 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -30,7 +30,7 @@ THE SOFTWARE. // 0x00 HI ME LO // 00 03 08 00 -#define COCOS2D_VERSION 0x00030800 +#define COCOS2D_VERSION 0x00030900 // // all cocos2d include files From bb83fe45963a047ddf4a443744a48cd568370b78 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 18 Nov 2015 13:38:29 +0800 Subject: [PATCH 085/192] Combine Studio change for UI components --- cocos/2d/libcocos2d.vcxproj | 1 + cocos/2d/libcocos2d.vcxproj.filters | 3 + cocos/cocos2d.h | 2 +- cocos/ui/GUIExport.h | 2 + cocos/ui/UIAbstractCheckButton.cpp | 74 ++++++++++++++++++++-- cocos/ui/UIAbstractCheckButton.h | 15 ++++- cocos/ui/UIButton.cpp | 90 ++++++++++++++++++++++++++- cocos/ui/UIButton.h | 17 +++++ cocos/ui/UIImageView.cpp | 11 ++++ cocos/ui/UIImageView.h | 9 ++- cocos/ui/UILayout.cpp | 9 +++ cocos/ui/UILayout.h | 3 + cocos/ui/UILayoutComponent.cpp | 96 +++++++++++------------------ cocos/ui/UILoadingBar.cpp | 11 ++++ cocos/ui/UILoadingBar.h | 6 ++ cocos/ui/UIScale9Sprite.cpp | 12 ++++ cocos/ui/UIScale9Sprite.h | 3 + cocos/ui/UISlider.cpp | 63 ++++++++++++++++++- cocos/ui/UISlider.h | 14 ++++- cocos/ui/UITextAtlas.cpp | 9 +++ cocos/ui/UITextAtlas.h | 4 ++ cocos/ui/UITextBMFont.cpp | 9 +++ cocos/ui/UITextBMFont.h | 4 ++ cocos/ui/UIWidget.cpp | 7 ++- 24 files changed, 399 insertions(+), 75 deletions(-) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 387c3bd9e7..6093eea4b0 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -1254,6 +1254,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index b80fd19400..2919034953 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -3776,6 +3776,9 @@ network\Header Files + + ui + diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 282321f4fb..1f3a539d2c 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -30,7 +30,7 @@ THE SOFTWARE. // 0x00 HI ME LO // 00 03 08 00 -#define COCOS2D_VERSION 0x00030800 +#define COCOS2D_VERSION 0x00030900 // // all cocos2d include files diff --git a/cocos/ui/GUIExport.h b/cocos/ui/GUIExport.h index 717a0ad9e4..7b86aeaf3b 100644 --- a/cocos/ui/GUIExport.h +++ b/cocos/ui/GUIExport.h @@ -24,6 +24,8 @@ #define NULL ((void *)0) #endif #endif +#elif defined(_SHARED_) + #define CC_GUI_DLL __attribute__((visibility("default"))) #else #define CC_GUI_DLL #endif diff --git a/cocos/ui/UIAbstractCheckButton.cpp b/cocos/ui/UIAbstractCheckButton.cpp index 2edb24910e..b5886da07a 100644 --- a/cocos/ui/UIAbstractCheckButton.cpp +++ b/cocos/ui/UIAbstractCheckButton.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include "ui/UIAbstractCheckButton.h" #include "2d/CCSprite.h" +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -53,6 +54,11 @@ _frontCrossDisabledTexType(TextureResType::LOCAL), _zoomScale(0.1f), _backgroundTextureScaleX(1.0), _backgroundTextureScaleY(1.0), +_backGroundFileName(""), +_backGroundSelectedFileName(""), +_frontCrossFileName(""), +_backGroundDisabledFileName(""), +_frontCrossDisabledFileName(""), _backGroundBoxRendererAdaptDirty(true), _backGroundSelectedBoxRendererAdaptDirty(true), _frontCrossRendererAdaptDirty(true), @@ -129,10 +135,14 @@ void AbstractCheckButton::loadTextures(const std::string& backGround, void AbstractCheckButton::loadTextureBackGround(const std::string& backGround,TextureResType texType) { + _backGroundFileName = backGround; +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (backGround.empty()) { return; } +#endif + _backGroundTexType = texType; switch (_backGroundTexType) { @@ -166,13 +176,16 @@ void AbstractCheckButton::loadTextureBackGround(SpriteFrame* spriteFrame) void AbstractCheckButton::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType) { + _backGroundSelectedFileName = backGroundSelected; + _isBackgroundSelectedTextureLoaded = !backGroundSelected.empty(); +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (backGroundSelected.empty()) { return; } - +#endif + _backGroundSelectedTexType = texType; - _isBackgroundSelectedTextureLoaded = true; switch (_backGroundSelectedTexType) { case TextureResType::LOCAL: @@ -201,10 +214,14 @@ void AbstractCheckButton::setupBackgroundSelectedTexture() void AbstractCheckButton::loadTextureFrontCross(const std::string& cross,TextureResType texType) { + _frontCrossFileName = cross; +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (cross.empty()) { return; } +#endif + _frontCrossTexType = texType; switch (_frontCrossTexType) { @@ -234,12 +251,16 @@ void AbstractCheckButton::setupFrontCrossTexture() void AbstractCheckButton::loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType) { + _backGroundDisabledFileName = backGroundDisabled; + _isBackgroundDisabledTextureLoaded = !backGroundDisabled.empty(); +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (backGroundDisabled.empty()) { return; } +#endif + _backGroundDisabledTexType = texType; - _isBackgroundDisabledTextureLoaded = true; switch (_backGroundDisabledTexType) { case TextureResType::LOCAL: @@ -269,12 +290,16 @@ void AbstractCheckButton::setupBackgroundDisable() void AbstractCheckButton::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType) { + _frontCrossDisabledFileName = frontCrossDisabled; + _isFrontCrossDisabledTextureLoaded = !frontCrossDisabled.empty(); +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (frontCrossDisabled.empty()) { return; } +#endif + _frontCrossDisabledTexType = texType; - _isFrontCrossDisabledTextureLoaded = true; switch (_frontCrossDisabledTexType) { case TextureResType::LOCAL: @@ -579,6 +604,47 @@ void AbstractCheckButton::copySpecialProperties(Widget *widget) } } + +ResouceData AbstractCheckButton::getBackNormalFile() +{ + ResouceData rData; + rData.type = (int)_backGroundTexType; + rData.file = _backGroundFileName; + return rData; +} + +ResouceData AbstractCheckButton::getBackPressedFile() +{ + ResouceData rData; + rData.type = (int)_backGroundSelectedTexType; + rData.file = _backGroundSelectedFileName; + return rData; +} + +ResouceData AbstractCheckButton::getBackDisabledFile() +{ + ResouceData rData; + rData.type = (int)_backGroundDisabledTexType; + rData.file = _backGroundDisabledFileName; + return rData; +} + +ResouceData AbstractCheckButton::getCrossNormalFile() +{ + ResouceData rData; + rData.type = (int)_frontCrossTexType; + rData.file = _frontCrossFileName; + return rData; +} + +ResouceData AbstractCheckButton::getCrossDisabeldFile() +{ + ResouceData rData; + rData.type = (int)_frontCrossDisabledTexType; + rData.file = _frontCrossDisabledFileName; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UIAbstractCheckButton.h b/cocos/ui/UIAbstractCheckButton.h index bef259688e..3cf3e679c6 100644 --- a/cocos/ui/UIAbstractCheckButton.h +++ b/cocos/ui/UIAbstractCheckButton.h @@ -34,6 +34,7 @@ THE SOFTWARE. */ NS_CC_BEGIN class Sprite; +struct CC_DLL ResouceData; namespace ui { @@ -160,7 +161,13 @@ public: * @return the sprite instance of front cross when disabled */ Sprite* getRendererFrontCrossDisabled() const { return _frontCrossDisabledRenderer; } - + + ResouceData getBackNormalFile(); + ResouceData getBackPressedFile(); + ResouceData getBackDisabledFile(); + ResouceData getCrossNormalFile(); + ResouceData getCrossDisabeldFile(); + CC_CONSTRUCTOR_ACCESS: virtual bool init() override; virtual bool init(const std::string& backGround, @@ -237,6 +244,12 @@ protected: bool _frontCrossRendererAdaptDirty; bool _backGroundBoxDisabledRendererAdaptDirty; bool _frontCrossDisabledRendererAdaptDirty; + + std::string _backGroundFileName; + std::string _backGroundSelectedFileName; + std::string _frontCrossFileName; + std::string _backGroundDisabledFileName; + std::string _frontCrossDisabledFileName; }; } diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 2e785a5e14..060cc89f4e 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -30,6 +30,7 @@ THE SOFTWARE. #include "platform/CCFileUtils.h" #include "ui/UIHelper.h" #include +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -49,6 +50,13 @@ _buttonClickedRenderer(nullptr), _buttonDisabledRenderer(nullptr), _titleRenderer(nullptr), _zoomScale(0.1f), +_normalFileName(""), +_clickedFileName(""), +_disabledFileName(""), +_normalTexType(TextureResType::LOCAL), +_pressedTexType(TextureResType::LOCAL), +_disabledTexType(TextureResType::LOCAL), +_fontName(""), _prevIgnoreSize(true), _scale9Enabled(false), _pressedActionEnabled(false), @@ -222,10 +230,16 @@ void Button::loadTextures(const std::string& normal, void Button::loadTextureNormal(const std::string& normal,TextureResType texType) { - if(normal.empty()) + _normalFileName = normal; + _normalTexType = texType; + +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only + if (normal.empty()) { return; } +#endif + switch (texType) { case TextureResType::LOCAL: @@ -273,10 +287,15 @@ void Button::loadTextureNormal(SpriteFrame* normalSpriteFrame) void Button::loadTexturePressed(const std::string& selected,TextureResType texType) { + _clickedFileName = selected; + _pressedTexType = texType; + +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (selected.empty()) { return; } +#endif switch (texType) { @@ -311,10 +330,15 @@ void Button::loadTexturePressed(SpriteFrame* pressedSpriteFrame) void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType) { + _disabledFileName = disabled; + _disabledTexType = texType; + +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (disabled.empty()) { return; } +#endif switch (texType) { @@ -876,6 +900,7 @@ void Button::setTitleFontName(const std::string& fontName) _titleRenderer->setSystemFontSize(_fontSize); _type = FontType::SYSTEM; } + _fontName = fontName; this->updateContentSize(); } @@ -903,7 +928,7 @@ const std::string Button::getTitleFontName() const } else { - return ""; + return _fontName; } } @@ -976,6 +1001,67 @@ Size Button::getNormalTextureSize() const { return _normalTextureSize; } + +void Button::resetNormalRender() +{ + _normalFileName = ""; + _normalTexType = TextureResType::LOCAL; + + _normalTextureSize = Size(0, 0); + + _normalTextureLoaded = false; + _normalTextureAdaptDirty = false; + + _buttonNormalRenderer->resetRender(); +} +void Button::resetPressedRender() +{ + _clickedFileName = ""; + _pressedTexType = TextureResType::LOCAL; + + _pressedTextureSize = Size(0, 0); + + _pressedTextureLoaded = false; + _pressedTextureAdaptDirty = false; + + _buttonClickedRenderer->resetRender(); +} + +void Button::resetDisabledRender() +{ + _disabledFileName = ""; + _disabledTexType = TextureResType::LOCAL; + + _disabledTextureSize = Size(0, 0); + + _disabledTextureLoaded = false; + _disabledTextureAdaptDirty = false; + + _buttonDisabledRenderer->resetRender(); +} + +ResouceData Button::getNormalFile() +{ + ResouceData rData; + rData.type = (int)_normalTexType; + rData.file = _normalFileName; + return rData; +} +ResouceData Button::getPressedFile() +{ + ResouceData rData; + rData.type = (int)_pressedTexType; + rData.file = _clickedFileName; + return rData; +} +ResouceData Button::getDisabledFile() +{ + ResouceData rData; + rData.type = (int)_disabledTexType; + rData.file = _disabledFileName; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index aac84bbf21..f216c907c3 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -36,6 +36,7 @@ NS_CC_BEGIN class Label; class SpriteFrame; +struct CC_DLL ResouceData; namespace ui{ @@ -296,6 +297,14 @@ public: */ Scale9Sprite* getRendererDisabled() const { return _buttonDisabledRenderer; } + void resetNormalRender(); + void resetPressedRender(); + void resetDisabledRender(); + + ResouceData getNormalFile(); + ResouceData getPressedFile(); + ResouceData getDisabledFile(); + CC_CONSTRUCTOR_ACCESS: virtual bool init() override; virtual bool init(const std::string& normalImage, @@ -363,6 +372,13 @@ protected: bool _pressedTextureAdaptDirty; bool _disabledTextureAdaptDirty; + std::string _normalFileName; + std::string _clickedFileName; + std::string _disabledFileName; + TextureResType _normalTexType; + TextureResType _pressedTexType; + TextureResType _disabledTexType; + private: enum class FontType { @@ -373,6 +389,7 @@ private: int _fontSize; FontType _type; + std::string _fontName; }; } diff --git a/cocos/ui/UIImageView.cpp b/cocos/ui/UIImageView.cpp index 3bda9b3fc8..9eb5619dda 100644 --- a/cocos/ui/UIImageView.cpp +++ b/cocos/ui/UIImageView.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "ui/UIScale9Sprite.h" #include "ui/UIHelper.h" #include "2d/CCSprite.h" +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -39,6 +40,7 @@ ImageView::ImageView(): _scale9Enabled(false), _prevIgnoreSize(true), _capInsets(Rect::ZERO), +_textureFile(""), _imageRenderer(nullptr), _imageTexType(TextureResType::LOCAL), _imageTextureSize(_contentSize), @@ -121,6 +123,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) { return; } + _textureFile = fileName; _imageTexType = texType; switch (_imageTexType) { @@ -311,6 +314,14 @@ void ImageView::copySpecialProperties(Widget *widget) } } +ResouceData ImageView::getRenderFile() +{ + ResouceData rData; + rData.type = (int)_imageTexType; + rData.file = _textureFile; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UIImageView.h b/cocos/ui/UIImageView.h index 8289fea104..7c2a82ac27 100644 --- a/cocos/ui/UIImageView.h +++ b/cocos/ui/UIImageView.h @@ -34,9 +34,11 @@ THE SOFTWARE. */ NS_CC_BEGIN +struct CC_DLL ResouceData; + namespace ui { class Scale9Sprite; -/** + /** * @brief A widget to display images. */ class CC_GUI_DLL ImageView : public Widget @@ -121,7 +123,9 @@ public: virtual std::string getDescription() const override; virtual Size getVirtualRendererSize() const override; virtual Node* getVirtualRenderer() override; - + + ResouceData getRenderFile(); + CC_CONSTRUCTOR_ACCESS: //initializes state of widget. virtual bool init() override; @@ -146,6 +150,7 @@ protected: TextureResType _imageTexType; Size _imageTextureSize; bool _imageRendererAdaptDirty; + std::string _textureFile; }; } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 3f8cc02db8..f75e05310a 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include "2d/CCLayer.h" #include "2d/CCSprite.h" #include "base/CCEventFocus.h" +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -2032,5 +2033,13 @@ void Layout::setCameraMask(unsigned short mask, bool applyChildren) } } +ResouceData Layout::getRenderFile() +{ + ResouceData rData; + rData.type = (int)_bgImageTexType; + rData.file = _backGroundImageFileName; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index f98c37bcdf..232a38d42a 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -39,6 +39,7 @@ NS_CC_BEGIN class DrawNode; class LayerColor; class LayerGradient; +struct CC_DLL ResouceData; namespace ui { @@ -458,6 +459,8 @@ public: */ virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override; + ResouceData getRenderFile(); + CC_CONSTRUCTOR_ACCESS: //override "init" method of widget. virtual bool init() override; diff --git a/cocos/ui/UILayoutComponent.cpp b/cocos/ui/UILayoutComponent.cpp index 56fbee58a7..baf4e9e7f2 100644 --- a/cocos/ui/UILayoutComponent.cpp +++ b/cocos/ui/UILayoutComponent.cpp @@ -184,7 +184,7 @@ namespace ui { else { _positionPercentX = 0; - if (_usingPositionPercentX) + if (_usingPositionPercentX || _horizontalEdge == HorizontalEdge::Center) ownerPoint.x = 0; } @@ -193,7 +193,7 @@ namespace ui { else { _positionPercentY = 0; - if (_usingPositionPercentY) + if (_usingPositionPercentY || _verticalEdge == VerticalEdge::Center) ownerPoint.y = 0; } @@ -227,11 +227,14 @@ namespace ui { { _positionPercentX = percentMargin; - Node* parent = this->getOwnerParent(); - if (parent != nullptr) + if (_usingPositionPercentX || _horizontalEdge == HorizontalEdge::Center) { - _owner->setPositionX(parent->getContentSize().width * _positionPercentX); - this->refreshHorizontalMargin(); + Node* parent = this->getOwnerParent(); + if (parent != nullptr) + { + _owner->setPositionX(parent->getContentSize().width * _positionPercentX); + this->refreshHorizontalMargin(); + } } } @@ -256,11 +259,14 @@ namespace ui { { _positionPercentY = percentMargin; - Node* parent = this->getOwnerParent(); - if (parent != nullptr) + if (_usingPositionPercentY || _verticalEdge == VerticalEdge::Center) { - _owner->setPositionY(parent->getContentSize().height * _positionPercentY); - this->refreshVerticalMargin(); + Node* parent = this->getOwnerParent(); + if (parent != nullptr) + { + _owner->setPositionY(parent->getContentSize().height * _positionPercentY); + this->refreshVerticalMargin(); + } } } @@ -275,24 +281,6 @@ namespace ui { { _usingPositionPercentX = false; } - - Node* parent = this->getOwnerParent(); - if (parent != nullptr) - { - Point ownerPoint = _owner->getPosition(); - const Size& parentSize = parent->getContentSize(); - if (parentSize.width != 0) - _positionPercentX = ownerPoint.x / parentSize.width; - else - { - _positionPercentX = 0; - ownerPoint.x = 0; - if (_usingPositionPercentX) - _owner->setPosition(ownerPoint); - } - - this->refreshHorizontalMargin(); - } } LayoutComponent::VerticalEdge LayoutComponent::getVerticalEdge()const @@ -306,24 +294,6 @@ namespace ui { { _usingPositionPercentY = false; } - - Node* parent = this->getOwnerParent(); - if (parent != nullptr) - { - Point ownerPoint = _owner->getPosition(); - const Size& parentSize = parent->getContentSize(); - if (parentSize.height != 0) - _positionPercentY = ownerPoint.y / parentSize.height; - else - { - _positionPercentY = 0; - ownerPoint.y = 0; - if (_usingPositionPercentY) - _owner->setPosition(ownerPoint); - } - - this->refreshVerticalMargin(); - } } float LayoutComponent::getLeftMargin()const @@ -380,7 +350,7 @@ namespace ui { else { _percentWidth = 0; - if (_usingPercentWidth) + if (_usingPercentWidth || (this->_horizontalEdge != HorizontalEdge::Center && this->_usingStretchWidth)) ownerSize.width = 0; } @@ -389,7 +359,7 @@ namespace ui { else { _percentHeight = 0; - if (_usingPercentHeight) + if (_usingPercentHeight || (this->_verticalEdge != VerticalEdge::Center && this->_usingStretchHeight)) ownerSize.height = 0; } @@ -451,14 +421,17 @@ namespace ui { { _percentWidth = percentWidth; - Node* parent = this->getOwnerParent(); - if (parent != nullptr) + if (_usingPercentWidth) { - Size ownerSize = _owner->getContentSize(); - ownerSize.width = parent->getContentSize().width * _percentWidth; - _owner->setContentSize(ownerSize); + Node* parent = this->getOwnerParent(); + if (parent != nullptr) + { + Size ownerSize = _owner->getContentSize(); + ownerSize.width = parent->getContentSize().width * _percentWidth; + _owner->setContentSize(ownerSize); - this->refreshHorizontalMargin(); + this->refreshHorizontalMargin(); + } } } @@ -511,14 +484,17 @@ namespace ui { { _percentHeight = percentHeight; - Node* parent = this->getOwnerParent(); - if (parent != nullptr) + if (_usingPercentHeight) { - Size ownerSize = _owner->getContentSize(); - ownerSize.height = parent->getContentSize().height * _percentHeight; - _owner->setContentSize(ownerSize); + Node* parent = this->getOwnerParent(); + if (parent != nullptr) + { + Size ownerSize = _owner->getContentSize(); + ownerSize.height = parent->getContentSize().height * _percentHeight; + _owner->setContentSize(ownerSize); - this->refreshVerticalMargin(); + this->refreshVerticalMargin(); + } } } diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index b682dc56b8..ab403122a7 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "ui/UIHelper.h" #include "ui/UIScale9Sprite.h" #include "2d/CCSprite.h" +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -39,6 +40,7 @@ LoadingBar::LoadingBar(): _direction(Direction::LEFT), _percent(100.0), _totalLength(0), +_textureFile(""), _barRenderer(nullptr), _renderBarTexType(TextureResType::LOCAL), _barRendererTextureSize(Size::ZERO), @@ -146,6 +148,7 @@ void LoadingBar::loadTexture(const std::string& texture,TextureResType texType) { return; } + _textureFile = texture; _renderBarTexType = texType; switch (_renderBarTexType) { @@ -418,6 +421,14 @@ void LoadingBar::copySpecialProperties(Widget *widget) } } +ResouceData LoadingBar::getRenderFile() +{ + ResouceData rData; + rData.type = (int)_renderBarTexType; + rData.file = _textureFile; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index 171b18d898..b332edc66d 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -34,6 +34,8 @@ NS_CC_BEGIN * @{ */ +struct CC_DLL ResouceData; + namespace ui { class Scale9Sprite; @@ -171,6 +173,9 @@ public: virtual Size getVirtualRendererSize() const override; virtual Node* getVirtualRenderer() override; virtual std::string getDescription() const override; + + ResouceData getRenderFile(); + protected: virtual void initRenderer() override; virtual void onSizeChanged() override; @@ -197,6 +202,7 @@ protected: bool _prevIgnoreSize; Rect _capInsets; bool _barRendererAdaptDirty; + std::string _textureFile; }; } diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 35605110f9..c21ae93e6a 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -420,6 +420,10 @@ namespace ui { _scale9Image->setSpriteFrame(sprite->getSpriteFrame()); } } + else + { + CC_SAFE_RELEASE_NULL(_scale9Image); + } if (!_scale9Image) { @@ -1286,4 +1290,12 @@ namespace ui { return _renderingType; } + void Scale9Sprite::resetRender() + { + // Release old sprites + this->cleanupSlicedSprites(); + + CC_SAFE_RELEASE_NULL(this->_scale9Image); + } + }} diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index 593297fe4e..7547164260 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -667,6 +667,9 @@ namespace ui { * Return the slice sprite rendering type. */ RenderingType getRenderingType()const; + + void resetRender(); + protected: void updateCapInset(); void createSlicedSprites(); diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index 19a465b8a6..ec571ba532 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -27,6 +27,7 @@ THE SOFTWARE. #include "ui/UIHelper.h" #include "2d/CCSprite.h" #include "2d/CCCamera.h" +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -68,7 +69,12 @@ _ballNTexType(TextureResType::LOCAL), _ballPTexType(TextureResType::LOCAL), _ballDTexType(TextureResType::LOCAL), _barRendererAdaptDirty(true), -_progressBarRendererDirty(true) +_progressBarRendererDirty(true), +_textureFile(""), +_progressBarTextureFile(""), +_slidBallNormalTextureFile(""), +_slidBallPressedTextureFile(""), +_slidBallDisabledTextureFile("") { setTouchEnabled(true); } @@ -147,10 +153,13 @@ void Slider::initRenderer() void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) { + _textureFile = fileName; +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (fileName.empty()) { return; } +#endif _barTexType = texType; switch (_barTexType) { @@ -182,10 +191,13 @@ void Slider::setupBarTexture() void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType texType) { + _progressBarTextureFile = fileName; +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (fileName.empty()) { return; } +#endif _progressBarTexType = texType; switch (_progressBarTexType) { @@ -305,10 +317,13 @@ void Slider::loadSlidBallTextures(const std::string& normal, void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType texType) { + _slidBallNormalTextureFile = normal; +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (normal.empty()) { return; } +#endif _ballNTexType = texType; switch (_ballNTexType) { @@ -331,12 +346,15 @@ void Slider::loadSlidBallTextureNormal(SpriteFrame* spriteframe) void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType) { + _slidBallPressedTextureFile = pressed; + _isSliderBallPressedTextureLoaded = !pressed.empty(); +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (pressed.empty()) { return; } +#endif _ballPTexType = texType; - _isSliderBallPressedTextureLoaded = true; switch (_ballPTexType) { case TextureResType::LOCAL: @@ -360,11 +378,14 @@ void Slider::loadSlidBallTexturePressed(SpriteFrame* spriteframe) void Slider::loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType) { + _slidBallDisabledTextureFile = disabled; + _isSliderBallDisabledTexturedLoaded = !disabled.empty(); +#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (disabled.empty()) { return; } - _isSliderBallDisabledTexturedLoaded = true; +#endif _ballDTexType = texType; switch (_ballDTexType) { @@ -723,6 +744,42 @@ void Slider::copySpecialProperties(Widget *widget) } } +ResouceData Slider::getBackFile() +{ + ResouceData rData; + rData.type = (int)_barTexType; + rData.file = _textureFile; + return rData; +} +ResouceData Slider::getProgressBarFile() +{ + ResouceData rData; + rData.type = (int)_progressBarTexType; + rData.file = _progressBarTextureFile; + return rData; +} +ResouceData Slider::getBallNormalFile() +{ + ResouceData rData; + rData.type = (int)_ballNTexType; + rData.file = _slidBallNormalTextureFile; + return rData; +} +ResouceData Slider::getBallPressedFile() +{ + ResouceData rData; + rData.type = (int)_ballPTexType; + rData.file = _slidBallPressedTextureFile; + return rData; +} +ResouceData Slider::getBallDisabeldFile() +{ + ResouceData rData; + rData.type = (int)_ballDTexType; + rData.file = _slidBallDisabledTextureFile; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index 8304870210..45fa8a6bd2 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -36,6 +36,7 @@ NS_CC_BEGIN */ class Sprite; +struct CC_DLL ResouceData; namespace ui { class Scale9Sprite; @@ -264,7 +265,12 @@ public: */ float getZoomScale()const; - + ResouceData getBackFile(); + ResouceData getProgressBarFile(); + ResouceData getBallNormalFile(); + ResouceData getBallPressedFile(); + ResouceData getBallDisabeldFile(); + CC_CONSTRUCTOR_ACCESS: virtual bool init() override; @@ -341,6 +347,12 @@ protected: TextureResType _ballDTexType; bool _barRendererAdaptDirty; bool _progressBarRendererDirty; + + std::string _textureFile; + std::string _progressBarTextureFile; + std::string _slidBallNormalTextureFile; + std::string _slidBallPressedTextureFile; + std::string _slidBallDisabledTextureFile; }; } diff --git a/cocos/ui/UITextAtlas.cpp b/cocos/ui/UITextAtlas.cpp index 64f06f4636..c448791f2e 100644 --- a/cocos/ui/UITextAtlas.cpp +++ b/cocos/ui/UITextAtlas.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include "ui/UITextAtlas.h" #include "2d/CCLabel.h" +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -190,5 +191,13 @@ void TextAtlas::copySpecialProperties(Widget *widget) } } +ResouceData TextAtlas::getRenderFile() +{ + ResouceData rData; + rData.type = 0; + rData.file = _charMapFileName; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UITextAtlas.h b/cocos/ui/UITextAtlas.h index ca3b3e3a48..f6b7cfafbc 100644 --- a/cocos/ui/UITextAtlas.h +++ b/cocos/ui/UITextAtlas.h @@ -36,6 +36,7 @@ NS_CC_BEGIN */ class Label; +struct CC_DLL ResouceData; namespace ui { @@ -138,6 +139,9 @@ public: * @js NA */ virtual void adaptRenderers() override; + + ResouceData getRenderFile(); + protected: virtual void initRenderer() override; virtual void onSizeChanged() override; diff --git a/cocos/ui/UITextBMFont.cpp b/cocos/ui/UITextBMFont.cpp index 2bc541870d..6ac518cb98 100644 --- a/cocos/ui/UITextBMFont.cpp +++ b/cocos/ui/UITextBMFont.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include "ui/UITextBMFont.h" #include "2d/CCLabel.h" +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -186,6 +187,14 @@ void TextBMFont::copySpecialProperties(Widget *widget) } } +ResouceData TextBMFont::getRenderFile() +{ + ResouceData rData; + rData.type = 0; + rData.file = _fntFileName; + return rData; +} + } NS_CC_END diff --git a/cocos/ui/UITextBMFont.h b/cocos/ui/UITextBMFont.h index 179884cb9d..994935acf5 100644 --- a/cocos/ui/UITextBMFont.h +++ b/cocos/ui/UITextBMFont.h @@ -35,6 +35,7 @@ THE SOFTWARE. NS_CC_BEGIN class Label; +struct CC_DLL ResouceData; namespace ui { @@ -94,6 +95,9 @@ public: * Returns the "class name" of widget. */ virtual std::string getDescription() const override; + + ResouceData getRenderFile(); + protected: virtual void initRenderer() override; virtual void onSizeChanged() override; diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 3a1accbad6..d4389ec297 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -303,7 +303,7 @@ void Widget::setContentSize(const cocos2d::Size &contentSize) } else if (_ignoreSize) { - _contentSize = getVirtualRendererSize(); + ProtectedNode::setContentSize(getVirtualRendererSize()); } if (!_usingLayoutComponent && _running) { @@ -609,6 +609,11 @@ bool Widget::isHighlighted() const void Widget::setHighlighted(bool highlight) { + if (highlight == _highlight) + { + return; + } + _highlight = highlight; if (_bright) { From fb7b92915c7d53230fe4518c4b784724f778672b Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 18 Nov 2015 14:34:14 +0800 Subject: [PATCH 086/192] Combine Studio change for particle 3d --- extensions/ExtensionExport.h | 2 ++ extensions/Particle3D/PU/CCPUMaterialManager.h | 4 ++-- extensions/Particle3D/PU/CCPUParticleSystem3D.h | 3 ++- extensions/Particle3D/PU/CCPUScriptCompiler.h | 12 ++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/extensions/ExtensionExport.h b/extensions/ExtensionExport.h index 837df61c54..75380032e3 100644 --- a/extensions/ExtensionExport.h +++ b/extensions/ExtensionExport.h @@ -24,6 +24,8 @@ #define NULL ((void *)0) #endif #endif +#elif defined(_SHARED_) + #define CC_EX_DLL __attribute__((visibility("default"))) #else #define CC_EX_DLL #endif diff --git a/extensions/Particle3D/PU/CCPUMaterialManager.h b/extensions/Particle3D/PU/CCPUMaterialManager.h index fb48645e77..ea039d99f2 100644 --- a/extensions/Particle3D/PU/CCPUMaterialManager.h +++ b/extensions/Particle3D/PU/CCPUMaterialManager.h @@ -31,7 +31,7 @@ NS_CC_BEGIN -class PUMaterial : public Ref +class CC_DLL PUMaterial : public Ref { public: @@ -54,7 +54,7 @@ public: GLuint wrapMode; }; -class PUMaterialCache +class CC_DLL PUMaterialCache { public: diff --git a/extensions/Particle3D/PU/CCPUParticleSystem3D.h b/extensions/Particle3D/PU/CCPUParticleSystem3D.h index 470124134d..e6f46423e4 100644 --- a/extensions/Particle3D/PU/CCPUParticleSystem3D.h +++ b/extensions/Particle3D/PU/CCPUParticleSystem3D.h @@ -353,6 +353,8 @@ public: virtual PUParticleSystem3D* clone(); virtual void copyAttributesTo(PUParticleSystem3D* system); + bool initSystem(const std::string &filePath); + CC_CONSTRUCTOR_ACCESS: PUParticleSystem3D(); virtual ~PUParticleSystem3D(); @@ -379,7 +381,6 @@ protected: inline bool isExpired(PUParticle3D* particle, float timeElapsed); - bool initSystem(const std::string &filePath); static void convertToUnixStylePath(std::string &path); protected: diff --git a/extensions/Particle3D/PU/CCPUScriptCompiler.h b/extensions/Particle3D/PU/CCPUScriptCompiler.h index a2a730eca8..7523c3e163 100644 --- a/extensions/Particle3D/PU/CCPUScriptCompiler.h +++ b/extensions/Particle3D/PU/CCPUScriptCompiler.h @@ -41,10 +41,10 @@ enum PUAbstractNodeType ANT_VARIABLE_SET, ANT_VARIABLE_ACCESS }; -class PUAbstractNode; +class CC_DLL PUAbstractNode; typedef std::list PUAbstractNodeList; -class PUAbstractNode +class CC_DLL PUAbstractNode { public: std::string file; @@ -97,7 +97,7 @@ public: }; /** This abstract node represents a script property */ -class PUPropertyAbstractNode : public PUAbstractNode +class CC_DLL PUPropertyAbstractNode : public PUAbstractNode { public: std::string name; @@ -111,7 +111,7 @@ public: }; /** This is an abstract node which cannot be broken down further */ -class PUAtomAbstractNode : public PUAbstractNode +class CC_DLL PUAtomAbstractNode : public PUAbstractNode { public: std::string value; @@ -124,8 +124,8 @@ private: void parseNumber() const; }; -class PUParticleSystem3D; -class PUScriptCompiler +class CC_DLL PUParticleSystem3D; +class CC_DLL PUScriptCompiler { private: From 02b59f020e13b1f4dc20b24d32690ea8467d5444 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 18 Nov 2015 15:05:13 +0800 Subject: [PATCH 087/192] Fix onEndEditing issue in script. Issue: https://github.com/cocos2d/cocos2d-x/issues/14332 --- cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp index c44dec4468..10859ed70c 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp @@ -350,7 +350,7 @@ void EditBoxImplCommon::editBoxEditingDidEnd(const std::string& text) if (_editBox != nullptr) { - this->onEndEditing(text); + this->onEndEditing(_text); } } From b33aa00109b65c3670ec4e26307c0cb972b1d307 Mon Sep 17 00:00:00 2001 From: Xpol Wan Date: Wed, 18 Nov 2015 17:47:07 +0800 Subject: [PATCH 088/192] Fixes boring deprecated warning. I know I duplicated the code but there is no cpp for me to move body into. --- cocos/network/HttpRequest.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index eafe52538a..bcccd0136d 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -242,7 +242,15 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector) { - setResponseCallback(pTarget, (SEL_HttpResponse) pSelector); + // This function have duplicated body with setResponseCallback(Ref* , SEL_HttpResponse ) + // You must repeat youself in that function when modified. + _pTarget = pTarget; + _pSelector = (SEL_HttpResponse)pSelector; + + if (_pTarget) + { + _pTarget->retain(); + } } /** @@ -254,6 +262,8 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) { + // This function have duplicated body with setResponseCallback(Ref* , SEL_CallFuncND ) + // You must repeat youself in that function. _pTarget = pTarget; _pSelector = pSelector; From 0b5a3465bc2fe1197908a984d32100e26fb5deea Mon Sep 17 00:00:00 2001 From: Xpol Wan Date: Wed, 18 Nov 2015 17:52:24 +0800 Subject: [PATCH 089/192] Remove duplicated code by introduce a private doSetResponseCallback. --- cocos/network/HttpRequest.h | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index bcccd0136d..ea3de64a2d 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -242,15 +242,7 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector) { - // This function have duplicated body with setResponseCallback(Ref* , SEL_HttpResponse ) - // You must repeat youself in that function when modified. - _pTarget = pTarget; - _pSelector = (SEL_HttpResponse)pSelector; - - if (_pTarget) - { - _pTarget->retain(); - } + doSetResponseCallback(pTarget, (SEL_HttpResponse)pSelector); } /** @@ -262,15 +254,7 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) { - // This function have duplicated body with setResponseCallback(Ref* , SEL_CallFuncND ) - // You must repeat youself in that function. - _pTarget = pTarget; - _pSelector = pSelector; - - if (_pTarget) - { - _pTarget->retain(); - } + doSetResponseCallback(pTarget, pSelector); } /** * Set response callback function of HttpRequest object. @@ -352,6 +336,18 @@ public: return _headers; } +private: + inline void doSetResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) + { + _pTarget = pTarget; + _pSelector = pSelector; + + if (_pTarget) + { + _pTarget->retain(); + } + } + protected: // properties Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums From 9cbcd00798395a593e167d7702df7e832411a3f7 Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Wed, 18 Nov 2015 22:47:26 +0800 Subject: [PATCH 090/192] some properties should be set --- cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp index b8faf4c3ca..9ad5332c85 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp @@ -307,9 +307,12 @@ INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param, dlgTemplate->y = param->yPos; } - CCAssert(s_win32InputBox == nullptr, ""); + CCAssert(s_win32InputBox == nullptr, "Only one instance of Win32InputBox allowed"); s_win32InputBox = new (std::nothrow) CWin32InputBox(param); + s_win32InputBox->_returnType = eReturnType; + s_win32InputBox->_inputMode = eInputMode; + s_win32InputBox->_inputFlag = eInputFlag; s_win32InputBox->_onTextChange = onTextChange; s_win32InputBox->_onClose = onClose; @@ -489,7 +492,7 @@ void CWin32InputBox::InitDialog() break; } - CCAssert(_getMsgHook == NULL, ""); + CCAssert(_getMsgHook == NULL, "Windows Message hook already set"); // To make the enter key work, here need a Windows Message hook. // Please refer to https://support.microsoft.com/en-us/kb/187988 From efeae1eae953fdc2213f98c3b060f9b67e711c42 Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Wed, 18 Nov 2015 22:52:47 +0800 Subject: [PATCH 091/192] add a test case for pr 14327 --- .../cpp-tests/Classes/BugsTest/Bug-14327.cpp | 91 +++++++++++++++++++ tests/cpp-tests/Classes/BugsTest/Bug-14327.h | 31 +++++++ tests/cpp-tests/Classes/BugsTest/BugsTest.cpp | 8 ++ tests/cpp-tests/proj.win32/cpp-tests.vcxproj | 2 + .../proj.win32/cpp-tests.vcxproj.filters | 6 ++ 5 files changed, 138 insertions(+) create mode 100644 tests/cpp-tests/Classes/BugsTest/Bug-14327.cpp create mode 100644 tests/cpp-tests/Classes/BugsTest/Bug-14327.h diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-14327.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-14327.cpp new file mode 100644 index 0000000000..1d0c2fc548 --- /dev/null +++ b/tests/cpp-tests/Classes/BugsTest/Bug-14327.cpp @@ -0,0 +1,91 @@ +// +// Bug-14327.cpp +// cocos2d_tests +// +// Issue: https://github.com/cocos2d/cocos2d-x/pull/14327 +// Please test in Windows +// +// + +#include "Bug-14327.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + +USING_NS_CC; + +bool Bug14327Layer::init() +{ + if (BugsTestBase::init()) + { + auto glview = Director::getInstance()->getOpenGLView(); + auto visibleOrigin = glview->getVisibleOrigin(); + auto visibleSize = glview->getVisibleSize(); + + auto pBg = Sprite::create("Images/HelloWorld.png"); + pBg->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height / 2)); + addChild(pBg); + + _removeTime = time(nullptr) + 20; + + _TTFShowTime = Label::createWithSystemFont("Edit control will be removed after 00:20!", "Arial", 20); + _TTFShowTime->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height - 60)); + this->addChild(_TTFShowTime); + + + auto editBoxSize = Size(visibleSize.width - 100, visibleSize.height * 0.1); + + std::string pNormalSprite = "extensions/green_edit.png"; + _edit = ui::EditBox::create(editBoxSize + Size(0, 20), ui::Scale9Sprite::create(pNormalSprite)); + _edit->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height / 2)); + _edit->setFontColor(Color3B::RED); + _edit->setReturnType(ui::EditBox::KeyboardReturnType::DONE); + _edit->setDelegate(this); + this->addChild(_edit); + + this->scheduleUpdate(); + return true; + } + + return false; +} + +void Bug14327Layer::update(float dt) +{ + long delta = _removeTime - time(nullptr); + if (delta > 0) + { + ldiv_t ret = ldiv(delta, 60L); + char str[100]; + snprintf(str, 100, "%s%.2ld:%.2ld", "Edit control will be removed after ", ret.quot, ret.rem); + _TTFShowTime->setString(str); + } + else + { + _edit->removeFromParent(); + _edit = nullptr; + _TTFShowTime->setString("Edit control has been removed!\nIt should not crash."); + this->unscheduleUpdate(); + } +} + +void Bug14327Layer::editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox) +{ + log("editBox %p DidBegin !", editBox); +} + +void Bug14327Layer::editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox) +{ + log("editBox %p DidEnd !", editBox); +} + +void Bug14327Layer::editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text) +{ + log("editBox %p TextChanged, text: %s ", editBox, text.c_str()); +} + +void Bug14327Layer::editBoxReturn(ui::EditBox* editBox) +{ + log("editBox %p was returned !", editBox); +} + +#endif diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-14327.h b/tests/cpp-tests/Classes/BugsTest/Bug-14327.h new file mode 100644 index 0000000000..2191b2b6f7 --- /dev/null +++ b/tests/cpp-tests/Classes/BugsTest/Bug-14327.h @@ -0,0 +1,31 @@ +#ifndef __cocos2d_tests__Bug_14327__ +#define __cocos2d_tests__Bug_14327__ + +#include "BugsTest.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + +class Bug14327Layer : public BugsTestBase, public cocos2d::ui::EditBoxDelegate +{ +public: + CREATE_FUNC(Bug14327Layer); + + virtual bool init() override; + + virtual void editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox) override; + virtual void editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox) override; + virtual void editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text) override; + virtual void editBoxReturn(cocos2d::ui::EditBox* editBox) override; + +protected: + virtual void update(float dt) override; + +private: + time_t _removeTime; + cocos2d::Label *_TTFShowTime; + cocos2d::ui::EditBox* _edit; +}; + +#endif + +#endif /* defined(__cocos2d_tests__Bug_14327__) */ diff --git a/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp b/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp index 55b6a4fe10..5ea0363d20 100644 --- a/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp +++ b/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp @@ -13,6 +13,10 @@ #include "Bug-CCDrawNode.h" #include "Bug-PageViewLayout.h" +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#include "Bug-14327.h" +#endif + BugsTests::BugsTests() { ADD_TEST_CASE(Bug350Layer); @@ -29,4 +33,8 @@ BugsTests::BugsTests() ADD_TEST_CASE(BugDrawNodeLayer); ADD_TEST_CASE(BugPageViewLayer); ADD_TEST_CASE(Bug12847Layer); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + ADD_TEST_CASE(Bug14327Layer); +#endif } diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj index 6214945a7f..d7e62975bc 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj @@ -152,6 +152,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y + @@ -346,6 +347,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y + diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters index 5ac16aa2dd..ac91fe4111 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters @@ -931,6 +931,9 @@ Classes\BugsTest + + Classes\BugsTest + Classes\DownloaderTest @@ -1689,6 +1692,9 @@ Classes\BugsTest + + Classes\BugsTest + Classes\DownloaderTest From 5369f9a84d83c8b7b7a21fef2b8d27b656b814f9 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 19 Nov 2015 10:14:27 +0800 Subject: [PATCH 092/192] Add header file to make this pr can pass jenkins auto build --- cocos/2d/CocosStudioExtension.h | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cocos/2d/CocosStudioExtension.h diff --git a/cocos/2d/CocosStudioExtension.h b/cocos/2d/CocosStudioExtension.h new file mode 100644 index 0000000000..aa8ad9b4a5 --- /dev/null +++ b/cocos/2d/CocosStudioExtension.h @@ -0,0 +1,44 @@ + +#ifndef __COCOSSTUDIOEXTENSION_H__ +#define __COCOSSTUDIOEXTENSION_H__ + +#include "math/CCAffineTransform.h" + +NS_CC_BEGIN + +struct CC_DLL ResouceData +{ + int type; + std::string file; + std::string plist; + + ResouceData() + { + type = 0; + file = ""; + plist = ""; + } + + ResouceData(int iType, std::string sFile, std::string sPlist) + { + type = iType; + file = sFile; + plist = sPlist; + } +}; + +class CC_DLL NodeExtension +{ +public: + NodeExtension(); + ~NodeExtension(); + +private: + +}; + + +NS_CC_END + + +#endif \ No newline at end of file From d5b07e5b60b23e5175e82aef474d6b27a36e9594 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 19 Nov 2015 03:14:03 +0000 Subject: [PATCH 093/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/RichElementNewLine.lua | 28 ++++++ .../auto/api/lua_cocos2dx_ui_auto_api.lua | 5 + .../auto/lua_cocos2dx_ui_auto.cpp | 99 +++++++++++++++++++ .../auto/lua_cocos2dx_ui_auto.hpp | 3 + 4 files changed, 135 insertions(+) create mode 100644 cocos/scripting/lua-bindings/auto/api/RichElementNewLine.lua diff --git a/cocos/scripting/lua-bindings/auto/api/RichElementNewLine.lua b/cocos/scripting/lua-bindings/auto/api/RichElementNewLine.lua new file mode 100644 index 0000000000..2d8483454f --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RichElementNewLine.lua @@ -0,0 +1,28 @@ + +-------------------------------- +-- @module RichElementNewLine +-- @extend RichElement +-- @parent_module ccui + +-------------------------------- +-- brief Create a RichElementNewLine with various arguments.
+-- param tag A integer tag value.
+-- param color A color in Color3B.
+-- param opacity A opacity in GLubyte.
+-- return A RichElementNewLine instance. +-- @function [parent=#RichElementNewLine] create +-- @param self +-- @param #int tag +-- @param #color3b_table color +-- @param #unsigned char opacity +-- @return RichElementNewLine#RichElementNewLine ret (return value: ccui.RichElementNewLine) + +-------------------------------- +-- brief Default constructor.
+-- js ctor
+-- lua new +-- @function [parent=#RichElementNewLine] RichElementNewLine +-- @param self +-- @return RichElementNewLine#RichElementNewLine self (return value: ccui.RichElementNewLine) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua index 18f8e8be60..d41e40a9dc 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua @@ -126,6 +126,11 @@ -- @field [parent=#ccui] RichElementCustomNode#RichElementCustomNode RichElementCustomNode preloaded module +-------------------------------------------------------- +-- the ccui RichElementNewLine +-- @field [parent=#ccui] RichElementNewLine#RichElementNewLine RichElementNewLine preloaded module + + -------------------------------------------------------- -- the ccui RichText -- @field [parent=#ccui] RichText#RichText RichText preloaded module diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index d6b2cf6c60..1b18fe5da8 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -23393,6 +23393,104 @@ int lua_register_cocos2dx_ui_RichElementCustomNode(lua_State* tolua_S) return 1; } +int lua_cocos2dx_ui_RichElementNewLine_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.RichElementNewLine",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 3) + { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.RichElementNewLine:create"); + ok &= luaval_to_color3b(tolua_S, 3, &arg1, "ccui.RichElementNewLine:create"); + ok &= luaval_to_uint16(tolua_S, 4,&arg2, "ccui.RichElementNewLine:create"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RichElementNewLine_create'", nullptr); + return 0; + } + cocos2d::ui::RichElementNewLine* ret = cocos2d::ui::RichElementNewLine::create(arg0, arg1, arg2); + object_to_luaval(tolua_S, "ccui.RichElementNewLine",(cocos2d::ui::RichElementNewLine*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.RichElementNewLine:create",argc, 3); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RichElementNewLine_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_ui_RichElementNewLine_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RichElementNewLine* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RichElementNewLine_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::ui::RichElementNewLine(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.RichElementNewLine"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RichElementNewLine:RichElementNewLine",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RichElementNewLine_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_ui_RichElementNewLine_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (RichElementNewLine)"); + return 0; +} + +int lua_register_cocos2dx_ui_RichElementNewLine(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"ccui.RichElementNewLine"); + tolua_cclass(tolua_S,"RichElementNewLine","ccui.RichElementNewLine","ccui.RichElement",nullptr); + + tolua_beginmodule(tolua_S,"RichElementNewLine"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_RichElementNewLine_constructor); + tolua_function(tolua_S,"create", lua_cocos2dx_ui_RichElementNewLine_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::ui::RichElementNewLine).name(); + g_luaType[typeName] = "ccui.RichElementNewLine"; + g_typeCast["RichElementNewLine"] = "ccui.RichElementNewLine"; + return 1; +} + int lua_cocos2dx_ui_RichText_insertElement(lua_State* tolua_S) { int argc = 0; @@ -30494,6 +30592,7 @@ TOLUA_API int register_all_cocos2dx_ui(lua_State* tolua_S) lua_register_cocos2dx_ui_RadioButtonGroup(tolua_S); lua_register_cocos2dx_ui_ScrollView(tolua_S); lua_register_cocos2dx_ui_ListView(tolua_S); + lua_register_cocos2dx_ui_RichElementNewLine(tolua_S); lua_register_cocos2dx_ui_LayoutComponent(tolua_S); lua_register_cocos2dx_ui_Button(tolua_S); lua_register_cocos2dx_ui_LayoutParameter(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 0730c1684c..8bafd19d26 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -629,6 +629,9 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + From d0c3275281d03ae319d076a30972ac5fd7512531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=B3=B0?= Date: Thu, 19 Nov 2015 13:33:05 +0800 Subject: [PATCH 094/192] Change version in change log --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e1d11ab98c..4aef9877b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -cocos2d-x-3.9 beta0 October.20 2015 +cocos2d-x-3.9 November.09 2015 [NEW] Label: Added line spacing/leading feature to Label. [NEW] ListView: Added APIs to scroll to specific item in list. From 32f21ca5be99ac21cbb879585e9d94feac85f631 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 19 Nov 2015 14:31:39 +0800 Subject: [PATCH 095/192] Binding ResouceData structure to js to fix auto compile error --- .../manual/js_manual_conversions.cpp | 41 +++++++++++++++++++ .../manual/js_manual_conversions.h | 6 +++ tools/bindings-generator | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index 24097f76b9..3a9908949c 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -27,6 +27,7 @@ #include "js_manual_conversions.h" #include "cocos2d_specifics.hpp" #include "math/TransformUtils.h" +#include "2d/CocosStudioExtension.h" USING_NS_CC; @@ -2865,3 +2866,43 @@ jsval std_map_string_string_to_jsval(JSContext* cx, const std::maptype = (int)t; + ret->file = file; + ret->plist = plist; + return true; +} + +jsval resoucedata_to_jsval(JSContext* cx, const ResouceData& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "type", v.type, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "file", JS::RootedValue(cx, std_string_to_jsval(cx, v.file)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "plist", JS::RootedValue(cx, std_string_to_jsval(cx, v.plist)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index ae99be38f3..2161475794 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -34,6 +34,10 @@ #define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +NS_CC_BEGIN +struct CC_DLL ResouceData; +NS_CC_END + // just a simple utility to avoid mem leaking when using JSString class JSStringWrapper { @@ -110,6 +114,7 @@ bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, cocos2d::__ bool jsval_to_quaternion(JSContext *cx, JS::HandleValue vp, cocos2d::Quaternion* ret); bool jsval_to_obb(JSContext *cx, JS::HandleValue vp, cocos2d::OBB* ret); bool jsval_to_ray(JSContext *cx, JS::HandleValue vp, cocos2d::Ray* ret); +bool jsval_to_resoucedata(JSContext *cx, JS::HandleValue v, ResouceData* ret); // forward declaration js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); @@ -272,6 +277,7 @@ jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); jsval quaternion_to_jsval(JSContext* cx, const cocos2d::Quaternion& q); jsval meshVertexAttrib_to_jsval(JSContext* cx, const cocos2d::MeshVertexAttrib& q); jsval uniform_to_jsval(JSContext* cx, const cocos2d::Uniform* uniform); +jsval resoucedata_to_jsval(JSContext* cx, const ResouceData& v); template js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj); diff --git a/tools/bindings-generator b/tools/bindings-generator index 2318a1593d..a0fe326ea3 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 2318a1593d2d490a3860179acaf81a1bf867a36b +Subproject commit a0fe326ea3d685d342ba2a61c0be6f9dee83f800 From f4d317f1fd3b6e78b2799c027703a7315b299fa1 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 19 Nov 2015 15:21:14 +0800 Subject: [PATCH 096/192] Combine Studio change for get program file full path. --- cocos/platform/win32/CCFileUtils-win32.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos/platform/win32/CCFileUtils-win32.cpp b/cocos/platform/win32/CCFileUtils-win32.cpp index ea3f9e6f12..3469b11e61 100644 --- a/cocos/platform/win32/CCFileUtils-win32.cpp +++ b/cocos/platform/win32/CCFileUtils-win32.cpp @@ -137,7 +137,13 @@ static void _checkPath() if (s_resourcePath.empty()) { WCHAR *pUtf16ExePath = nullptr; - _get_wpgmptr(&pUtf16ExePath); +#ifdef CC_STUDIO_ENABLED_VIEW + WCHAR utf16Path[CC_MAX_PATH] = { 0 }; + GetModuleFileNameW(NULL, utf16Path, CC_MAX_PATH - 1); + pUtf16ExePath = &(utf16Path[0]); +#else + _get_wpgmptr(&pUtf16ExePath); // CocoStudio Notice : This function won't work under studio, will cause a assert in system library +#endif // We need only directory part without exe WCHAR *pUtf16DirEnd = wcsrchr(pUtf16ExePath, L'\\'); From b6b35e0c7497cf06e60b8f9c5dacd1b5880ef825 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 19 Nov 2015 15:47:36 +0800 Subject: [PATCH 097/192] Fix name space. --- cocos/scripting/js-bindings/manual/js_manual_conversions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 2161475794..cd60c4d62c 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -114,7 +114,7 @@ bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, cocos2d::__ bool jsval_to_quaternion(JSContext *cx, JS::HandleValue vp, cocos2d::Quaternion* ret); bool jsval_to_obb(JSContext *cx, JS::HandleValue vp, cocos2d::OBB* ret); bool jsval_to_ray(JSContext *cx, JS::HandleValue vp, cocos2d::Ray* ret); -bool jsval_to_resoucedata(JSContext *cx, JS::HandleValue v, ResouceData* ret); +bool jsval_to_resoucedata(JSContext *cx, JS::HandleValue v, cocos2d::ResouceData* ret); // forward declaration js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); @@ -277,7 +277,7 @@ jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); jsval quaternion_to_jsval(JSContext* cx, const cocos2d::Quaternion& q); jsval meshVertexAttrib_to_jsval(JSContext* cx, const cocos2d::MeshVertexAttrib& q); jsval uniform_to_jsval(JSContext* cx, const cocos2d::Uniform* uniform); -jsval resoucedata_to_jsval(JSContext* cx, const ResouceData& v); +jsval resoucedata_to_jsval(JSContext* cx, const cocos2d::ResouceData& v); template js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj); From ccdb2a75f9e57fff72b67e6dbb6d7f2b9e88ab8d Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 19 Nov 2015 16:06:13 +0800 Subject: [PATCH 098/192] Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton --- cocos/2d/CCFontAtlas.cpp | 13 + cocos/2d/CCFontAtlas.h | 7 + cocos/2d/CCFontFNT.cpp | 28 +- cocos/2d/CCFontFNT.h | 6 +- cocos/2d/CCLabel.cpp | 378 +++++++-- cocos/2d/CCLabel.h | 81 +- cocos/2d/CCLabelTextFormatter.cpp | 137 +++- .../Classes/LabelTest/LabelTestNew.cpp | 731 ++++++++++++++++++ .../Classes/LabelTest/LabelTestNew.h | 120 +++ .../Resources/fonts/enligsh-chinese.fnt | 108 +++ .../Resources/fonts/enligsh-chinese.png | Bin 0 -> 79233 bytes 11 files changed, 1503 insertions(+), 106 deletions(-) create mode 100644 tests/cpp-tests/Resources/fonts/enligsh-chinese.fnt create mode 100644 tests/cpp-tests/Resources/fonts/enligsh-chinese.png diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index 8593a0f666..4dbb0f72d4 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -157,6 +157,19 @@ void FontAtlas::addLetterDefinition(char16_t utf16Char, const FontLetterDefiniti _letterDefinitions[utf16Char] = letterDefinition; } +void FontAtlas::scaleFontLetterDefinition(float scaleFactor) +{ + for (auto&& fontDefinition : _letterDefinitions) { + FontLetterDefinition letterDefinition = fontDefinition.second; + letterDefinition.width *= scaleFactor; + letterDefinition.height *= scaleFactor; + letterDefinition.offsetX *= scaleFactor; + letterDefinition.offsetY *= scaleFactor; + letterDefinition.xAdvance *= scaleFactor; + _letterDefinitions[fontDefinition.first] = letterDefinition; + } +} + bool FontAtlas::getLetterDefinitionForChar(char16_t utf16Char, FontLetterDefinition &letterDefinition) { auto outIterator = _letterDefinitions.find(utf16Char); diff --git a/cocos/2d/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h index 4e147aea96..433c47b705 100644 --- a/cocos/2d/CCFontAtlas.h +++ b/cocos/2d/CCFontAtlas.h @@ -115,6 +115,13 @@ protected: void conversionU16TOGB2312(const std::u16string& u16Text, std::unordered_map& charCodeMap); + /** + * Scale each font letter by scaleFactor. + * + * @param scaleFactor A float scale factor for scaling font letter info. + */ + void scaleFontLetterDefinition(float scaleFactor); + std::unordered_map _atlasTextures; std::unordered_map _letterDefinitions; float _lineHeight; diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp index 1a2ea333e9..4971d8d57e 100644 --- a/cocos/2d/CCFontFNT.cpp +++ b/cocos/2d/CCFontFNT.cpp @@ -119,6 +119,8 @@ public://@public // Character Set defines the letters that actually exist in the font std::set *_characterSet; + //! Font Size + int _fontSize; public: /** * @js ctor @@ -225,6 +227,7 @@ BMFontConfiguration::BMFontConfiguration() , _commonHeight(0) , _kerningDictionary(nullptr) , _characterSet(nullptr) +, _fontSize(0) { } @@ -539,7 +542,7 @@ void BMFontConfiguration::parseInfoArguments(const char* line) // info face="Script" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,4,3,2 spacing=0,0 outline=0 // info face="Cracked" size=36 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 ////////////////////////////////////////////////////////////////////////// - + sscanf(strstr(line, "size=") + 5, "%d", &_fontSize); // padding sscanf(strstr(line,"padding=") + 8, "%d,%d,%d,%d", &_padding.top, &_padding.right, &_padding.bottom, &_padding.left); //CCLOG("cocos2d: padding: %d,%d,%d,%d", _padding.left, _padding.top, _padding.right, _padding.bottom); @@ -647,7 +650,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Vec2& imageOffse } FontFNT *tempFont = new FontFNT(newConf,imageOffset); - + tempFont->setFontSize(newConf->_fontSize); if (!tempFont) { return nullptr; @@ -716,6 +719,16 @@ int FontFNT::getHorizontalKerningForChars(unsigned short firstChar, unsigned sh return ret; } +void FontFNT::setFontSize(float fontSize) +{ + _fontSize = fontSize; +} + +int FontFNT::getOriginalFontSize()const +{ + return _configuration->_fontSize; +} + FontAtlas * FontFNT::createFontAtlas() { FontAtlas *tempAtlas = new (std::nothrow) FontAtlas(*this); @@ -734,7 +747,16 @@ FontAtlas * FontFNT::createFontAtlas() return nullptr; // common height - tempAtlas->setLineHeight(_configuration->_commonHeight); + int originalFontSize = _configuration->_fontSize; + float originalLineHeight = _configuration->_commonHeight; + float factor = 0.0f; + if (fabs(_fontSize - originalFontSize) < FLT_EPSILON) { + factor = 1.0f; + }else { + factor = _fontSize / originalFontSize; + } + + tempAtlas->setLineHeight(originalLineHeight * factor); BMFontDef fontDef; diff --git a/cocos/2d/CCFontFNT.h b/cocos/2d/CCFontFNT.h index d2b83e9886..ba734ae1e9 100644 --- a/cocos/2d/CCFontFNT.h +++ b/cocos/2d/CCFontFNT.h @@ -46,7 +46,8 @@ public: static void purgeCachedData(); virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override; virtual FontAtlas *createFontAtlas() override; - + void setFontSize(float fontSize); + int getOriginalFontSize()const; protected: FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset = Vec2::ZERO); @@ -62,7 +63,8 @@ private: BMFontConfiguration * _configuration; Vec2 _imageOffset; - + //User defined font size + float _fontSize; }; /// @endcond diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 638a51704c..074d7efc23 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -39,6 +39,7 @@ #include "base/CCEventListenerCustom.h" #include "base/CCEventDispatcher.h" #include "base/CCEventCustom.h" +#include "2d/CCFontFNT.h" NS_CC_BEGIN @@ -472,6 +473,12 @@ void Label::reset() _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _isOpacityModifyRGB = false; _insideBounds = true; + _enableWrap = true; + _bmFontSize = -1; + _bmfontScale = 1.0f; + _overflow = Overflow::NORMAL; + _originalFontSize = 0.0f; + } void Label::updateShaderProgram() @@ -548,46 +555,37 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false * bool Label::setTTFConfig(const TTFConfig& ttfConfig) { - FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(&ttfConfig); - - if (!newAtlas) - { - reset(); - return false; - } - _systemFontDirty = false; - - _currentLabelType = LabelType::TTF; - setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true); - - _fontConfig = ttfConfig; - if (_fontConfig.outlineSize > 0) - { - _fontConfig.distanceFieldEnabled = false; - _useDistanceField = false; - _useA8Shader = false; - _currLabelEffect = LabelEffect::OUTLINE; - updateShaderProgram(); - } - else - { - _currLabelEffect = LabelEffect::NORMAL; - updateShaderProgram(); - } - - return true; + _originalFontSize = ttfConfig.fontSize; + return setTTFConfigInternal(ttfConfig); } -bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset /* = Vec2::ZERO */) +bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset, float fontSize) { FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset); - + if (!newAtlas) { reset(); return false; } + + //asign the default fontSize + if (fabs(fontSize) < FLT_EPSILON) { + FontFNT *bmFont = (FontFNT*)newAtlas->getFont(); + if (bmFont) { + float originalFontSize = bmFont->getOriginalFontSize(); + if(fabs(_bmFontSize+1) < FLT_EPSILON){ + _bmFontSize = originalFontSize / CC_CONTENT_SCALE_FACTOR(); + } + } + } + + if(fontSize > 0){ + _bmFontSize = fontSize; + } + _bmFontPath = bmfontFilePath; + _currentLabelType = LabelType::BMFONT; setFontAtlas(newAtlas); @@ -631,6 +629,9 @@ void Label::setMaxLineWidth(float maxLineWidth) void Label::setDimensions(float width, float height) { + if(_overflow == Overflow::RESIZE_HEIGHT){ + height = 0; + } if (height != _labelHeight || width != _labelWidth) { _labelWidth = width; @@ -640,7 +641,26 @@ void Label::setDimensions(float width, float height) _maxLineWidth = width; _contentDirty = true; - } + + if(_overflow == Overflow::SHRINK){ + if (_originalFontSize > 0) { + this->restoreFontSize(); + } + } + } +} + +void Label::restoreFontSize() +{ + if(_currentLabelType == LabelType::TTF){ + auto ttfConfig = this->getTTFConfig(); + ttfConfig.fontSize = _originalFontSize; + this->setTTFConfigInternal(ttfConfig); + }else if(_currentLabelType == LabelType::BMFONT){ + this->setBMFontSizeInternal(_originalFontSize); + }else if(_currentLabelType == LabelType::STRING_TEXTURE){ + this->setSystemFontSize(_originalFontSize); + } } void Label::setLineBreakWithoutSpace(bool breakWithoutSpace) @@ -695,61 +715,94 @@ void Label::updateLabelLetters() auto py = letterInfo.positionY - letterDef.height / 2 + _letterOffsetY; letterSprite->setPosition(px, py); + if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0) { + _reusedLetter->setScale(_bmfontScale); + }else{ + if(fabs(_bmFontSize)setScale(0); + }else{ + _reusedLetter->setScale(1.0); + } + } ++it; } } } } -void Label::alignText() +bool Label::alignText() { if (_fontAtlas == nullptr || _utf16Text.empty()) { setContentSize(Size::ZERO); - return; + return true; } - _fontAtlas->prepareLetterDefinitions(_utf16Text); - auto& textures = _fontAtlas->getTextures(); - if (textures.size() > _batchNodes.size()) - { - for (auto index = _batchNodes.size(); index < textures.size(); ++index) + bool ret = true; + do { + _fontAtlas->prepareLetterDefinitions(_utf16Text); + auto& textures = _fontAtlas->getTextures(); + if (textures.size() > _batchNodes.size()) { - auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index)); - if (batchNode) + for (auto index = _batchNodes.size(); index < textures.size(); ++index) { - _isOpacityModifyRGB = batchNode->getTexture()->hasPremultipliedAlpha(); - _blendFunc = batchNode->getBlendFunc(); - batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); - batchNode->setPosition(Vec2::ZERO); - _batchNodes.pushBack(batchNode); + auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index)); + if (batchNode) + { + _isOpacityModifyRGB = batchNode->getTexture()->hasPremultipliedAlpha(); + _blendFunc = batchNode->getBlendFunc(); + batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); + batchNode->setPosition(Vec2::ZERO); + _batchNodes.pushBack(batchNode); + } } } - } - if (_batchNodes.empty()) - { - return; - } - _reusedLetter->setBatchNode(_batchNodes.at(0)); + if (_batchNodes.empty()) + { + return true; + } + _reusedLetter->setBatchNode(_batchNodes.at(0)); + + _lengthOfString = 0; + _textDesiredHeight = 0.f; + _linesWidth.clear(); + if (_maxLineWidth > 0.f && !_lineBreakWithoutSpaces) + { + multilineTextWrapByWord(); + } + else + { + multilineTextWrapByChar(); + } + computeAlignmentOffset(); - _lengthOfString = 0; - _textDesiredHeight = 0.f; - _linesWidth.clear(); - if (_maxLineWidth > 0.f && !_lineBreakWithoutSpaces) - { - multilineTextWrapByWord(); - } - else - { - multilineTextWrapByChar(); - } - computeAlignmentOffset(); + if(_enableWrap && _overflow == Overflow::SHRINK){ + float fontSize = 0; + if (_currentLabelType == LabelType::BMFONT) { + fontSize = _bmFontSize; + }else if(_currentLabelType == LabelType::TTF){ + fontSize = this->getTTFConfig().fontSize; + } - updateQuads(); + if(fontSize > 0 && isVerticalClamp()){ + this->shrinkLabelToContentSize(CC_CALLBACK_0(Label::isVerticalClamp, this)); + } + } - updateLabelLetters(); + if(!updateQuads()){ + ret = false; + if(!_enableWrap && _overflow == Overflow::SHRINK){ + this->shrinkLabelToContentSize(CC_CALLBACK_0(Label::isHorizontalClamp, this)); + } + break; + } + + updateLabelLetters(); + + updateColor(); + }while (0); - updateColor(); + return ret; } bool Label::computeHorizontalKernings(const std::u16string& stringToRender) @@ -769,13 +822,15 @@ bool Label::computeHorizontalKernings(const std::u16string& stringToRender) return true; } -void Label::updateQuads() +bool Label::updateQuads() { + bool ret = true; for (auto&& batchNode : _batchNodes) { batchNode->getTextureAtlas()->removeAllQuads(); } + bool letterClamp = false; for (int ctr = 0; ctr < _lengthOfString; ++ctr) { if (_lettersInfo[ctr].valid) @@ -802,16 +857,114 @@ void Label::updateQuads() } } + if(!_enableWrap){ + auto px = _lettersInfo[ctr].positionX + letterDef.width/2; + if(_labelWidth > 0.f){ + if (px > _contentSize.width) { + if(_overflow == Overflow::CLAMP){ + _reusedRect.size.width = 0; + }else if(_overflow == Overflow::SHRINK){ + if (letterDef.width > 0 + && _contentSize.width > letterDef.width) { + letterClamp = true; + ret = false; + break; + }else{ + //clamp + _reusedRect.size.width = 0; + } + + } + } + } + } + if (_reusedRect.size.height > 0.f && _reusedRect.size.width > 0.f) { _reusedLetter->setTextureRect(_reusedRect, false, _reusedRect.size); _reusedLetter->setPosition(_lettersInfo[ctr].positionX + _linesOffsetX[_lettersInfo[ctr].lineIndex], py); auto index = static_cast(_batchNodes.at(letterDef.textureID)->getTextureAtlas()->getTotalQuads()); _lettersInfo[ctr].atlasIndex = index; + + if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0) { + _reusedLetter->setScale(_bmfontScale); + }else{ + if(fabs(_bmFontSize)setScale(0); + }else{ + _reusedLetter->setScale(1.0); + } + } + _batchNodes.at(letterDef.textureID)->insertQuadFromSprite(_reusedLetter, index); } } } + + + return ret; +} + +bool Label::setTTFConfigInternal(const TTFConfig& ttfConfig) +{ + FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(&ttfConfig); + + if (!newAtlas) + { + reset(); + return false; + } + _systemFontDirty = false; + + _currentLabelType = LabelType::TTF; + setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true); + + _fontConfig = ttfConfig; + + if (_fontConfig.outlineSize > 0) + { + _fontConfig.distanceFieldEnabled = false; + _useDistanceField = false; + _useA8Shader = false; + _currLabelEffect = LabelEffect::OUTLINE; + updateShaderProgram(); + } + else + { + _currLabelEffect = LabelEffect::NORMAL; + updateShaderProgram(); + } + return true; +} + +void Label::setBMFontSizeInternal(float fontSize) +{ + if(_currentLabelType == LabelType::BMFONT){ + this->setBMFontFilePath(_bmFontPath, Vec2::ZERO, fontSize); + _contentDirty = true; + } +} + +void Label::scaleFontSizeDown(float fontSize) +{ + bool shouldUpdateContent = true; + if(_currentLabelType == LabelType::TTF){ + auto ttfConfig = this->getTTFConfig(); + ttfConfig.fontSize = fontSize; + this->setTTFConfigInternal(ttfConfig); + }else if(_currentLabelType == LabelType::BMFONT){ + if (fabs(fontSize) < FLT_EPSILON) { + fontSize = 0.1f; + shouldUpdateContent = false; + } + this->setBMFontSizeInternal(fontSize); + }else if (_currentLabelType == LabelType::STRING_TEXTURE){ + this->setSystemFontSize(fontSize); + } + + if (shouldUpdateContent) { + this->updateContent(); + } } void Label::enableGlow(const Color4B& glowColor) @@ -1102,6 +1255,7 @@ void Label::updateContent() CC_SAFE_RELEASE_NULL(_textSprite); CC_SAFE_RELEASE_NULL(_shadowNode); + bool updateFinished = true; if (_fontAtlas) { @@ -1112,7 +1266,7 @@ void Label::updateContent() } computeHorizontalKernings(_utf16Text); - alignText(); + updateFinished = alignText(); } else { @@ -1123,7 +1277,9 @@ void Label::updateContent() createShadowSpriteForSystemFont(fontDef); } } - _contentDirty = false; + if(updateFinished){ + _contentDirty = false; + } #if CC_LABEL_DEBUG_DRAW _debugDrawNode->clear(); @@ -1138,6 +1294,17 @@ void Label::updateContent() #endif } +void Label::setBMFontSize(float fontSize) +{ + this->setBMFontSizeInternal(fontSize); + _originalFontSize = fontSize; +} + +float Label::getBMFontSize()const +{ + return _bmFontSize; +} + void Label::onDrawShadow(GLProgram* glProgram) { if (_currentLabelType == LabelType::TTF) @@ -1381,6 +1548,7 @@ void Label::setSystemFontSize(float fontSize) if (_systemFontSize != fontSize) { _systemFontSize = fontSize; + _originalFontSize = fontSize; _systemFontDirty = true; } } @@ -1468,16 +1636,16 @@ float Label::getLineHeight() const void Label::setLineSpacing(float height) { - if (_lineSpacing != height) - { - _lineSpacing = height; - _contentDirty = true; - } + if (_lineSpacing != height) + { + _lineSpacing = height; + _contentDirty = true; + } } float Label::getLineSpacing() const { - return _lineSpacing; + return _lineSpacing; } void Label::setAdditionalKerning(float space) @@ -1753,4 +1921,64 @@ void Label::setGlobalZOrder(float globalZOrder) } } +float Label::getRenderingFontSize()const +{ + float fontSize; + if (_currentLabelType == LabelType::BMFONT) { + fontSize = _bmFontSize; + }else if(_currentLabelType == LabelType::TTF){ + fontSize = this->getTTFConfig().fontSize; + }else if(_currentLabelType == LabelType::STRING_TEXTURE){ + fontSize = _systemFontSize; + }else{ //FIXME: find a way to caculate char map font size + fontSize = this->getLineHeight(); + } + return fontSize; +} + +void Label::enableWrap(bool enable) +{ + if(enable == _enableWrap || _overflow == Overflow::RESIZE_HEIGHT + || _currentLabelType == LabelType::STRING_TEXTURE){ + return; + } + + this->_enableWrap = enable; + auto renderingFontSize = this->getRenderingFontSize(); + if (fabs(_originalFontSize - renderingFontSize) >= 1) { + this->scaleFontSizeDown(_originalFontSize); + } + + _contentDirty = true; +} + +bool Label::isWrapEnabled()const +{ + return this->_enableWrap; +} + +void Label::setOverflow(Overflow overflow) +{ + if(_overflow == overflow || _currentLabelType == LabelType::CHARMAP){ + return; + } + + if(overflow == Overflow::RESIZE_HEIGHT){ + this->setDimensions(_labelDimensions.width,0); + this->enableWrap(true); + } + _overflow = overflow; + + auto renderingFontSize = this->getRenderingFontSize(); + if (fabs(_originalFontSize - renderingFontSize) >= 1) { + this->scaleFontSizeDown(_originalFontSize); + } + _contentDirty = true; +} + +Label::Overflow Label::getOverflow()const +{ + return _overflow; +} + NS_CC_END diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index e54ec0ee6b..c5884c926e 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -95,6 +95,23 @@ class EventListenerCustom; class CC_DLL Label : public Node, public LabelProtocol, public BlendProtocol { public: + enum class Overflow + { + //for keep back compatibility + NORMAL, + /** + * In SHRINK mode, the font size will change dynamically to adapt the content size. + */ + SHRINK, + /** + *In CLAMP mode, when label content goes out of the bounding box, it will be clipped. + */ + CLAMP, + /** + *In RESIZE_HEIGHT mode, you can only change the width of label and the height is changed automatically. + */ + RESIZE_HEIGHT + }; /// @name Creators /// @{ @@ -221,7 +238,7 @@ public: virtual const TTFConfig& getTTFConfig() const { return _fontConfig;} /** Sets a new bitmap font to Label */ - virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO); + virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO, float fontSize = 0); /** Returns the bitmap font used by the Label.*/ const std::string& getBMFontFilePath() const { return _bmFontPath;} @@ -366,12 +383,53 @@ public: */ void setMaxLineWidth(float maxLineWidth); float getMaxLineWidth() { return _maxLineWidth; } + /** + * Change font size of label type BMFONT + * Note: This function only scale the BMFONT letter to mimic the font size change effect. + * + * @param fontSize The desired font size in float. + */ + void setBMFontSize(float fontSize); + /** + * Return the user define BMFont size. + * + * @return The BMFont size in float value. + */ + float getBMFontSize()const; + + /** + * Toggle wrap option the label. + * Note: System font doesn't support manually toggle wrap. + * + * @param enable Set true to enable wrap and false to disable wrap. + */ + void enableWrap(bool enable); + + /** + * Query the wrap is enabled or not. + * Note: System font will always return true. + */ + bool isWrapEnabled()const; + + /** + * Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type. + * + * @param overflow see `Overflow` + */ + void setOverflow(Overflow overflow); + + /** + * Query the label's Overflow type. + * + * @return see `Overflow` + */ + Overflow getOverflow()const; /** * Makes the Label exactly this untransformed width. * * The Label's width be used for text align if the value not equal zero. - */ + */ void setWidth(float width) { setDimensions(width,_labelHeight);} float getWidth() const { return _labelWidth; } @@ -508,21 +566,30 @@ protected: bool multilineTextWrapByChar(); bool multilineTextWrapByWord(); + void shrinkLabelToContentSize(std::function lambda); + bool isHorizontalClamp(); + bool isVerticalClamp(); + float getRenderingFontSize()const; void updateLabelLetters(); - virtual void alignText(); + virtual bool alignText(); void computeAlignmentOffset(); bool computeHorizontalKernings(const std::u16string& stringToRender); void recordLetterInfo(const cocos2d::Vec2& point, char16_t utf16Char, int letterIndex, int lineIndex); void recordPlaceholderInfo(int letterIndex, char16_t utf16Char); - void updateQuads(); + bool updateQuads(); void createSpriteForSystemFont(const FontDefinition& fontDef); void createShadowSpriteForSystemFont(const FontDefinition& fontDef); virtual void updateShaderProgram(); + void updateBMFontScale(); + void scaleFontSizeDown(float fontSize); + bool setTTFConfigInternal(const TTFConfig& ttfConfig); + void setBMFontSizeInternal(float fontSize); + void restoreFontSize(); void reset(); @@ -614,6 +681,12 @@ protected: #if CC_LABEL_DEBUG_DRAW DrawNode* _debugDrawNode; #endif + + bool _enableWrap; + float _bmFontSize; + float _bmfontScale; + Overflow _overflow; + float _originalFontSize; private: CC_DISALLOW_COPY_AND_ASSIGN(Label); }; diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index b83748f996..cc22d83b8c 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -28,6 +28,7 @@ #include "base/ccUTF8.h" #include "base/CCDirector.h" #include "2d/CCFontAtlas.h" +#include "2d/CCFontFNT.h" NS_CC_BEGIN @@ -93,6 +94,18 @@ static int getFirstWordLen(const std::u16string& utf16Text, int startIndex, int return len; } +void Label::updateBMFontScale() +{ + auto font = _fontAtlas->getFont(); + if (_currentLabelType == LabelType::BMFONT) { + FontFNT *bmFont = (FontFNT*)font; + float originalFontSize = bmFont->getOriginalFontSize(); + _bmfontScale = _bmFontSize * CC_CONTENT_SCALE_FACTOR() / originalFontSize; + }else{ + _bmfontScale = 1.0f; + } +} + bool Label::multilineTextWrapByWord() { int textLen = getStringLength(); @@ -108,7 +121,9 @@ bool Label::multilineTextWrapByWord() float lowestY = 0.f; FontLetterDefinition letterDef; Vec2 letterPosition; - + + this->updateBMFontScale(); + for (int index = 0; index < textLen; ) { auto character = _utf16Text[index]; @@ -118,7 +133,7 @@ bool Label::multilineTextWrapByWord() letterRight = 0.f; lineIndex++; nextWordX = 0.f; - nextWordY -= _lineHeight + lineSpacing; + nextWordY -= _lineHeight*_bmfontScale + lineSpacing; recordPlaceholderInfo(index, character); index++; continue; @@ -146,14 +161,14 @@ bool Label::multilineTextWrapByWord() continue; } - auto letterX = (nextLetterX + letterDef.offsetX) / contentScaleFactor; - if (_maxLineWidth > 0.f && nextWordX > 0.f && letterX + letterDef.width > _maxLineWidth) + auto letterX = (nextLetterX + letterDef.offsetX * _bmfontScale) / contentScaleFactor; + if (_enableWrap && _maxLineWidth > 0.f && nextWordX > 0.f && letterX + letterDef.width * _bmfontScale > _maxLineWidth) { _linesWidth.push_back(letterRight); letterRight = 0.f; lineIndex++; nextWordX = 0.f; - nextWordY -= _lineHeight + lineSpacing; + nextWordY -= (_lineHeight*_bmfontScale + lineSpacing); newLine = true; break; } @@ -161,19 +176,19 @@ bool Label::multilineTextWrapByWord() { letterPosition.x = letterX; } - letterPosition.y = (nextWordY - letterDef.offsetY) / contentScaleFactor; + letterPosition.y = (nextWordY - letterDef.offsetY * _bmfontScale) / contentScaleFactor; recordLetterInfo(letterPosition, character, letterIndex, lineIndex); if (_horizontalKernings && letterIndex < textLen - 1) nextLetterX += _horizontalKernings[letterIndex + 1]; - nextLetterX += letterDef.xAdvance + _additionalKerning; + nextLetterX += letterDef.xAdvance * _bmfontScale + _additionalKerning; - wordRight = letterPosition.x + letterDef.width; + wordRight = letterPosition.x + letterDef.width * _bmfontScale; if (wordHighestY < letterPosition.y) wordHighestY = letterPosition.y; - if (wordLowestY > letterPosition.y - letterDef.height) - wordLowestY = letterPosition.y - letterDef.height; + if (wordLowestY > letterPosition.y - letterDef.height * _bmfontScale) + wordLowestY = letterPosition.y - letterDef.height * _bmfontScale; } if (newLine) @@ -196,7 +211,7 @@ bool Label::multilineTextWrapByWord() _linesWidth.push_back(letterRight); _numberOfLines = lineIndex + 1; - _textDesiredHeight = (_numberOfLines * _lineHeight) / contentScaleFactor; + _textDesiredHeight = (_numberOfLines * _lineHeight * _bmfontScale) / contentScaleFactor; if (_numberOfLines > 1) _textDesiredHeight += (_numberOfLines - 1) * _lineSpacing; Size contentSize(_labelWidth, _labelHeight); @@ -232,6 +247,8 @@ bool Label::multilineTextWrapByChar() FontLetterDefinition letterDef; Vec2 letterPosition; + this->updateBMFontScale(); + for (int index = 0; index < textLen; index++) { auto character = _utf16Text[index]; @@ -246,7 +263,7 @@ bool Label::multilineTextWrapByChar() letterRight = 0.f; lineIndex++; nextLetterX = 0.f; - nextLetterY -= _lineHeight + lineSpacing; + nextLetterY -= _lineHeight * _bmfontScale + lineSpacing; recordPlaceholderInfo(index, character); continue; } @@ -258,33 +275,33 @@ bool Label::multilineTextWrapByChar() continue; } - auto letterX = (nextLetterX + letterDef.offsetX) / contentScaleFactor; - if (_maxLineWidth > 0.f && nextLetterX > 0.f && letterX + letterDef.width > _maxLineWidth) + auto letterX = (nextLetterX + letterDef.offsetX * _bmfontScale) / contentScaleFactor; + if (_enableWrap && _maxLineWidth > 0.f && nextLetterX > 0.f && letterX + letterDef.width * _bmfontScale > _maxLineWidth) { _linesWidth.push_back(letterRight); letterRight = 0.f; lineIndex++; nextLetterX = 0.f; - nextLetterY -= _lineHeight + lineSpacing; - letterPosition.x = letterDef.offsetX / contentScaleFactor; + nextLetterY -= _lineHeight * _bmfontScale + lineSpacing; + letterPosition.x = letterDef.offsetX * _bmfontScale / contentScaleFactor; } else { letterPosition.x = letterX; } - letterPosition.y = (nextLetterY - letterDef.offsetY) / contentScaleFactor; + letterPosition.y = (nextLetterY - letterDef.offsetY * _bmfontScale) / contentScaleFactor; recordLetterInfo(letterPosition, character, index, lineIndex); if (_horizontalKernings && index < textLen - 1) nextLetterX += _horizontalKernings[index + 1]; - nextLetterX += letterDef.xAdvance + _additionalKerning; + nextLetterX += letterDef.xAdvance * _bmfontScale + _additionalKerning; - letterRight = letterPosition.x + letterDef.width; + letterRight = letterPosition.x + letterDef.width * _bmfontScale; if (highestY < letterPosition.y) highestY = letterPosition.y; - if (lowestY > letterPosition.y - letterDef.height) - lowestY = letterPosition.y - letterDef.height; + if (lowestY > letterPosition.y - letterDef.height * _bmfontScale) + lowestY = letterPosition.y - letterDef.height * _bmfontScale; if (longestLine < letterRight) longestLine = letterRight; } @@ -292,7 +309,7 @@ bool Label::multilineTextWrapByChar() _linesWidth.push_back(letterRight); _numberOfLines = lineIndex + 1; - _textDesiredHeight = (_numberOfLines * _lineHeight) / contentScaleFactor; + _textDesiredHeight = (_numberOfLines * _lineHeight * _bmfontScale) / contentScaleFactor; if (_numberOfLines > 1) _textDesiredHeight += (_numberOfLines - 1) * _lineSpacing; Size contentSize(_labelWidth, _labelHeight); @@ -300,6 +317,7 @@ bool Label::multilineTextWrapByChar() contentSize.width = longestLine; if (_labelHeight <= 0.f) contentSize.height = _textDesiredHeight; + setContentSize(contentSize); _tailoredTopY = contentSize.height; @@ -312,6 +330,81 @@ bool Label::multilineTextWrapByChar() return true; } +bool Label::isVerticalClamp() +{ + if (_textDesiredHeight > _contentSize.height) + { + return true; + } + else + { + return false; + } +} + +bool Label::isHorizontalClamp() +{ + bool letterClamp = false; + for (int ctr = 0; ctr < _lengthOfString; ++ctr) + { + if (_lettersInfo[ctr].valid) + { + auto& letterDef = _fontAtlas->_letterDefinitions[_lettersInfo[ctr].utf16Char]; + + auto px = _lettersInfo[ctr].positionX + letterDef.width/2; + if(_labelWidth > 0.f){ + if (px > _contentSize.width) { + letterClamp = true; + break; + } + } + } + } + + return letterClamp; +} + +void Label::shrinkLabelToContentSize(std::function lambda) +{ + float fontSize = this->getRenderingFontSize(); + + int i = 0; + auto letterDefinition = _fontAtlas->_letterDefinitions; + auto tempLetterDefinition = letterDefinition; + float originalLineHeight = this->getLineHeight(); + bool flag = true; + while (lambda()) { + ++i; + float newFontSize = fontSize - i; + flag = false; + if (newFontSize <= 0) { + break; + } + float scale = newFontSize / fontSize; + std::swap(_fontAtlas->_letterDefinitions, tempLetterDefinition); + _fontAtlas->scaleFontLetterDefinition(scale); + this->setLineHeight(originalLineHeight * scale); + if (_maxLineWidth > 0.f && !_lineBreakWithoutSpaces) + { + multilineTextWrapByWord(); + } + else + { + multilineTextWrapByChar(); + } + computeAlignmentOffset(); + tempLetterDefinition = letterDefinition; + } + this->setLineHeight(originalLineHeight); + std::swap(_fontAtlas->_letterDefinitions, letterDefinition); + + if (!flag) { + if (fontSize - i >= 0) { + this->scaleFontSizeDown(fontSize - i); + } + } +} + void Label::recordLetterInfo(const cocos2d::Vec2& point, char16_t utf16Char, int letterIndex, int lineIndex) { if (static_cast(letterIndex) >= _lettersInfo.size()) diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index effdf3d436..09d7300e61 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -5,6 +5,7 @@ USING_NS_CC; using namespace ui; +using namespace extension; enum { kTagTileMap = 1, @@ -88,6 +89,14 @@ NewLabelTests::NewLabelTests() ADD_TEST_CASE(LabelIssue10688Test); ADD_TEST_CASE(LabelIssue13202Test); ADD_TEST_CASE(LabelIssue9500Test); + ADD_TEST_CASE(LabelWrapByWordTest); + ADD_TEST_CASE(LabelWrapByCharTest); + ADD_TEST_CASE(LabelShrinkByWordTest); + ADD_TEST_CASE(LabelShrinkByCharTest); + ADD_TEST_CASE(LabelResizeTest); + ADD_TEST_CASE(LabelToggleTypeTest); + ADD_TEST_CASE(LabelSystemFontTest); + ADD_TEST_CASE(LabelCharMapFontTest); }; LabelFNTColorAndOpacity::LabelFNTColorAndOpacity() @@ -2003,3 +2012,725 @@ std::string LabelIssue9500Test::subtitle() const { return "Spaces should not be lost if label created with Fingerpop.ttf"; } + +ControlStepper *LabelLayoutBaseTest::makeControlStepper() +{ + auto minusSprite = Sprite::create("extensions/stepper-minus.png"); + auto plusSprite = Sprite::create("extensions/stepper-plus.png"); + + return ControlStepper::create(minusSprite, plusSprite); +} + +LabelLayoutBaseTest::LabelLayoutBaseTest() +{ + auto size = Director::getInstance()->getVisibleSize(); + + this->initTestLabel(size); + + this->initFontSizeChange(size); + this->initToggleLabelTypeOption(size); + + this->initWrapOption(size); + + this->initAlignmentOption(size); + + this->initDrawNode(size); + + this->initSliders(size); +} + +void LabelLayoutBaseTest::initFontSizeChange(const cocos2d::Size& size) +{ + auto fontSizeLabel = Label::createWithSystemFont("font size:20", "Arial", 10); + fontSizeLabel->setName("fontSize"); + + ControlStepper *stepper = this->makeControlStepper(); + stepper->setPosition(size.width * 0.5 - stepper->getContentSize().width / 2, + size.height * 0.8); + stepper->setValue(20); + stepper->addTargetWithActionForControlEvents(this, + cccontrol_selector(LabelLayoutBaseTest::valueChanged), + Control::EventType::VALUE_CHANGED); + this->addChild(stepper); + stepper->setName("stepper"); + stepper->setScale(0.5); + + fontSizeLabel->setPosition(stepper->getPosition() - + Vec2(stepper->getContentSize().width/2 + fontSizeLabel->getContentSize().width/2,0)); + this->addChild(fontSizeLabel); +} + +void LabelLayoutBaseTest::initWrapOption(const cocos2d::Size& size) +{ + auto label = Label::createWithSystemFont("Enable Wrap:", "Arial", 10); + label->setColor(Color3B::WHITE); + label->setPosition(Vec2(size.width * 0.8f - 100, size.height * 0.8f)); + this->addChild(label); + + CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", + "cocosui/check_box_normal_press.png", + "cocosui/check_box_active.png", + "cocosui/check_box_normal_disable.png", + "cocosui/check_box_active_disable.png"); + checkBox->setPosition(Vec2(size.width * 0.8f - 55, size.height * 0.8f)); + checkBox->setScale(0.5); + checkBox->setSelected(true); + checkBox->setName("toggleWrap"); + + checkBox->addEventListener([=](Ref* ref, CheckBox::EventType event){ + if (event == CheckBox::EventType::SELECTED) { + _label->enableWrap(true); + }else{ + _label->enableWrap(false); + } + this->updateDrawNodeSize(_label->getContentSize()); + }); + this->addChild(checkBox); +} + +void LabelLayoutBaseTest::initToggleLabelTypeOption(const cocos2d::Size& size) +{ + auto label = Label::createWithSystemFont("Toggle Label Type:", "Arial", 10); + label->setColor(Color3B::WHITE); + label->setPosition(Vec2(size.width * 0.8f + 15, size.height * 0.8f)); + this->addChild(label); + + CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", + "cocosui/check_box_normal_press.png", + "cocosui/check_box_active.png", + "cocosui/check_box_normal_disable.png", + "cocosui/check_box_active_disable.png"); + checkBox->setPosition(Vec2(size.width * 0.8f + 70, size.height * 0.8f)); + checkBox->setScale(0.5); + checkBox->setName("toggleType"); + checkBox->setSelected(true); + + auto stepper = (ControlStepper*)this->getChildByName("stepper"); + + checkBox->addEventListener([=](Ref* ref, CheckBox::EventType event){ + float fontSize = stepper->getValue(); + + if (event == CheckBox::EventType::SELECTED) { + _labelType = 0; + auto ttfConfig = _label->getTTFConfig(); + ttfConfig.fontSize = fontSize; + _label->setTTFConfig(ttfConfig); + }else{ + _labelType = 1; + _label->setBMFontFilePath("fonts/enligsh-chinese.fnt"); + _label->setBMFontSize(fontSize); + } + }); + this->addChild(checkBox); + +} + +void LabelLayoutBaseTest::initAlignmentOption(const cocos2d::Size& size) +{ + //add text alignment settings + MenuItemFont::setFontSize(30); + auto menu = Menu::create( + MenuItemFont::create("Left", CC_CALLBACK_1(LabelLayoutBaseTest::setAlignmentLeft, this)), + MenuItemFont::create("Center", CC_CALLBACK_1(LabelLayoutBaseTest::setAlignmentCenter, this)), + MenuItemFont::create("Right", CC_CALLBACK_1(LabelLayoutBaseTest::setAlignmentRight, this)), + nullptr); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(Vec2(50, size.height / 2 - 20)); + this->addChild(menu); + + menu = Menu::create( + MenuItemFont::create("Top", CC_CALLBACK_1(LabelLayoutBaseTest::setAlignmentTop, this)), + MenuItemFont::create("Middle", CC_CALLBACK_1(LabelLayoutBaseTest::setAlignmentMiddle, this)), + MenuItemFont::create("Bottom", CC_CALLBACK_1(LabelLayoutBaseTest::setAlignmentBottom, this)), + nullptr); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(Vec2(size.width - 50, size.height / 2 - 20)); + this->addChild(menu); +} + +void LabelLayoutBaseTest::initSliders(const cocos2d::Size& size) +{ + auto slider = ui::Slider::create(); + slider->setTag(1); + slider->setTouchEnabled(true); + slider->loadBarTexture("cocosui/sliderTrack.png"); + slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); + slider->loadProgressBarTexture("cocosui/sliderProgress.png"); + slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getContentSize().height * 2.0f - 5)); + slider->setPercent(52); + addChild(slider); + + auto slider2 = ui::Slider::create(); + slider2->setTag(2); + slider2->setTouchEnabled(true); + slider2->loadBarTexture("cocosui/sliderTrack.png"); + slider2->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); + slider2->loadProgressBarTexture("cocosui/sliderProgress.png"); + slider2->setPosition(Vec2(size.width * 0.2f, size.height / 2.0)); + slider2->setRotation(90); + slider2->setPercent(52); + addChild(slider2); + auto winSize = Director::getInstance()->getVisibleSize(); + auto labelSize = _label->getContentSize(); + + slider->addEventListener([=](Ref* ref, Slider::EventType event){ + float percent = slider->getPercent(); + auto drawNodeSize = Size(percent / 100.0 * winSize.width, labelSize.height); + if(drawNodeSize.width <=0){ + drawNodeSize.width = 0.1f; + } + _label->setDimensions(drawNodeSize.width, drawNodeSize.height); + this->updateDrawNodeSize(drawNodeSize); + }); + + slider2->addEventListener([=](Ref* ref, Slider::EventType event){ + float percent = slider2->getPercent(); + auto drawNodeSize = Size( labelSize.width, percent / 100.0 * winSize.height); + if(drawNodeSize.height <= 0){ + drawNodeSize.height = 0.1f; + } + _label->setDimensions(drawNodeSize.width, drawNodeSize.height); + this->updateDrawNodeSize(drawNodeSize); + }); +} + +void LabelLayoutBaseTest::initTestLabel(const cocos2d::Size& size) +{ + auto center = VisibleRect::center(); + _label = Label::createWithTTF("五六七八This is a very long sentence一二三四.", "fonts/HKYuanMini.ttf", 20); + _label->setDimensions(size.width/2, size.height/2); + _label->setPosition(center); + _label->setName("Label"); + _label->setString("五六七八This is a very long sentence一二三."); + addChild(_label); + _labelType = 0; +} + +void LabelLayoutBaseTest::initDrawNode(const cocos2d::Size& size) +{ + _drawNode = DrawNode::create(); + + _drawNode->setTag(3); + addChild(_drawNode); + this->updateDrawNodeSize(_label->getContentSize()); +} + + +void LabelLayoutBaseTest::setAlignmentLeft(Ref* sender) +{ + _label->setHorizontalAlignment(TextHAlignment::LEFT); +} + +void LabelLayoutBaseTest::setAlignmentCenter(Ref* sender) +{ + _label->setHorizontalAlignment(TextHAlignment::CENTER); +} + +void LabelLayoutBaseTest::setAlignmentRight(Ref* sender) +{ + _label->setHorizontalAlignment(TextHAlignment::RIGHT); +} + +void LabelLayoutBaseTest::setAlignmentTop(Ref* sender) +{ + _label->setVerticalAlignment(TextVAlignment::TOP); +} + +void LabelLayoutBaseTest::setAlignmentMiddle(Ref* sender) +{ + _label->setVerticalAlignment(TextVAlignment::CENTER); +} + +void LabelLayoutBaseTest::setAlignmentBottom(Ref* sender) +{ + _label->setVerticalAlignment(TextVAlignment::BOTTOM); +} + + +void LabelLayoutBaseTest::valueChanged(cocos2d::Ref *sender, cocos2d::extension::Control::EventType controlEvent) +{ + ControlStepper* pControl = (ControlStepper*)sender; + // Change value of label. + auto fontSizeLabel = (Label*)this->getChildByName("fontSize"); + float fontSize = (float)pControl->getValue(); + fontSizeLabel->setString(StringUtils::format("font size:%d", (int)fontSize)); + + if (_labelType == 0) { + auto ttfConfig = _label->getTTFConfig(); + ttfConfig.fontSize = fontSize; + _label->setTTFConfig(ttfConfig); + }else if(_labelType == 1){ + _label->setBMFontSize(fontSize); + } + this->updateDrawNodeSize(_label->getContentSize()); +} + +void LabelLayoutBaseTest::updateDrawNodeSize(const cocos2d::Size &drawNodeSize) +{ + auto origin = Director::getInstance()->getWinSize(); + auto labelSize = _label->getContentSize(); + + origin.width = origin.width / 2 - (labelSize.width / 2); + origin.height = origin.height / 2 - (labelSize.height / 2); + + Vec2 vertices[4]= + { + Vec2(origin.width, origin.height), + Vec2(drawNodeSize.width + origin.width, origin.height), + Vec2(drawNodeSize.width + origin.width, drawNodeSize.height + origin.height), + Vec2(origin.width, drawNodeSize.height + origin.height) + }; + _drawNode->clear(); + _drawNode->drawLine(vertices[0], vertices[1], Color4F(1.0, 1.0, 1.0, 1.0)); + _drawNode->drawLine(vertices[0], vertices[3], Color4F(1.0, 1.0, 1.0, 1.0)); + _drawNode->drawLine(vertices[2], vertices[3], Color4F(1.0, 1.0, 1.0, 1.0)); + _drawNode->drawLine(vertices[1], vertices[2], Color4F(1.0, 1.0, 1.0, 1.0)); + +} + +LabelWrapByWordTest::LabelWrapByWordTest() +{ + _label->setLineSpacing(5); + _label->setAdditionalKerning(2); + _label->setVerticalAlignment(TextVAlignment::CENTER); + _label->setOverflow(Label::Overflow::CLAMP); + +} + +std::string LabelWrapByWordTest::title() const +{ + return "Clamp content Test: Word Wrap"; +} + +std::string LabelWrapByWordTest::subtitle() const +{ + return ""; +} + +LabelWrapByCharTest::LabelWrapByCharTest() +{ + _label->setLineBreakWithoutSpace(true); + _label->setLineSpacing(5); + _label->setAdditionalKerning(2); + _label->setVerticalAlignment(TextVAlignment::TOP); + _label->setOverflow(Label::Overflow::CLAMP); + +} + +std::string LabelWrapByCharTest::title() const +{ + return "Clamp content Test: Char Wrap"; +} + +std::string LabelWrapByCharTest::subtitle() const +{ + return ""; +} + +LabelShrinkByWordTest::LabelShrinkByWordTest() +{ + _label->setLineSpacing(5); + _label->setAdditionalKerning(2); + _label->setString("This is Hello World hehe I love 一二三"); + _label->setVerticalAlignment(TextVAlignment::TOP); + _label->setOverflow(Label::Overflow::SHRINK); +} + +std::string LabelShrinkByWordTest::title() const +{ + return "Shrink content Test: Word Wrap"; +} + +std::string LabelShrinkByWordTest::subtitle() const +{ + return ""; +} + +LabelShrinkByCharTest::LabelShrinkByCharTest() +{ + _label->setLineSpacing(5); + _label->setAdditionalKerning(2); + _label->setLineBreakWithoutSpace(true); + _label->setString("This is Hello World hehe I love 一二三"); + _label->setVerticalAlignment(TextVAlignment::CENTER); + _label->setOverflow(Label::Overflow::SHRINK); +} + +std::string LabelShrinkByCharTest::title() const +{ + return "Shrink content Test: Char Wrap"; +} + +std::string LabelShrinkByCharTest::subtitle() const +{ + return ""; +} + +LabelResizeTest::LabelResizeTest() +{ + _label->setLineSpacing(5); + _label->setAdditionalKerning(2); + _label->setVerticalAlignment(TextVAlignment::TOP); + _label->setOverflow(Label::Overflow::RESIZE_HEIGHT); + + + this->updateDrawNodeSize(_label->getContentSize()); + + auto slider1 = (ui::Slider*)this->getChildByTag(1); + + auto slider2 = (ui::Slider*)this->getChildByTag(2); + slider2->setVisible(false); + + auto winSize = Director::getInstance()->getVisibleSize(); + slider1->addEventListener([=](Ref* ref, Slider::EventType event){ + float percent = slider1->getPercent(); + auto drawNodeSize = Size(percent / 100.0 * winSize.width,_label->getContentSize().height); + if(drawNodeSize.height <= 0){ + drawNodeSize.height = 0.1f; + } + _label->setDimensions(drawNodeSize.width, drawNodeSize.height); + this->updateDrawNodeSize(drawNodeSize); + }); + + auto stepper = (ControlStepper*)this->getChildByName("stepper"); + stepper->setValue(12); + + auto label = Label::createWithSystemFont("Word Line break:", "Arial", 10); + label->setColor(Color3B::WHITE); + label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); + this->addChild(label); + + CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", + "cocosui/check_box_normal_press.png", + "cocosui/check_box_active.png", + "cocosui/check_box_normal_disable.png", + "cocosui/check_box_active_disable.png"); + checkBox->setPosition(Vec2(winSize.width * 0.2f , winSize.height * 0.8f)); + checkBox->setScale(0.5); + checkBox->setSelected(false); + checkBox->setName("LineBreak"); + + checkBox->addEventListener([=](Ref* ref, CheckBox::EventType event){ + if (event == CheckBox::EventType::SELECTED) { + _label->setLineBreakWithoutSpace(true); + }else{ + _label->setLineBreakWithoutSpace(false); + } + this->updateDrawNodeSize(_label->getContentSize()); + }); + this->addChild(checkBox); + +} + +std::string LabelResizeTest::title() const +{ + return "Resize content Test"; +} + +std::string LabelResizeTest::subtitle() const +{ + return ""; +} + +LabelToggleTypeTest::LabelToggleTypeTest() +{ + _label->setLineSpacing(5); + _label->setAdditionalKerning(2); + _label->setVerticalAlignment(TextVAlignment::CENTER); + _label->setOverflow(Label::Overflow::NORMAL); + + + this->updateDrawNodeSize(_label->getContentSize()); + + auto slider1 = (ui::Slider*)this->getChildByTag(1); + + auto slider2 = (ui::Slider*)this->getChildByTag(2); + slider2->setVisible(false); + + auto winSize = Director::getInstance()->getVisibleSize(); + slider1->addEventListener([=](Ref* ref, Slider::EventType event){ + float percent = slider1->getPercent(); + auto drawNodeSize = Size(percent / 100.0 * winSize.width,_label->getContentSize().height); + if(drawNodeSize.height <= 0){ + drawNodeSize.height = 0.1f; + } + _label->setDimensions(drawNodeSize.width, drawNodeSize.height); + this->updateDrawNodeSize(drawNodeSize); + }); + + auto stepper = (ControlStepper*)this->getChildByName("stepper"); + stepper->setValue(12); + + auto label = Label::createWithSystemFont("Word Line break:", "Arial", 10); + label->setColor(Color3B::WHITE); + label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); + this->addChild(label); + + CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", + "cocosui/check_box_normal_press.png", + "cocosui/check_box_active.png", + "cocosui/check_box_normal_disable.png", + "cocosui/check_box_active_disable.png"); + checkBox->setPosition(Vec2(winSize.width * 0.2f , winSize.height * 0.8f)); + checkBox->setScale(0.5); + checkBox->setSelected(false); + checkBox->setName("LineBreak"); + + checkBox->addEventListener([=](Ref* ref, CheckBox::EventType event){ + if (event == CheckBox::EventType::SELECTED) { + _label->setLineBreakWithoutSpace(true); + }else{ + _label->setLineBreakWithoutSpace(false); + } + this->updateDrawNodeSize(_label->getContentSize()); + }); + this->addChild(checkBox); + + this->initToggleCheckboxes(); +} + +void LabelToggleTypeTest::initToggleCheckboxes() +{ + const float BUTTON_WIDTH = 100; + float startPosX = 0; + Size winSize = Director::getInstance()->getVisibleSize(); + + // Create a radio button group + auto radioButtonGroup = RadioButtonGroup::create(); + this->addChild(radioButtonGroup); + + // Create the radio buttons + static const int NUMBER_OF_BUTTONS = 4; + startPosX = winSize.width / 2.0f - (NUMBER_OF_BUTTONS - 1 ) * 0.5 * BUTTON_WIDTH - 30; + std::vector labelTypes = {"Normal", "Clamp", "Shrink", "RESIZE"}; + + for(int i = 0; i < NUMBER_OF_BUTTONS; ++i) + { + + RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png"); + float posX = startPosX + BUTTON_WIDTH * i; + radioButton->setPosition(Vec2(posX, winSize.height / 2.0f + 70)); + radioButton->setScale(1.2f); + radioButton->addEventListener(CC_CALLBACK_2(LabelToggleTypeTest::onChangedRadioButtonSelect, this)); + radioButton->setTag(i); + radioButtonGroup->addRadioButton(radioButton); + this->addChild(radioButton); + + auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 20); + label->setPosition(radioButton->getPosition() + Vec2(50,0)); + this->addChild(label); + } +} + +std::string LabelToggleTypeTest::title() const +{ + return "Toggle Label Type Test"; +} + +std::string LabelToggleTypeTest::subtitle() const +{ + return ""; +} + + +void LabelToggleTypeTest::onChangedRadioButtonSelect(RadioButton* radioButton, RadioButton::EventType type) +{ + if(radioButton == nullptr) + { + return; + } + + switch (type) + { + case RadioButton::EventType::SELECTED: + { + switch (radioButton->getTag()) { + case 0: + _label->setOverflow(Label::Overflow::NORMAL); + break; + case 1: + _label->setOverflow(Label::Overflow::CLAMP); + break; + case 2: + _label->setOverflow(Label::Overflow::SHRINK); + break; + case 3: + _label->setOverflow(Label::Overflow::RESIZE_HEIGHT); + break; + default: + break; + } + break; + } + default: + break; + } + auto checkbox = (CheckBox*)(this->getChildByName("toggleWrap")); + checkbox->setSelected(_label->isWrapEnabled()); + this->updateDrawNodeSize(_label->getContentSize()); +} + +LabelSystemFontTest::LabelSystemFontTest() +{ + _label->setLineSpacing(5); + _label->setVerticalAlignment(TextVAlignment::CENTER); + _label->setOverflow(Label::Overflow::NORMAL); + _label->setSystemFontName("Hiragino Sans GB"); + + this->updateDrawNodeSize(_label->getContentSize()); + + auto slider1 = (ui::Slider*)this->getChildByTag(1); + + auto slider2 = (ui::Slider*)this->getChildByTag(2); + slider2->setVisible(false); + + auto winSize = Director::getInstance()->getVisibleSize(); + slider1->addEventListener([=](Ref* ref, Slider::EventType event){ + float percent = slider1->getPercent(); + auto drawNodeSize = Size(percent / 100.0 * winSize.width,_label->getContentSize().height); + if(drawNodeSize.height <= 0){ + drawNodeSize.height = 0.1f; + } + _label->setDimensions(drawNodeSize.width, drawNodeSize.height); + this->updateDrawNodeSize(drawNodeSize); + }); + + + auto label = Label::createWithSystemFont("Word Line break:", "Arial", 10); + label->setColor(Color3B::WHITE); + label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); + this->addChild(label); + + CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", + "cocosui/check_box_normal_press.png", + "cocosui/check_box_active.png", + "cocosui/check_box_normal_disable.png", + "cocosui/check_box_active_disable.png"); + checkBox->setPosition(Vec2(winSize.width * 0.2f , winSize.height * 0.8f)); + checkBox->setScale(0.5); + checkBox->setSelected(false); + checkBox->setName("LineBreak"); + + checkBox->addEventListener([=](Ref* ref, CheckBox::EventType event){ + if (event == CheckBox::EventType::SELECTED) { + _label->setLineBreakWithoutSpace(true); + }else{ + _label->setLineBreakWithoutSpace(false); + } + this->updateDrawNodeSize(_label->getContentSize()); + }); + this->addChild(checkBox); + + this->initToggleCheckboxes(); +} + +void LabelSystemFontTest::initToggleCheckboxes() +{ + const float BUTTON_WIDTH = 100; + float startPosX = 0; + Size winSize = Director::getInstance()->getVisibleSize(); + + // Create a radio button group + auto radioButtonGroup = RadioButtonGroup::create(); + this->addChild(radioButtonGroup); + + // Create the radio buttons + static const int NUMBER_OF_BUTTONS = 4; + startPosX = winSize.width / 2.0f - (NUMBER_OF_BUTTONS - 1 ) * 0.5 * BUTTON_WIDTH - 30; + std::vector labelTypes = {"Normal", "Clamp", "Shrink", "RESIZE"}; + + for(int i = 0; i < NUMBER_OF_BUTTONS; ++i) + { + + RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png"); + float posX = startPosX + BUTTON_WIDTH * i; + radioButton->setPosition(Vec2(posX, winSize.height / 2.0f + 70)); + radioButton->setScale(1.2f); + radioButton->addEventListener(CC_CALLBACK_2(LabelSystemFontTest::onChangedRadioButtonSelect, this)); + radioButton->setTag(i); + radioButtonGroup->addRadioButton(radioButton); + this->addChild(radioButton); + + auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 20); + label->setPosition(radioButton->getPosition() + Vec2(50,0)); + this->addChild(label); + } +} + +std::string LabelSystemFontTest::title() const +{ + return "System Font Test"; +} + +std::string LabelSystemFontTest::subtitle() const +{ + return ""; +} + + +void LabelSystemFontTest::onChangedRadioButtonSelect(RadioButton* radioButton, RadioButton::EventType type) +{ + if(radioButton == nullptr) + { + return; + } + + switch (type) + { + case RadioButton::EventType::SELECTED: + { + switch (radioButton->getTag()) { + case 0: + _label->setOverflow(Label::Overflow::NORMAL); + break; + case 1: + _label->setOverflow(Label::Overflow::CLAMP); + break; + case 2: + _label->setOverflow(Label::Overflow::SHRINK); + break; + case 3: + _label->setOverflow(Label::Overflow::RESIZE_HEIGHT); + break; + default: + break; + } + break; + } + default: + break; + } + auto checkbox = (CheckBox*)(this->getChildByName("toggleWrap")); + checkbox->setSelected(_label->isWrapEnabled()); + this->updateDrawNodeSize(_label->getContentSize()); +} + +LabelCharMapFontTest::LabelCharMapFontTest() +{ + _label->setLineSpacing(5); + _label->setVerticalAlignment(TextVAlignment::CENTER); + _label->setOverflow(Label::Overflow::NORMAL); + _label->setCharMap("fonts/tuffy_bold_italic-charmap.plist"); + _label->setString("Hello World, This is a char map test."); + _label->setScale(0.5f); + + auto stepper = (ControlStepper*)this->getChildByName("stepper"); + stepper->setEnabled(false); + + auto checkbox = (CheckBox*)(this->getChildByName("toggleType")); + checkbox->setEnabled(false); + + this->updateDrawNodeSize(_label->getContentSize()); + +} + + +std::string LabelCharMapFontTest::title() const +{ + return "CharMap Font Test"; +} + +std::string LabelCharMapFontTest::subtitle() const +{ + return ""; +} diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h index 13cb6d24fa..a803f8d7dd 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h @@ -4,6 +4,7 @@ #include "../BaseTest.h" #include "renderer/CCCustomCommand.h" #include "ui/CocosGUI.h" +#include "extensions/cocos-ext.h" DEFINE_TEST_SUITE(NewLabelTests); @@ -635,4 +636,123 @@ public: virtual std::string subtitle() const override; }; +class LabelLayoutBaseTest : public AtlasDemoNew +{ +public: + LabelLayoutBaseTest(); + void updateDrawNodeSize(const cocos2d::Size &drawNodeSize); + cocos2d::extension::ControlStepper* makeControlStepper(); + void valueChanged(cocos2d::Ref* sender, cocos2d::extension::Control::EventType controlEvent); + +protected: + void setAlignmentLeft(cocos2d::Ref* sender); + void setAlignmentCenter(cocos2d::Ref* sender); + void setAlignmentRight(cocos2d::Ref* sender); + void setAlignmentTop(cocos2d::Ref* sender); + void setAlignmentMiddle(cocos2d::Ref* sender); + void setAlignmentBottom(cocos2d::Ref* sender); + + void initWrapOption(const cocos2d::Size& size); + void initToggleLabelTypeOption(const cocos2d::Size& size); + void initAlignmentOption(const cocos2d::Size& size); + void initFontSizeChange(const cocos2d::Size& size); + void initSliders(const cocos2d::Size& size); + void initTestLabel(const cocos2d::Size& size); + void initDrawNode(const cocos2d::Size& size); + cocos2d::DrawNode* _drawNode; + cocos2d::Label* _label; + int _labelType; +}; + +class LabelWrapByWordTest : public LabelLayoutBaseTest +{ +public: + CREATE_FUNC(LabelWrapByWordTest); + + LabelWrapByWordTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelWrapByCharTest : public LabelLayoutBaseTest +{ +public: + CREATE_FUNC(LabelWrapByCharTest); + + LabelWrapByCharTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelShrinkByWordTest : public LabelLayoutBaseTest +{ +public: + CREATE_FUNC(LabelShrinkByWordTest); + + LabelShrinkByWordTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelShrinkByCharTest : public LabelLayoutBaseTest +{ +public: + CREATE_FUNC(LabelShrinkByCharTest); + + LabelShrinkByCharTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelResizeTest : public LabelLayoutBaseTest +{ +public: + CREATE_FUNC(LabelResizeTest); + + LabelResizeTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelToggleTypeTest : public LabelLayoutBaseTest +{ +public: + CREATE_FUNC(LabelToggleTypeTest); + + LabelToggleTypeTest(); + void initToggleCheckboxes(); + void onChangedRadioButtonSelect(cocos2d::ui::RadioButton* radioButton,cocos2d::ui::RadioButton::EventType type); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelSystemFontTest : public LabelLayoutBaseTest +{ +public: + CREATE_FUNC(LabelSystemFontTest); + + LabelSystemFontTest(); + void initToggleCheckboxes(); + void onChangedRadioButtonSelect(cocos2d::ui::RadioButton* radioButton,cocos2d::ui::RadioButton::EventType type); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelCharMapFontTest : public LabelSystemFontTest +{ +public: + CREATE_FUNC(LabelCharMapFontTest); + + LabelCharMapFontTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; #endif diff --git a/tests/cpp-tests/Resources/fonts/enligsh-chinese.fnt b/tests/cpp-tests/Resources/fonts/enligsh-chinese.fnt new file mode 100644 index 0000000000..e7c7b63d3c --- /dev/null +++ b/tests/cpp-tests/Resources/fonts/enligsh-chinese.fnt @@ -0,0 +1,108 @@ +info face="DFYuanW7-GBK" size=40 bold=1 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=2,2 +common lineHeight=43 base=34 scaleW=512 scaleH=256 pages=1 packed=0 +page id=0 file="enligsh-chinese.png" +chars count=104 +char id=32 x=261 y=151 width=0 height=0 xoffset=0 yoffset=37 xadvance=20 page=0 chnl=0 letter="space" +char id=33 x=368 y=82 width=10 height=33 xoffset=7 yoffset=4 xadvance=20 page=0 chnl=0 letter="!" +char id=34 x=44 y=151 width=14 height=15 xoffset=5 yoffset=0 xadvance=20 page=0 chnl=0 letter=""" +char id=35 x=419 y=47 width=20 height=33 xoffset=2 yoffset=5 xadvance=20 page=0 chnl=0 letter="#" +char id=36 x=231 y=2 width=21 height=39 xoffset=1 yoffset=1 xadvance=20 page=0 chnl=0 letter="$" +char id=37 x=480 y=2 width=22 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="%" +char id=38 x=74 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="&" +char id=39 x=60 y=151 width=11 height=14 xoffset=6 yoffset=0 xadvance=20 page=0 chnl=0 letter="'" +char id=40 x=10 y=2 width=15 height=40 xoffset=4 yoffset=1 xadvance=20 page=0 chnl=0 letter="(" +char id=41 x=27 y=2 width=15 height=40 xoffset=4 yoffset=1 xadvance=20 page=0 chnl=0 letter=")" +char id=42 x=212 y=117 width=23 height=26 xoffset=0 yoffset=8 xadvance=20 page=0 chnl=0 letter="*" +char id=43 x=23 y=151 width=19 height=21 xoffset=2 yoffset=10 xadvance=20 page=0 chnl=0 letter="+" +char id=44 x=107 y=151 width=9 height=13 xoffset=7 yoffset=28 xadvance=20 page=0 chnl=0 letter="," +char id=45 x=190 y=151 width=19 height=7 xoffset=2 yoffset=17 xadvance=20 page=0 chnl=0 letter="-" +char id=46 x=137 y=151 width=9 height=9 xoffset=7 yoffset=28 xadvance=20 page=0 chnl=0 letter="." +char id=47 x=254 y=2 width=21 height=39 xoffset=1 yoffset=2 xadvance=20 page=0 chnl=0 letter="/" +char id=48 x=176 y=82 width=18 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="0" +char id=49 x=355 y=82 width=11 height=33 xoffset=6 yoffset=4 xadvance=20 page=0 chnl=0 letter="1" +char id=50 x=196 y=82 width=18 height=33 xoffset=3 yoffset=3 xadvance=20 page=0 chnl=0 letter="2" +char id=51 x=216 y=82 width=18 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="3" +char id=52 x=441 y=47 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="4" +char id=53 x=236 y=82 width=18 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="5" +char id=54 x=256 y=82 width=18 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="6" +char id=55 x=276 y=82 width=18 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="7" +char id=56 x=296 y=82 width=18 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="8" +char id=57 x=316 y=82 width=18 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="9" +char id=58 x=495 y=117 width=10 height=24 xoffset=7 yoffset=13 xadvance=20 page=0 chnl=0 letter=":" +char id=59 x=200 y=117 width=10 height=28 xoffset=7 yoffset=13 xadvance=20 page=0 chnl=0 letter=";" +char id=60 x=47 y=117 width=20 height=31 xoffset=2 yoffset=5 xadvance=20 page=0 chnl=0 letter="<" +char id=61 x=86 y=151 width=19 height=13 xoffset=2 yoffset=14 xadvance=20 page=0 chnl=0 letter="=" +char id=62 x=69 y=117 width=20 height=31 xoffset=2 yoffset=5 xadvance=20 page=0 chnl=0 letter=">" +char id=63 x=97 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="?" +char id=64 x=120 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="@" +char id=65 x=143 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="A" +char id=66 x=451 y=82 width=21 height=32 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="B" +char id=67 x=166 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="C" +char id=68 x=474 y=82 width=21 height=32 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="D" +char id=69 x=25 y=117 width=20 height=32 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="E" +char id=70 x=463 y=47 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="F" +char id=71 x=189 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="G" +char id=72 x=485 y=47 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="H" +char id=73 x=390 y=82 width=7 height=33 xoffset=8 yoffset=4 xadvance=20 page=0 chnl=0 letter="I" +char id=74 x=212 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="J" +char id=75 x=2 y=82 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="K" +char id=76 x=24 y=82 width=20 height=33 xoffset=2 yoffset=3 xadvance=20 page=0 chnl=0 letter="L" +char id=77 x=2 y=47 width=22 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="M" +char id=78 x=46 y=82 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="N" +char id=79 x=26 y=47 width=22 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="O" +char id=80 x=235 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="P" +char id=81 x=258 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="Q" +char id=82 x=281 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="R" +char id=83 x=304 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="S" +char id=84 x=50 y=47 width=22 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="T" +char id=85 x=68 y=82 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="U" +char id=86 x=327 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="V" +char id=87 x=350 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="W" +char id=88 x=373 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="X" +char id=89 x=396 y=47 width=21 height=33 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="Y" +char id=90 x=2 y=117 width=21 height=32 xoffset=1 yoffset=4 xadvance=20 page=0 chnl=0 letter="Z" +char id=91 x=44 y=2 width=13 height=40 xoffset=5 yoffset=1 xadvance=20 page=0 chnl=0 letter="[" +char id=92 x=277 y=2 width=21 height=39 xoffset=1 yoffset=2 xadvance=20 page=0 chnl=0 letter="\" +char id=93 x=59 y=2 width=13 height=40 xoffset=5 yoffset=1 xadvance=20 page=0 chnl=0 letter="]" +char id=94 x=118 y=151 width=17 height=9 xoffset=3 yoffset=2 xadvance=20 page=0 chnl=0 letter="^" +char id=95 x=211 y=151 width=23 height=6 xoffset=0 yoffset=37 xadvance=20 page=0 chnl=0 letter="_" +char id=96 x=73 y=151 width=11 height=14 xoffset=6 yoffset=0 xadvance=20 page=0 chnl=0 letter="`" +char id=97 x=395 y=117 width=19 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="a" +char id=98 x=90 y=82 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="b" +char id=99 x=285 y=117 width=20 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="c" +char id=100 x=112 y=82 width=20 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="d" +char id=101 x=307 y=117 width=20 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="e" +char id=102 x=336 y=82 width=17 height=33 xoffset=3 yoffset=4 xadvance=20 page=0 chnl=0 letter="f" +char id=103 x=91 y=117 width=22 height=29 xoffset=1 yoffset=13 xadvance=20 page=0 chnl=0 letter="g" +char id=104 x=134 y=82 width=19 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="h" +char id=105 x=380 y=82 width=8 height=33 xoffset=8 yoffset=4 xadvance=20 page=0 chnl=0 letter="i" +char id=106 x=381 y=2 width=13 height=38 xoffset=5 yoffset=4 xadvance=20 page=0 chnl=0 letter="j" +char id=107 x=155 y=82 width=19 height=33 xoffset=2 yoffset=4 xadvance=20 page=0 chnl=0 letter="k" +char id=108 x=399 y=82 width=7 height=33 xoffset=8 yoffset=4 xadvance=20 page=0 chnl=0 letter="l" +char id=109 x=237 y=117 width=22 height=24 xoffset=1 yoffset=13 xadvance=20 page=0 chnl=0 letter="m" +char id=110 x=416 y=117 width=19 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="n" +char id=111 x=329 y=117 width=20 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="o" +char id=112 x=115 y=117 width=20 height=29 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="p" +char id=113 x=137 y=117 width=20 height=29 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="q" +char id=114 x=479 y=117 width=14 height=24 xoffset=5 yoffset=13 xadvance=20 page=0 chnl=0 letter="r" +char id=115 x=437 y=117 width=19 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="s" +char id=116 x=181 y=117 width=17 height=28 xoffset=3 yoffset=8 xadvance=20 page=0 chnl=0 letter="t" +char id=117 x=458 y=117 width=19 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="u" +char id=118 x=351 y=117 width=20 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="v" +char id=119 x=261 y=117 width=22 height=24 xoffset=1 yoffset=13 xadvance=20 page=0 chnl=0 letter="w" +char id=120 x=373 y=117 width=20 height=24 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="x" +char id=121 x=159 y=117 width=20 height=29 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="y" +char id=122 x=2 y=151 width=19 height=23 xoffset=2 yoffset=13 xadvance=20 page=0 chnl=0 letter="z" +char id=123 x=74 y=2 width=13 height=40 xoffset=5 yoffset=1 xadvance=20 page=0 chnl=0 letter="{" +char id=124 x=2 y=2 width=6 height=43 xoffset=9 yoffset=0 xadvance=20 page=0 chnl=0 letter="|" +char id=125 x=89 y=2 width=13 height=40 xoffset=5 yoffset=1 xadvance=20 page=0 chnl=0 letter="}" +char id=126 x=236 y=151 width=23 height=6 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=0 letter="~" +char id=19968 x=148 y=151 width=40 height=7 xoffset=2 yoffset=16 xadvance=40 page=0 chnl=0 letter="一" +char id=19971 x=300 y=2 width=40 height=38 xoffset=1 yoffset=1 xadvance=40 page=0 chnl=0 letter="七" +char id=19977 x=439 y=2 width=39 height=36 xoffset=2 yoffset=3 xadvance=40 page=0 chnl=0 letter="三" +char id=20061 x=189 y=2 width=40 height=39 xoffset=2 yoffset=2 xadvance=40 page=0 chnl=0 letter="九" +char id=20108 x=408 y=82 width=41 height=32 xoffset=1 yoffset=6 xadvance=40 page=0 chnl=0 letter="二" +char id=20116 x=396 y=2 width=41 height=37 xoffset=1 yoffset=2 xadvance=40 page=0 chnl=0 letter="五" +char id=20843 x=104 y=2 width=41 height=39 xoffset=1 yoffset=2 xadvance=40 page=0 chnl=0 letter="八" +char id=20845 x=147 y=2 width=40 height=39 xoffset=2 yoffset=1 xadvance=40 page=0 chnl=0 letter="六" +char id=22235 x=342 y=2 width=37 height=38 xoffset=3 yoffset=3 xadvance=40 page=0 chnl=0 letter="四" diff --git a/tests/cpp-tests/Resources/fonts/enligsh-chinese.png b/tests/cpp-tests/Resources/fonts/enligsh-chinese.png new file mode 100644 index 0000000000000000000000000000000000000000..a3bc36f9750235000c97820e540d4b171e74b7e3 GIT binary patch literal 79233 zcmV)1K+V62P)4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6wD^Ni=!>T7nL9I? zX}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8rehoBb*p;u8ID_yBf z0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J`jH<$>RKN5V(7Oq zK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYvwjAKwmYb0gKL(K8 z-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z>!FI&AHCpoWI|RUq zx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVTrI(b06~u#xf1yS} z_UGdMvD``!0~u->P=lA4?YN`hilQ|3tHka)7T{2CGqw zjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^7T9R1gAN8V6s;5) zieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2bW$~+pTw@bIek?Zv zKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L_AC5qq~L$#SMj%U z$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6=b6>{xYV#Ue-+LB$ z7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=Re4r3qYr~6#KE>;1F z`>_J_P5xC?ROxV(DIHdCO*p$HRQI@7^PwV@Pvuf+5K}u-6REM(K@W$s zrgorh0{i?O)v0c>QtHxU-hBdD(>iYJ4b2sIOVX2K8m~4gmYVA5h^QEb$V`rCQ-|7Z zS{nuL-t>?3n=-o(6I(7vocj#GzCZEo`!3>+v;dYIfPu#&ZWzzX2i^rZ^Mu;6+rb@? zNPG+6)c5T6zxpzGe*M(x+{AON=PiJ>H#?ob-|uwRK0yDg0B4PV0id6JRZw95ZvX&5 z07*naRCodGT?c>^Mb_@>NxKU!IZ0e{kZeRzz<}foqQJo&Dq{8wr{}46ik!-cqM%?v z5fdn&D4?jIh?y)ogP?>Z?y_NKy8iF0o}QhZ=}Ef_-uZ9APFGjG_v+QFSFd7MX*SN}yB%r4lHWK&b>uB~U7XQVEnw;Eyi>5t_w~Pd9Cul3u=DnTqAL za+NBr^j!Aly3qJif2joiKTBZGD;J;5{MY%*^8NpxSC!bg#czN|z>I3Gs-} z3b&qe)*#2~?W;PbdGxJK?%J}?3NL+@N}yB%{~Z!=hO*(4vbSLvk4ZynhR^pP;*#zF z?4RE&&5@HkMmQWts`NkW4IyUxL(`z&Gz=?;JKT3*{q4wZ!bHZWby{~(+VFRgY z*EyV?vcf4er`xSL9WKq`c51rAN&hL2$Masr{vZDwPHWA$2Il}^pws0_v&D5fvr;|o zH_P{1xIG*<*8BdqI`tL8(bAb#=9MaaK8$E2);!gqs`P6&Al;2E?%Fs<2!Sm8{w{OQ zRaY9C{<@|K$WI?qvFFFjelM;LeQ@zv{^O3y)kl1_^Y`MxF5RtD+6~M1=FSkh(00Fi z!HBwl{(hz%+?fuOOFB7s@ABU1bUD(URZ{+4z3ZphXM%^UC4;K_b8^;cPFJP8Wm}&_ zn)ijLyK?jQ4+>p>Bq!f_eEqX6TD7=+{hn}`)Ahb}Qrjv%>APPzv^0m)IjPZ@RU1xM zTCwQ<_^;Y;>zd}#91i?9bT)9R6I#Q+6n=2 zXpdBxpv>?*A>6Jho(`{VQp9b3);!fD15MdKQLZh7)4AF0NqMBf4L@wL0SyLaeKw$# zl=_QEb8}jkrhh?4+z3V{;3?DrQ1D9IG%YDAfrR$FedXE4@skU5x2rYD9Qi2Eg~v;Q z=->l};m;86G)+3S6Z=k#*z-!;?sfjMDx$#*BG`DmUhjvx)74xDr$VAc&}oql{P8Ia z&2Si+&+v~1YOQc|zvf$nBCm;VjyKccH1YBczP{Zs+)pkqoVLp z#?(LBEi_(&@SvlbD>POXzK(GGSHQ&Ab$JSJ3Aydl&bv+;#=prAh@WTV`B}zY?T|T; z@*3WE9J*c;of!02&`ALwX6FU`sZNM${LC=b5JDr^@CN*Bbgj+~J2=RyYM3b}c7W8A z4Ke)|ZQ?Tj$QZ)6rj~K{7U#bf(~hnf-=Lx9_sx``&q{2{3eq+pZ5=W~7$_>a8BkpE zgrY$lqzxSsh96mUY6c2GkO<@sE;IwY&?e|CN5E0+s!UiOd_%a2kNA9FTSRxXljYj+ zbt?G%-lc}qRfpw?vTf({dOPoU>4G-(umApl9S*~MUgK4VLvIi7MfutxG!l`c-yo$5l3n&Kh zL*W$d01U$eX%r$K?M3M42BUxn39`|$b?9Ub1nm}Rh06o59C$4UdE-wjhx)7hKvYjO ziYR*l7{D=3g&XBiP6|)K85S<^Nry1}11{+zM<%Snr}DGod7d}Vca<%JA%VhclmSj* znJPJfE5dXfx!<{64(^+@3svkA3cP^>##qjTY{VhzJNGB0NUG-j^?`==aM{g)Zw; zSnMxBDQ>OU^TT)S(Aqt;_nkFQG^~i;$8(5hx2b+^PX4ERXI<10%K=C1aKgjPJO`9p zh&||q&V|r?6a{xPL=m$H{b`R|QaMhEII)J-{NUu6z8u+xFDR}m?gFj(+$nVxzoI1pufv2D?7vl$DzUR=dgt4 z-gabLZ>Vfn7{{y7A>lxZmgB+$?_YhR$K#k)zURkBPZx(rr9KjdyF$P+u6K2u@tIv( zZ6DnI&C16!euQqF2eFmS&&}hE&ICKy(-Ib_!m7wlO9Dv{waf{g_yK&5T#1iA)#xx?z9;C=nfnx=cPMb+VO;-3G*pb& ze?U#}gFYuM%zQ9C^S??rm?s9(1s)Uvm(vty{2`AaAmp9FDu^^g97onxEbK%srodN+ zMB94XJ+yPpig9(H0>#eA6z1k>VdzMSvk-W<(#KPU5k|?DafBxT{sMq11b*_VmTu@% z?Y21+pyG+I(8LLca6ZNqqqqSKN0Bc-=g#%LH$K<$Q`E65L7m}$x5tqWTV;$UZ@g&n z2xkD3auFQ>MKB2xQa++@pZ3wa4&BvUXt{Dp1fZ;@(y@7C38|I_R*sPZ4HimGXS_s_Vb&e#n@Y8Wb_+T$6Isr&a7r>RS$kHJ zXPr_tlvv*h}*$N6@$St76c5x*BFC(_^8>qpy?3W40np>uLTe&X`#)B!Ml)= zw6$ophPa)&Nh@S*DSY`|5c@7QgK&j31n;q2y}x|7aL*eZ`$2B~v0S;Wa@orNi3Z>H zAG;T<8<$bj>(Huex)ZG`oTH#g!Ct2zs>@}DqhXx`{xirJIye(_r{hf%$fY^Weh^v% z6INk|(6IJUXez>~xuh;#9?xFU;gy62jqU%w``#c!|3x0|iCeMdhc>KHkoz*ShC$+T z_^(8VqA>=>sp0$N4$bS?3w6Cc+YqS3zO-6ZUM@=Bdc&t11jVp1m^`{|)}fEtptO;F-~eI2j8r(Kr~h zld7_UE_<2roY$vybU4sw11PHG;hNWVnxhR{8V^lt_1BFH&{+Qh{%bK6uiv-~k2m5X z#s!dfV5+SuW;HO4FNOg;p$>p<$X!NYw1IrrjhoDA1gJA&`A^t{^d6EJ#AHwse?tX% z<#aU~tH#x9gH&!pLsbR~n9yImskKIKCPk@obVhxUvIC!rC-`?w?=X}4$F)L+TkDu= z<4|Bj5IUwltQPD6nd#+w&)=z#i}ADesV1Wg>35{FYf)dL3Ho_L!I6=ttFe&Q+U)!C>gb+;Yb#@Q~G z?-_9c19?W$ik1k~hNVUA!RD^xP43=wI2?A}!`6g4_Rg7q3;; z#Fu{KczVADg=jse!HV-iTi|bnceJ9taqpneh65!0$_G7zh zajjhOC;f|SUAJs?D9ryy|B4+eYC<<$svVKqF3JE)AiLQi;8p{X51T4FfDH1Fn!DO ztzl5aeWZbuA3pfzm9wi}w|J`s6ZNV1G>vjpm?R@qWno@ab&ZV-Lt9-DxJOS(2-vudYURx7kPmgf|Hbqk|{Ab zG;iae_=8xy;3eZ%d88MJCuES4Wdcb|h1Q+VMI*I&N?B`!VwxXQi)Ibvv?@ZBZr}-j z25M#oT77eq7Q@Iaa0y3TZWLm7n45t7x_Jn~oF)RAj2?Fj4Jk ziAF-)xWWtGCnJ6wVPM$qz~hW{04!NB?cc*$I%7S3KA$Zc%GlH9sG`G9lC z&s^BC9@Pm}`Tk0NRw)z})>G7M29~Ff zveY=^=rv@;P$mz(e|2w^X?unN=9jekRbL5>PsVTC0kD)c9wF%HMA$etbqqKw>$GV8 z4^8_z9$G|vBbW0Z+coVSHD?`q7kf(SKAf6zYz;1vf zoPpf~!RcfvJxQS2g7R~)P3sOl<_uIjTlui%7sIKS$ZrIR~Z>8HfEOe20kC zPyr(y`SNe?UNM0qbHZ8hYP5}a^{Ep^-HNV?2MlI3@NPJquC-2&dj$3ouyM3?fL7rw zdqp2_)G8GUddiV5{wZx^7~cb7d=@y18bSh{0<^^Geqa8L2;olnA~|XJpFxKM(o;!u z+5hea*Z(jPGZCySW(UBKpCEh!(q#i1*jy?e&-?1Sg`P{_+)$*1Ly$7x>)HaH3QS8X zF1%Puoe~lq)$2~vryBX(zpvvu+I7tcSp!I&R@ii%K@5vmM|M-X};PJZ6MqLA*Y zXqcc2dDV?(utwLuqLg(0Um?4!zg?+$sYX#55A7G30N_IT~}yJrNl&RaHjJev*!D zB3%(sO~kO@jayDu0W)a#OnE>t67B#fQbOAfW~$S;OP_3xuw7wEB=q{@qZv&=U@RrW zW}X@3XEEkfI*buSrAEh!Ps$C7j0XnH>W_(-IY78&#WYz7)GDDOD0%a#_+$-Has0E8wmY?QQ;10-H4vXO(0W7P3IE;$f}FNC(}|L6zyW9UQcyg zq}+-4ZwN}h$*<~^sBR58z{pIGFQE` zKM_*RZrPNH{XR2+c|9eIIT6kR3`+#J*f8YR#_gRoDAnQ3tm>2gswmTH=$KZ8zE#B; zB2`hgXxwF>ao4LHo!`3(WbSl0u@@EeC};Eul)m9dDFN1FHUD>umLsW!;mIiufM@D+ ztQi1Hohf5zWtg+FLffRuAuK-hwE%_^x0gXE{F(4$P}17U18U})Gm+;1LK?7L_+ZAI z&B0SC2bHqo zD745gGS63?^vo6(qi8+J4uB>x2_r663>fkpJQpZ`l0Rh~p2OKbKX&HI6dFfmeym#0 zwox&OCmU88MS9sl(#J47`O8rLH!Fb&Re-Dj6bu{c0%K=|lN6Ep$L84aOF>LwU)#U$ zT8$8n&SSc*FSMHpYV`<&1(I(v{_;)S2JGIH3*3sfzcO^ofdFCpGlsdQ+;pgjUVRb1ldqlvV;FNXwl8}s(IV&e>e)!8&%uagezeS7BNNt3o#%ugGKHs#G zH_sYTK)H1NsZgRt^<#$fNn~uW5{A_Jo|x0GQhNWnnNjJX!j`C`G*qpD!B!PEK6Qed zC`t07MiKGpCk!EtIua7&hH0vGEQ6RF4vei7*Ti&<8VJfLf=Yak^hQ&|v3)T@1AW zPtl_)n(y%8pEMwewc^5;SC~je|K$kJ>X9c(1uArsDoS0V6pHGQhiVosrg(e}#;(|| z-CRJ=uD&|TIHt&a?E$2nf^v0e-qgstZV^r3nUyccpg1_Afa24am+$d@%-Okck}dAq zuzusSEf*vFO3cc*e477e`2QXbm*_hWPRaLcPeN~T9tcP5dbR9RTDq?1YhLJx`AMrO zBg{BefE+M#QvCs?htxq!f=Yg@@9eN5oOui#VVhwrLpo&}PD1AnLZc5#T^vCC0qELK z&Wm1Nsz9RskU*3@07MD$pjSii73?$gf$|K68v;z%50^2O6Arb!yzkA>zNX>z-xu4!GP$}Vzh1HD^-Iy$V1|j&xXsnP=rBKlT&Oo@TW|UVPnT4~$(Hg&)NfIrbOz<7Ht3G>$R2n{| z;oBXIOuz#px*F@d%E-Y$pO*kiRFL+6-^t4T2dv;$;{ZV=;8=YXV3GznoHWqY$dXMK zrwjMI(5gIO3Vr9V>TF1xk$%P8%wr4tPee!XF5o?n<+I0)yqs{_RmDXxVfhnaI`%AcFc94INxA})g9E z=9NjRMwpd7$_xNOlr2y~#*fVs0AYf>!yDX9ry|0BNDOJ?Kl2wB8T%D7tVsy6f>Tp# z#fDBS7AM+OGYo$<#Sl<%qF(6|KtOa3mpqDPSM$w~tlONG;vq?9m;>=xbK3t_=Z6`> zV9Y`md-PA@ksSa8vfyJntZkAB1?Rwboh9f{Vdj8#Yg17SuAxTl05JVzl{+4*G_qz* zj0YJK&sxU6B%HZ?k~CV>6tL1>U-1q$&^tWV;Kmh68GOG-TP*_H7%}@vVBNfW}EVR+jj+Dk?d27B_P;#A@7fd}1_!gR^d|1FG!9 zD3tFu=K%!quUPKa&08=lC(c&6z@b~^db;Npg<#{G*Dl;Vxy=^v+Zgzj_h|m%c)nB= zTF7q}<-xoMN9(AAW*uOo%Z>oL0;~@Loh2dgX|jG0F9#jE;~@IU2c6P=(4Xo#SZmOt zqp&;7UdcPF=&1v!^tJ{UsXC-c;i`k>kdHuZv_j0M1)`qOhy_q63oH4;RARq@wj!@= zD>v+vfb;qDT5&?qWJvhxRV%l#1jzm&NK~xu{N?CA(@3CUH#=O0zoy^_5e^e(`}WSf zv=3%P+p5m3E_PL}U2}R#WZqVVs5H?W4=q@|ePu^eMWA3pejW|BDB&=6pJR#RpVT^Z zf;&n%2!oh2cW?*|2b~(FC|~R!Rc!oGp4hPAv8-UKl7&YU;TKy^Y$6Zh35OQLFz z1-~7d*JCH}GMJYx)o|w+f>v|r-`Oj z2u{cp)wnQFN?YSx2%ax$lVZSrTGM$EK=A|8(;Z)CXUi-=mSq`ZIpUw2r?mU7$=H?4 zOl)vgB4*m27oQ>V>7SVZ4AgT)t&ePE(E)fC+)h>u>+*J_SfmbstX5^Ze(dHl{{%r%!maCqcbI^3gs6#GL?D z*zTIM6tqF&m>svY7qm@;z}+KuAZD0?0W1JR(~pi&5EHaZN~waA(**!wzV%PHsOa_O zcR+v3&Gl(q#b!dlkNTm?u}&+0R5oDyAPb`v3JJBDvsgmkRQSaafziO__=!? zmRvTK?>=ukDg4n~#;9GnE63H_ihMQ3wFK((K9pKJ6gA6vf4z}Qj{h?AvWHDw#*RRt zjmzA-zwMFvy(i%QgeK7cpFJ+uU)`PGTAi$HY&!t48oyQBzHfpJvFT)nrpQsZ2G#0gw;S+OV3)E-vq!LY!Q@#+Qt+)(9An>M(M|MLMy9SFn1!~Q!8mmMPiqHY^NVd;Z=O8&3sn4a z+g@z{w}xX@Ot9lAG%WM|ZncbDZ9OJ{(~s=ix8dZ1L7mR(KATgwr`@45T7jQ1QY+91 zW+#*&%R(7!^xLCN=_Wv^(QVsKtRCNRGC=QB##v}MJWKm@`?T}#BsZvtimwDnB@MFs zwT?KJSz3ESvYpcPa?(UX5XzlZ_4Sjd4v&Li%A+IGV&7YrU0L(mFBgY^B;-BU>@-p) zwr<137G?#uW?^ih&RigwQS~!$%3XNM&?(ekK$y0KrMfR1M!lnTS`#_ zExTj_#OP!MDCFgx`Wn196WDRXc^9AXp^?WtBr@&yBL?cPHchGw@#ES3MRL7YyV665@owTJP#}XB7n){^R9Fx;U1qr_RK(k!^?0 z;uj_VF@)C`E5qG3KHK7NsL_2`)R5bv-LH1&i*HccsLPUceJ3uLT7qk&euB;C9Si`K zU3}8`RDL(QCH6ZdbSRURu5AY(R^w;*^~UVgu^^$Zdm43LnAm8@N-@q;bY7af@2yUI zK)oLM@c9i+7ut3JV(}R#nW)hwO|zFB708N^l3iG3eZlW;D>#uS8e0Xg41?56I*B0K z!0evVvO-p#zcvbm%D~NP5yu?cphX0s;w?c%9L@@e9#|K-WMoP*>zxqn@2A#u4LYq!3yo)r)QuOUq33b-S|tJNQSy$T?3rc)d4H`!zj-kYS-kYC zkN7lu+l%ME1YNy{u(0o-uO;09h?kCvr%+I4rf?F%I4wY|<7{SVtnCc$)&<=>#*SYv zB#^Q{;2Zzf*)gNa*(4Qv20*n8B!otpGDyM^Ug0P_vk{DmZpaJ{Jjk{Br5&PE84vjJ zTHxc0`DSruwkN=6{jva6*_kgY9%sX3A35?6u+cyk&B>hO&me(6p|63@QB8Sce+TRx z>JV&^M8i(MIur~y0Gb<(8E;@Cvf3|VsuW>?Pa2A6;Hb}?QHUJ9a`J*6a(_zXu>(C4 ze^H&GJEq|NpE1Bm1?lk=C&=WZk2DE3?=@_VR%HU)JWlf)W2M7U9&Cd_ITJQ!1d^|U zyEgbW)4!r7ViTeCvQT)SL?Rw(rUM|VtCYAX4`nyavE^_qu$p< zgD~?6@)tu$~Lpqj|S;vt*cVQ>>{iK79U;o$i;{4GIav>XZI zECf7xmOU=E0TrBSuYG5>7l2oFL7*NJj`2dlTTd9n01Z5K#7X%J1*hD60U`LY98&3cAanojLvy=5S-E_*$;F+$!N}+q zFptlWnSxwUrT>C0R$9e*VuR|Q9j{(A2gYs?Mmr+kmv6G=1lTh0ScD@7< z{@J>%&$n)YuQh%q-yBi9Q&M`=8nzS-dwj<|U`Id7or|3JQno_V<2I(TsN$ffM?uGf zI$56b!6=&Z>}<;@cf8<_e5%b03`ec>@eyw^Pc&eoU`iX+20tF|vW9T_Q z8jB|@uJzw`&WC?KXLRe1U88pX@0fNzI)aJ|Bjx#(63KZgznIH#6|gjgS0y1 z?;Plp6GzgcB}>djb^w4Ev(osDH0#DEB%G62GD$+|S`N#F1%YNrH57IftfH`sD^eJw zL7K7hpXb#cfP8BQ20bp1{4-R5r!c z@r;{#Zq>&Aln81hjL_#n1T7U$QVhl?V7C`%%`Gwk7OU}R%(bE3QQCSA6!~2{IJ+=j zs&i;g_j`f*f+;sy$?)aB2-u{1zjpNP!n|I8Tb?hV3>XsDJ&vt*aN%Jz0jfl(Bk-4m z<4geP+_`gV`>FU;=sp;yq0mG8(Z=6oVYWYWes4C6y=X6>+m@K(C2JdxTWHy6USS*gUlLe%>^e0giqmoXVGlrS zB{fakes+yZ-^k4TrlD%xRoOW9kY(M__E0Jqa5%N^cGW`AE`}%KB83^KG|`aJgHw&Z zQZI>%M^1;6B8~KE(9k%Xik?I{G$+9xv&JAP!BI6NyB(7 zGz`tf=eo!B@6fP#epD>7atYa16;^8B7O685NC-DO&QbZtJJ;K@k7RNdpv2sIj0V8x z1th4-SC?~>{baFnzmKOv>dVL{9oF9ZW`8oUn|e7NKf1X`LzOvpo7Wq@?AOGSG5Mnw z7nt|NFyldG+_+*>gByMv1@(K8##Pw^Bxj|FHOqRSu_$Zt5U#N&?Xq%?i~`y6CZhPc z+K|saOPWXwgnEDemZO#*2?CzW&LM?XmyJ{9e1UBYgMKkNWIBv8ew? zDpJvckIBPdB&YBkMM5ov#Lv1_9RMprKCQMT$T^ z6x{$XC!!HiJQP*AqY$+!SD=nXK()Mg+x9m1Z|{a4*G-I6vXHXVp4U2D6#*P0VDseG zmtZ5CYP15T;f@;Dd~pSjagBi%5w&?@)AncqD+FjjQS`4PfRYHP&|}_eG*)V=mo#yH z_oyV$PDaYdJgTYj$1sen>^1zxf(2{vIWFHcuzCkxt zqm?LO>W7KR1%cD+Fok&p(!iuTOAZYM3J)dt^r1jn zi=Eidn6RjIT+&$b2(R1vQ!hNhRwbK6`&r#VFrNmT{ofW1K8pG20938?qBJ# zuHyu6#|_kP6FA~`69q-b5>`%VH4sz>ICW51bzqaLTTvDf>uH6@dltwnm`Xg9nDJP* zS9bs?K4kJ80E@UONbBv7{oMLon|_eKni+y_Y_D0{F_SsQKCR#$9~>a82IDCIz!RJ1 z152xkN++TNz(OiefJib>=p8CvDWYr`2~qqIsK27C3S1XEqEU>+XEdCI!eKyz9f2qa zE$`a=A_TR}lm#0~O*Ilxz$1cjqf=kv2IRe>_VBNYWMsXDxW=sDW@SY)vos>HBmtUwB}Y zISHMka*5L2`eOSYFxrg*@P}*EGW8)*{6yhuHE%u}3btRtOIiEK$sbB|wuyBA8yXGv z$4ni?Qi>26YbP|pW+6Eabv0mrO)ZAqyF1n`iNfW29y74P8PQg;*E!yP1Vfm+N1b7&Ybx- zq*I0S$7S9TfbKd!wqytplDl&xq6464s8kiXh#%eIQX^E;=*X&@r?#&g0aT2D{cm-u z4C7OkB$x&^v_&5gD?S4mFGiZ7s48DneoLUCkzsy(HnK!1BrCYYK|IMgY1AkCs#0(V zZ4n$51yz5DGW4t(Li?@BEqxQ;i5M+SxBdo1ud+r_`1AcYMgvVIJm2TL2L`|#r6U0- z-^Ai9S2*1%|HO>PF^dPt<6-&LsA6prvSLn3&K~&bCUhV! z#_pN-5xWog*`RU?(|)Ir2s;L+U=Yl*3aCVA8j%$3L#R*03+k0USVE!OUTDQVDb)!~ zmYlk?NF4yPi)89aLJ9v518sWtoc_?0R+JZ}{#D5%I7lH0XWIc#grX2>egAfBfD)Mj{n9X{dubHVA_e>X{>zj#05%Fe^Q`W3qHee{ zd9XMsQgRVUL8VW`ZV3H&2v}14AuwZ*X5|yp2gf5ANg!bT(@i@8tQKolfRDMwX;7^s zD|DN;3+(Z_GqCB@wYKw*$S4LaNQXWY^tLn?vYf+x%uAY4ac^|KE zO+#Pql=sv>ibBf{XUFqx>!KnKv*@ETE~!8Io85M>wqYn_<)Wx4bWP+fy>5E$m&3Mu zzaDXqEe!;&c(mTttNvYo_u8i#ujWad(csia$%stvF?S0Zia#khQ!e~`Dxp0R8=q^5 zFF>@*RXGXa)je`b)bvUsqKtDYlvi!~g(17>`24=-mju}$4b=e(zMXjw*7;QN3e~0IWR-&W*wPzv(cj^3^@N{08einP;pv zDH%Hd?Xa{7P?LuhpYUKc=ut7a;3Qn=4Q^UBb72@lEeBxDPd%w$h)SxnZrcGMp=b^T z0j}f{OEmzSkYR~NFFYI@x~^t7hYrhQOH_K{K!JDiP|}J)dQ3f*3_{saoW_t>C~T-7 zQ?<$!0X0a*Zy0x~a=;Jyz)4gb8I*|Ao#F*03o>QNgNbp`C9WH#H^hhKSFrkwFL>bh9xAmr9H(n4eZA+&ZU%uCTcHmZ9u&A}fkL$3E za64ze$T8fkIzyM6Q}pJ0iT~E>|9K|TGe0cO!`S}aUN=0$^JQd9wt*OMY{@8}@m44^hHxG= zMSwCjq*~U)0Yc>o!*X+Z%ngB|II;Y;1}7E*a^u9N^&r^WtyTpBJEgmv&qV=GDp+)w zor5xa!r~MDlpL@BzNCoQ0Iz?x)#c!KIHQya72@Yc*Y})j0~$BT)DIMRn8O~u@{onn zcAP8b(N^rYtw%5j!5+Tf@LwKACiseP>I*pxFV_bH1hx;wah#=r9IxXzf;>C5lKu2A zTJjk3Jgdr&olQ*+I`#RWn$cjB4p%gj#)^;N*T#X@<`}T_%ga1z&JxAKA|K3N$T!(l61}hu_P3YRZCT`WO;$)i({J%zi}^S z7gbSF8L-m$d`V3ITjJ!QJCH8cBmn1&phE;XDKUw)&?XksI1TR>- zqXtudlqRR1Z4M730JXgZL1Ls_(#g_P6&$U;f@Uo%Z5&1tcO;+Z&m99^tWL=CI)7RI zQ$f0?&sXExCFrP##b#X+&iq{8EhU*+vLoQc(iW9enW5g}=92me;SeG09Ds!IiUJh0 zM@Tg2PmEAdpOVD0r!G|ofLX`nc9GWqNtb0vT~;!;Pw0O>bnTOk1|WYeRYs(?xnbo7 zZ--~9Qul=?P(FK=Jf(SUyU^tYN-k1v6fGXf566l19@zmvp<6~H8e-G?HlGCIduBYh zAj-c2r&wh}eCd~eB@vZ5!+5VspASz)5ek5g2hA1Ab?qnQg6v!HllGdl-54k@G`7?a#|}; zdBu@5r}kJfG~&UkSpW^AND7pEN-Z@{7`r?dZpS z+d$+Ul}v~$!WQyU%`hTH#QZb-B6O6mzdp9zuD4f2~osl}yj%GT__ z6_-{xKDyo>tK){HA@vznI1Jw@f5HVTd&mp`gHM|a7#6CYrDKVvWx<=};ZGDT0uK9C z++d@bsz->$dG^62sR-aW0jdkGU_!Jc4$l8lG-R&6`?q9|_1uWjzm*>>7b;tXI^FZc z!U0c0!LC%g=+NWNm|HZgXQ7dV6_|*KaW42o?C2h0w$`!@zJup1z-)^~vd?YP&K>A< zx!W*p>Mk}hO^ipwgjLlm9%#bxN?8MyCvhZj62-_zqhYPrCW)rV8N!&T<2DG&o-#n% z(~><*CmLU&;iBss*~dQ_Fdj=jPt%H_i|3JE?+bv5It?9)&o%AUPs~8W%ro%rQOvK8nlCV?C98 z59*FGMce;ieFdQONtINgBykN=Id0(%G!of(+A6cdk^Z({JM{>RU=_CU$lF6(rnL1o zx~b3OyQY7l47_DznLy^8o);O0e>T1;S6u?=SdLqB6OEYvZQQ1?ot6hKu6<)UBt+20bL5%d}m&5l{s?J%- z7Y2^~Mt!6UHb$|*qsDIdZA%L%pi?#8V8rk^iaZ0rL`)rLj{bOV<-Z#?z=04L*wIev zo0^R6`?hwoeSZmuwV4+hX)+D6y~iwLal$PGZF5r2wgZreh+Evbe)Z22TYL&7xr!-b z)HUJYtWFE74qlp-6bAr4IJr~V6WYlMtRz%ADB!2u?V2o|l7Lsr3PM&Th)0w4T2*f4 zi3eRco_S5SlC65IULPcRMLS1;+pX@?f?p=0Fh6&ZBpCPJk^u5lEzDi@w{#`>(jy0(V*f08;-g}S#Q4MPl!rr zuff(y4b#^gJuw?L`YL>DZ6+y&4~^)chBtk4&!D*1yHBY$IcHr0MCMf$to4>8G(*ZV|bBL z6&mi91t#m5kVRe&vP&BWE7dZ5UUxyKR^M(1$1tQ0Hp~W-eW*ZQh4 zlsfmHUu$xpLiquXJE{q)$^bu@5d&-p4m)!So^dYv5wGwdd)9e|qij{~6+UU{KBT?O z)p5oXR+g-%(^=+M>C4&#DBS9*-x6!Nk#}-r&h6C?2~L7Q8iK|~BzcRtWX2wgUZPLS zL==LjA|>K*>%cvLJu zelzc;QH~3XPvjK~R1^*bl5m*ufrSPh{!mR5nrB-(zD@8B@Ty%JGUo>JXo~YZ*@EPM&r3jcHT&H=rFz<1X zhE}X_r%OJE`^Rr(^`qg(2CbW6%&<2ib|bQ4e1nEr+42K`HCM$5T(eljO^t6^^;MCX zLaj7AYUtY=S}VDJkXy8v9bBWs7LH5J3rN7Q)ON*6r|tdQW@F=L1rX#N2(&oR8yUDm z-ZYGOZ)W~Mukeo!kk6)F@%EFkXs>xZqazG!I}=7^yVA6mW5J)UxJs!NUq706d>nWw zkG@m0yd~FhaPdiz(vyJ$hFAugR&C3a_SZHZyCUW+NTTWB?unsPF{?hnXvO`sjSZKA zN4e4Q*R(b4qfp;e2m=GLK@9ay80BK&hr}_{W`ZG4lS15IsF$aJHzV4<6h$X|KT0U^ zjcX5^GrHglZRfgJuqIxoQ1qbx*vS>9zC#9VTO&@4?9?26p21OV=<%a@*FzS!Vp$LO zETAq@-jokziiVs|X@D^LIt)_gm0^@8-qnK3qc%hhmII~f5O znjgdfjO2aiR%m#|k1J+9z0a;HO9UF{lIR`gZh?3@Ak6xI>y1}fA0&F)&C^cqz% zIZNq0dt3J6As7K`-4&mjY~uUwFYKUx7LCrzaTz19;cqf5OIfy-bjtV%aclG2*A}ZG zgnW*hv}gxp?c;m=i?Tl%FcW>h9E=98fK>WIG-{-Qv{yyr(F$*M_m*iJpKiJt)TW{k zny7FZ8T=_Z(+@`-MplkM=J%AnVs_lUA-Gih4&HyRx(z~mEo0Q`V~Wrj{^63-kq>&m zgk9li5Ejdnfgy zQuXetXRUI-$d=EJ!dMuQ3aYYxzsqTAC%mz(e)SLq&a| z_(-OF&lpSY5iN2wPl?$LQH*#O`tfCA4IZ~PG_>@h%vM)1=@gHBO=QI@FA13CV;cBp z%keM4)*ZL^x0?is)PXUJ)E z>9!>4hkR=o&}LN=RZTb5XVudXlh9DW_dW;6^>v8Om^&;NQcm@<8mt$>zWwmSrCj77;y<)-0ttHpq~~~93_}J zETGu%Po4zHBDE5soqcJQr0vffuM*k&=<#(YEGf=IW}cY7%w*hJE7YqBth9 ze{PjDN>4MA`G<(v6*;Fw!k9)A`bQW5b4a@(OR%)_vZ4;#>5Ly@dg5%3TH6z3aNdv5 zwBo2TY0#(jZq2>Y-^H>YFDc7V3)YJBVoNMOmA6scHON|XZ8Ci3pl9h1G~j%y;J}E9&Lz zjY{8SJSe$hc@|Xkg9HOiM1$}~@#dNL&JK9N_MyJwc8%meqsYp4Tw8F#H(d^xbqk5hlS0mHR3Tmyn& zN)iYZW1Ks~QS-dL48mff1hGpTP(LxWcQ)vrIPwE4Db;d#-MqWp z$XJ;!^PFEbbaud`WsjoQI{X3^sZ=WbOQ|jz93^(Gf;!+;xYVin9#0Eytfq zwQ63NrClk4`IlFgKOX8^q4Zx5ffqH3ZutU|r7fLjl1qs-v0Wli58E!cqS$p|zQ{z9 zVj4O}xsKJWX;c2U3&6_;d`%Rc zhu})X|B<#q@_qz%f_Bz(^tF{H5rcV> zNmt^ZTf$8{O4ej>PK$b8~@ z09s4sT0EP}n4rofv*%15=+|+s5ZD~pL4T&a*ipBUV!*ff=E1Be#E-zN#n5{tmJ*t? zo{GjJueF4O|-`HN%Gn#r;cd&78OT#Pc@b*Ffd zCPTOPHqCmT5p?hrF?6!8S-XOXkUhW}WhHl6(jSEsR-g+@a`NWA@MU&&cV67Il`h+% zZfK&1FSoAZwUS8p)uFYZaac5Z)XR3BOx_MxK72(H5WH4v3Wc5xxNE17A}5=Bq3ig+ zn|`apNf}dJ3p%{D>8v@zi8ZDO=M!j>>W*~ z$UkLqEYP81kJEiaY1t3Qh>jIB>wz31v^T}J8PS1gpIJ}15c?JXESA}-aWghH0QRsR z>vln}-Lg&cyr}TF#lCLA%Dirctlj1HzCkEpykzsqVYns&14jkw%>~rZPp)7Qz$`{J z6pDrLbeRQB)vFOJ@sGdQ(NO_1I-u=;^OB$VW&)`z5Yv&ceF-4OciUE0bFe-8S z9qHxNqgWhW%FP%cceF>eh{20a2vx0SO$0~kI_oy_o!hfR7V0!vVZ2ntyOp~GK4b(I z27Ax`M*7&OHi5jUI%7rd@95BR<_*uzkOlXLzR!G(WSgpfQyG>WqbOs*O+>&DF+b+A zvkW_RuC?mf8M8BcA|cJ#p;m-Uvbls`8t{pX1j9Qf!YcR^GNYLU-1(`TAui`}l3Zi3 z5zu%XnRchN50c2qaiB#PK`eU)%={;zd^eGiMI+eumydm!4>5hX-JML8*1Vgd^cT_vv$cxxCkTL!iCcFv9-tFbQu}{B;?~+# zz{B|LRGMOJJM+$vS?|l5rmJQhI~oW*_Bi^B!ClaS+E$>;mZhs-&4jE{h$Pf8;Fugb z0b;sX^zR<|Ven1`V?zlrrzV8;+vvDc^!dAUU)R|#vHldOfvaL_$7PaBTT12hVGn2a zSU0Srow%dB;p1tBQt!mxqp7@!j5NcKs_D~^=O(P6cf&v7ESV(2mt%LrIpg6VYzX)x zug_{v+*O7`2Frg9>6&Uc$Dw1VvoIjLMs=8pmnQ|;m}yH)P{Zca-hSDtgdX*DR%`W; z>NY7jI|}U#gJl_Cti$5j7DCa4l#k~4pi|UG+~b*uv=4-6fwO1Ie=+NhZ{x>s2KOSH z-L!Lqka9PYUFwH3k^%3e?wmN8Y!TAtWp2%>v9#>m`TOmo`D?x{d*r z(#)7D(YJQ;=q6e+`D>t|eeuz9+H{uZ&~3B2W8QO$7f0rR%nQ82vrCp!J6lN>a|T!1 zMx%iihjjbnm$3FQ{NoKSa&NpQxLD_M)Q`VXOPA4W{-s!r@-mV1@i(0Al4{r(#<4xK z0GCEJ{Wm3*bmUaTrD)tcffVEYTBb3OZSH>HTv$C z4KtKT|CkG5O}aE&kT`kqF-RLoNT^zIVzT?1H@NlKm>ap7GBkhxugV312+#$fxyPxS z>-Bqy;p2hO7e0*g>3^wL{`<}?c>J%BrbsRs=%ORIUqbi)bi%wIh!I%9`>6#EJ+3Tz zv{xrp-+bDSw=t3Z_xu01LFWG=mHGcP-GV3b;}OIYq&FQ?)H3W z7%Pm#KENBseCoobIpL&8nf9WT-@H=XSm~Rq90-=Y@e3@o{x2b|!Le(1s=LP%kWvBjdZ>zAZ`Px!%hvK& z=I0`hGwbBwUwwJ(-)mYsyn!9ktuq~sHj8nsIl{UR%jyyNID<@03_U&035*FiT_H&jUmvSspRw{z;Ud}<;l%=hU z54q9EgiBcm%Zl(yxShMKoS#PhKL5%0Tq>pw1aEBN-rJ1k58`5d5dPF`mSvlxdQR;m zkasm5XsXO=yTdxi1q41*cl%#S4N=qzDThw>(dM%f-DQ*Rk3@6455g704pnJdmmKHsE|^jl zmc(2=Y<~4c8iQq}RQNRuI4UQ`iyhu)*YzvEh5ak(@K%j31FU_M0#&iLV%dkl!>h#~ z8g#9c?4pydpw2~S4=%$^^d2<(`1AA}TJ?khVC(i9lVj3n9;LDh;2n-`23lA4+rFl?;u zr{L$DgWVPyHs43FEv%y%v@P^w`tRM$3h=z>>3wIkR%jEqwTkT+w%5OjGF(63uGMBC z$Wo>P@Le=1j%IJ$53a)ld6~@aEYjV4@5BV|NoGA@A1#*$D*unKFBl zl22CXxI6penZY<*(5?J{Q{dj2wUGT>GYMh$Ip*((U{=7*d2rs(X78DKp~T+-9*>rn z*m%FSI*5$~AL@(^Cf>1qw_bTpTjbFl?=Xx3a`mmlI9aN1-=cbOvp2k@j(niEA%-Le zd(P5Sqzi32cV9d?Io%q&{jt&9)L3SySr<;pVRxQH869KrbZ39|9&M^fA4<1{%#cH} zs{bmkcZNy$KpGd(2mrhs;tO${e0;v}UH??CHf#-y&BDs^>K<>A6dpi@9FTJ1MR*9Z zNip1LlD1ejKixLB*!xRcZr+4QYT$&MqESkGI&4C?-24IoXl`27bH>%#2}&oH7lqLC zu%g?JJOiv+qBRk&669gzbrX*E>WfXHFF(((cc9)Q$rn7f`V3xVP#GyTTcyzM?A67y z_xD{b0JQtlp-DgGj6^p|(@suo^46WLQVWZ=S{8XqgW%n`I$F|4qf0&+-b;8+vD+hY z8M4V&^qgnYy~pBJ9C*C$yV9c_%?TW%(2V4$Wz4;GE4bb~J6od1FK?DZzs88@6w&OU zvlOxv3?5U=k`6!Hvw^X!{?L2Ftw+HhhbCQ9ZFh(e@3MgduO@{Uc=VwHT&$k6HMA_& z@8&y_!w$fiC*v)Bbp?4neLeKUCLYu8Ib!_hwjP5U_~MZL^|vp9?Vt=`+T?lnyE?^^ zRlTT&KxlYQQXkBV*msC+Ng}43sDGyJXb$saqJ78OAnq1x{U69gfiLuz9#8pjY&Aa~ z+fu2%L^-1W*|p*!Y!KC-WlA+|#^Bj``WM0GuyLE+iiD2$NI&BohcgK~qATTU)fbLP z$HaONPrwB;uVoXu`y@aLci^CvQEEKV`Q;ZTwgY$L7JZ|?2}y@w4H~}A3Pp$bjvEcG zsSM|SI%$Vfq;uCo?fh{>_(Wr@yDs?cZvZwBepKj%1-$FhS_)@=hRbhhO6|cLRiQa> zo2?c6E$7a`qK$6c()&iW;+g+QL%+4C)j3=e>fZl?_~`fjC2Od zw|z*CqPu%SaB1O2z*E7wYU~7FpygH|Jqw;mEq>tqQ#>WeMU|aogVx6ri3Px#`hFza zck1auuL8oI3=*7hQvDY^(%t{w#oJ?zaS!;|YDdkJdpE!cAr_K|0fK*-*ZDQr7x-`( zFAC+XrsOmV?8~6Z$BjHtwd`#41!ANch3d%vt`alE0?AXfLUr`rY`Te;k!_q{y3LPmyk#4{7ITLom7jRh`HDo4^ zyVLbyXlF=CKIX!6h}C`)gx0+^lat+gLaaYb->*?L3D-J3pLc`tdD6%P6@1My7Meqr zM&5zs~3HY9nrVS+kmg_E(>+wa`(B z)7zmAsQVecdyULhP}F?{dnwQ{e@{Qum*e@DuFOJ0tGvs9LklxMm{_%7m9($A|C*Iu zdjT#J?)L9uKDcpZh(B>fFbbrR0;Cf)_E`{XRn+r|4LB`>z+i)<*Zb)-f{M1L%OA{Q zHqgV7^UH)aw=9&%=e_z+hpkeR1X=gmpAs}$nzpa9?@O@l$ZFkI4@Kl-*8N3Fj7o-B z9}i@$3V%BhGWN#Wi)XQ->2(0$I{WWtHk)Zz+ZswCyz@K|4J0N79M(xlS`)tFNz%(= zj_`T1^O9?IzJkK>$VmqacY~joR`h;JDr=Zl=M)Gf*Vn{z*sUnWpG|QXW@+Be@F*CH z;!#v=(Hj}+OI4E-0m|mB&(8nLZg7Mukv|k%@D?Eynyw?LbNJC9b8D#5S}y}=@(DE` zHM;Yr!pyBVl^S3ZxOMfAN6ds~U+%eBE)QU(}mF67Qi&mpLferx>>cHJ_>4St{8a1Kn-=k}fZv@4t`J1}!Qa8C~1rIblb z-ppI}iW{e;?zj@#gq=^fLYQgRy{K~WV)1QZ1=s@q=YBX{u%~tN%&r-%%epXX_;~m? z60aq?YP3~dc4gU%z)FT&4uXd{!gHAvM~&Nmle5k2ZoE+&`+G&;>#UrUayJx zji16l+}Uw0@w%)oWi$$ zigQHWcD%Qm7=bWxp`ON(MXiND#rHH3O_D1mCMi408f-PD*+pp=A8#JAlN$H5rnlJf zYI8Eka-{EO!jE+92S9#`;1gJ(kigYBeB z-HuW14c;yXs3s)cy!HC|mSoUR9Iv<)I}Q3ftO0fOV*)c?fEw>AF`)t(Dr}QTBESrP>uzTW3ui{2o}J z6iJy?+&|nOxX{Fy_2@)=-U5-1&tKfTZ8wnMp_yTHw@Zb>z0h3+?ms zxYC!F!r|72{<9p%VfuoUhdO6kt9@<6XdIu(x8%mG85c&z)|$tp9|)#qP$cDMhKxm^ z?FE3s%wwdEd9!%Irq3rGaQXviY}RUh@7{#H{aH{IK*9H!`C6$*(r5e2(?nu5CH2_xFlRSQFWn zxqYu>F3;(#X7%SFXHHHR^h+1E)u|B=`HkY=U&Ccz! zWfEB(9wKy`?+!LCUxq8;?xf-etDVaqaq=sz=Q0N%Z_DIZ)-pAth8ymjbx1=0>bj{V zA9)TDHWNs&topGv^J^OK?kO9g^9Sd<7X6Ua?xKJzW6vxHfBeT`F!XxDq!P-X3b1A@ z^!#gG&afs6p`0pU`dHm~8cU9tp$4 zAH!{zjkR&^&88zRRIM91F(7B?SMnOQYRn?J;6P^o=4M&k>oKu|ZUZ9a)$n^!kmX%- zs-27?(tvg}>_zc%V@JZf{l`0^HJM{KT+y6wZFca`-EI?iGSA8yG*JGMm`I}G!z1Px z33RbLvDa(X{MU-$)=cHQNN)hNuMD9@Q_})GMq$ln45Sd+86Y+c3=M7`_FXwOky+|* zZw3k{b?Yq|4Ra^FM|~UmUMD%Vi0yHnW>DhCA8O%~E;6`l~ zHjeA-fpzgom@09O_K78SNSuEAV%2RE57)7iA#0`+k5QX-;u8`kfA^h`UeYFe67SPSbiiQ{+g%D z;QX##4ur+c^0?%G)TrkSnx~|l@7{JEg%TPZifW3HkY0gIZ9{Eg0`AhnnL-%2B^L6q zop;050M(veAFI_QElSvOt(-=D)3-Z07Ei$*h&U>w!)NfnN?#}rUr?!lf_ZR!HsJg+ z*SDLl2O+1cX8}w-#)WiS4vtfP>sJq?MtniE@{{9F4j3oh`g!p~bF<;2)O_efdivN} z!ZKNLXMpCP4xctF3R}gZ^1~``g`W`oYp6uW*rZ;(xD7_$Q)OWLRBeNBHNh|aL*9a^ z(@XF7{KbOqN$@c&SWKfINr`YDRIHy#f<3RYcpE)$jBo6I zeaU_8tsEP{f2i0Q>q;FABOw!Rrng}CwxtLlsX~o(&&4|^W6Lw&$NNKz{%k^3J zASjoaTD_lCp6Lg0F8&;S48+BFOvd_LIqoWvz>NDAe)d$n@DT>lMK<>U2qj z95zwy#cu!xcyIuHR-jN2GfZf`ozm?;OTRJj{3m6B77%yL05+gEZ!!K0dM+Qc2IT_l zas2ZsIfD0XZucEAwal^TMDTJg@UisSNvQSJ(#TB=xbBV99nrgRmS)mJ$hvlJJtFQK zCC3X@%!n+yBn0F(uRD5cPGRXbUQ%`04Lx!0@jEN$M+OMG&a?tIMF&f&lFX3SdUaK& z18+QFcCJKtzKJP@!0B8jc8!a=Fb5; z!ADfMDA8%4A=Vk9XLkW2By1>BngEm$0}~DZ4@D1ea8j6ikzh12hvw>pkxRAO+3u$T zTI8&f*dcuJ=R2Jev!KAndZY1BkFWqL9K}w-mgVRSe?x&k+kl)W5|m(?ZAA=T7Zgxs z)wozV1!ln{?nvjj+smWm_wxjHiuBfx%ZVlAlsc|b6@DMjvwS}064Uc-f&-tSq3k0U z3C$~E)U-Gv;4P%Iof4#=^p*fzEft!3w1%SMQz9qgjd4GKgPWuG>Doqz)Q!I-f+B@l za(ipVa*oeGGd=3dhIZdtKrSxhG3*GSzg4aA9$<_i>~5STiTLh{9zaEPfsn8ji!TK) zy$@ZKkqmJfU7ueg9zp#{uKi^f*YSgyl_% z7fxppUT6M{*kVz`xQJ5?B`j%&yjeSl*qg+QbwWoeB z=O!?$DV#1EdoHpi$9!uAWyQ$(Q_(5Ys?M7MNe`Yy{4qbn4)QYNDGIb1xCx|t8ao}1 zn2!coMP#*8bJjs9m*g36Y-L#{Gz~fj+!4pj#N z3Zfy_^#M0ZvUV^YEh_Z#^c}Nmiw(;4ja+3g+%i?!C-<=#zRKrdc{LiX?&dwFw!taV z7qb0sCFN((V*Nu{#`9slcjgX@yKh8;VTIU&d0-jI%dKYR@WR1!tUBlA3D#JDK=;sg z!e(iA2#lc?5xprAIP5w^h61zsK>xOs+)YvS)avx-Bzcy2gSM5yAyX8jwNc}czS+k<#RiWuA%42vL`~SIhbuLH7wW! z`qh0JNRo;bd{?JT&(s1c@{{qNgp6vEXuj_G3YH@HE!?E<39?Y1PmS`r*jo=?Vwmp4osytWSsxn?RkJ@uQ zj#Rd~$*zV{@MBPbTX{DbChdCmI(o^kgr9E0)b-D$Q1{jW31)MaxJsx$7!5%3%9_1@ zhnQ;ErR5pce!?2=Zl|S8^&ws0^c;Hvy(tLrWm9HrG2MP$(uVLv0~#zkz=#+3QZ5;uZxWjplXp!i?A0RYE0O_Uu~w>bHuI_dTG55ZKxf+Q;{g1!Ht;p<)KIqd-vo0q z&qeTP>&=L5R8F%4Dx@W5BfWMdBQ#i>QR@3<|gWA$)SI%XlE(`?b5 z1LOAa2<`AhYk6ozIH*}POGLBOclI= z&>~y7UN>n%eUy`5RqPiIq4QmXfW?kH?>{W>VCvJsuioL4W1}@6`*X}q&vXs1{)mp@ z#Jvtuo>Tj=vi3k#9&S~5DuV+Eu7L@`Ig|4)0p1>2)V7(x z^t*)g3q5dZQEWN}TciApY`gY~%Txcz&J;s$;^pJ=;%Vm;W2FQEA4fYRk`bxM&T~O^fFJdKh%pBQ+k-{j>3^xBsFVu>Xl=Nx z#I7=265Sj!vL17}wv3Ie`BJdpXK3f)dnoO`9|O}}CD;0q!27)pA!~-aP^Rca(T@lF zck-h5OZ(I6^ER_MSHexKlLtF3`u+-yY1gR?!TtWf55!ew}m5Ow@p&L)d*4=t?R^ zXrqVo=NGk0h42FxQ@M4Nmv*9piC^kd94z^3Dv+$H*CvU3qVyvxosXpALF?b(PuH4W zuR}Qja-epN$V_x=i%FzkrOYLth0{45af#OPSXA$XDESK;92vYYb-Yer-FG*LA3-ae z$~kmHNZyZY8F_%=W%Z%nz;r((d0GOe;8B}IvAW_}7Tt<*GqZHlrVn^0PMMy4mTeYY zI&SChBsW7(JOVnXH?ba%&AhkhJklH0dwRH4TUbu-=LqIRVfilZ!eAFvu$2Lp(4Xu> zMf%GVPB|)V28SHoYln00N{pTG zEIU?2_V&ae$KYiunSA*5g zS2g_Y;Qm^>@)C}`z;+&(j%@##uXx~-R|{Li#jEK&r}tCXLa>Y&y2nqyUSOO`pQ3)7 z(~qvt6p;QULCew5sALNxfRhDC`;yc#$!r<_KgQH4Mv-hkFof$Fb#!o)1Am4u^cDWs zz;0P}CPoVp3aHEn=>|FZ?&;`*J;HbvK>8flXk0s&W>X%vV_4|BD8$1BY#y_vZMbKn zui3A{H3Z6AquLwsQb%g;NFw(Wzt>@L>X9?wuuwRLWU8P}f5m~@lczs1Gq=4i>ss~s zebpx8LaO(XyM_47j31~%4KWAj62YIy!n6hEZ80OTR$^CAnb!yKBqS)nyQb&9#80^j zt{Y^GQ%6Nxx~|@ADY4S%6Jag ziVLC5*X$Q_Q?4w&c3-1HY@t0@sxCWq-VJpkJHc4a;jj|-${r<>H}?I&QrbvtW4Ofs znl3~$wGmTKpxv4akCmZ)PF#v@h&>*`-D{vryT25!#bnt5b6#DyIFU60^SQ1hm7 zVra{Jjyi#FH3gjrKQav$BsIv24MLVluCRAu@!w(OOJ#Hfjs9G9ilqat6}{B3N$) z3!nw;O}FejXeb=z-KOXTC{3q8F1D@fC23^o)}OPl<&gp+?9MxtI=p=(xAJ|fH{MRv zFZ06Q{ut3zld{;X5ce+NT3)Mn5P4_JyxL&Lg=@U=dAU z?kk{I60YPy5DLRdmTI{f)zP0arI5L8GttTHfKhHk2M3)(4-nkXhv{hr zF?ZNbB{tnKWkAnH7v_p7LX)FVAX8lG`0`ziaFBMxtqC*96Eqt3l)k>kwEDDyj>TaY zcV@WXt+*1)=u8*7E~=uVo5XI~(?03u?aO&OQIkM6#0xOI!peyBw#y-)?_+2H?Kk4( zEb3`32H%R4mSTwUZ1yt4e@~H9R~}%=haQ9jX?zk*|0?Pqh1aZMIh8qGcvcDprp>9Y zISWd#Y!$r9rL{2jIn(kA48bK5M*u!RdNe^G2z-fRodfk-(Kfl8(xBb#oTtWICR*~|!bRh6bHEO?44&y_RwreAyyDCceD2*wG# z7J=ndd9a-FvlN?#YY)I(oWXaLR1r0>OqjNJ81A_`t@qvQpO+$}xLxz(MtjzPFMM<# zOpqJ01v$(Md-}r*DEVLce`WCFchtHGy1@f)D+T2lbymGcQDNlUfB;V1{eG3t2HTMw zC$Izu?RJb>U0TxP*e@lAh?$y-J@(V0?$}V*U|z&=BLXXSm5)P*iVu(m`d*BBWID%b z^NuT}E=^2JlB#o$#TchE1$xB_G@ zz0#GtK%75q757nLq$z^ySu;z0(ydb*=}C+A*4j6w|E=t1k}VS{&Qwlx`d*F!1Iw zfX@ifj?Z4hFWtIn|7SLs-xSs|H-9#NE{#my&ijV zxdJ-AF2XpUDAI{yfPF_z61B>MnutEynOB~_4%)6{fP4>c{nCGk23l@R>mGu z7DV|hSr5JCl15*^DD4owArpt385i-1xJEQD9PFyMZ6dpuOjI~7L1{t^*91#GQ0f_k zqW$%j4DUeEdb=2GI0}QW$Zhcc4W`X#hf#dceg{j07}&ov=X3kaBOF2K4*ckETQE1v zmvRxchQN)B0<(9Z>|6Q!M2Xm~_Q{7JL!vQo{=V|QYKq3TDSz#q$VWmQFjdzT)|HCo zgK>@NJm(?#`{{VviRI-sr$u6u=vKZh z_=XU8xS*#F<)kYXKOr`-6idiu`#omToN~sKdrnEvemg%~gBaaEoLcIl#Z zm`63pdHjRr&!8&EBP-@Ezm~(~K+ASbx{PcX*W%KlmLEcldM^FhJ@>{uqHGy5nQM{r z4}+sha{d&}S_kq}Wv(G0XlN8LMz(*D0V_3U zum6q^1#fu$!jUuAQ=hpNFg6iIb=b529jG4q5u}c|;U7?_7?ZJeRLEr~PrNv3G?*Pn zo!;2ys9pJLynh>1iJ=q8(9lkRo^@Vs?nH2rR+FniiWXHI@xptLo7Hj85BaD4Y?g{| z%QNo5^vF~g$F*K4KaSWiE$X|B_rPBsFr6S-cV#KI*X2Xqf5bS?85bs_@$HB3m`A3M zpU1S)FNq2F{fV0W@(g>Z;4Lk|)R8iQ-LoDk{7>78aC`!mFdpWjNj)?KnL=RP_T8G= zg__&fsSpF+7-s415cGpd!MF$Qd#`akAYDW{V~*YaLhFIk5F+s7pnU-WKG%j$;1o@a zZ+HOM9)-S%Gsy(gE#;Se1YhS2=rNuM#(X0B{zxiGC~0PVeP$Z8aJ|F84O~7%W=OD9 z(+yzp&B1WOV+W15QU3yW^T>2AIwp<~H4=!XK$yBOUOd0>mT}C#U=Hg7cVZ!jYEF{~ zHd5fII#%$q)_OX^PW$&2fq2E}PWgtHyF#P9nN}O)`%BNg-~kRB&>7i-878k-D^a+^ntY|2Aky>(j6S@P z+aIDPY|K~t-tM^Q+W9_#XrvBytAM&F`{Z@NK0l+tI2#9j+NbgJiG+h#(is8Dr`^DN zOJ`n+9Uu`FB=CUQ3;ssneMy?Q;f06EogICWWbGf301-XNj;n=;Z4vwxQkU#JIsJ2n zWX)iMHQFi>vx3tZ>&GX@>5q3to5=Dg*U)^Flu0Z`HSQ0ojXj`~g%spr5PS}wS|FJ1 z28rpM@;Kb@tzIZ8l^BuO&nz+Ijqzs?T+Bzb51BkZw{>no zfMk6mM9?c$rmL^m&rMR7u24ZK6*^R>*VQhASS2^o!QTXwUuR*FQiW!0_mbB>f`7uk zoURSum1@e}BegyIbGD&^}KW!U`md{d20igxCpjohhH(aNn7`!nqw zNXxMi721`-=Je6NAGy6WeF89EB?^!co>=nj9zqtrXq+5dffP$|Li~09J-pQnh@jg| zWS{Q|DwG^iV4G`lk^kBi$Lsr4zKb=9Hes2dWW=?A`1P4(5LTOR;Y{?6)CCDE(UnJ% z_$@>VNy#dJg~R1xq3di3Xj1pDwDD8jMF+212{tr^`s0BhEX&jGV)qu3NH#(3_3Y8b z`BtZsSO|WBSTPTz`mHg19~sg7qsD7SHt$EcCsJ$}l!em{W%}KRVlnFZtT0fJAXd+Z zz+qVT!c_=sbPZJoB>W@Y-T2@TD;Mn&mzCXy038Zhzy&|eFpS>^tRENL=PanmD6I#+ zfX5vzny_v&-cAIR(^;wK$2@m=zAv&Qw!=@cRLz;ER(u#}g)kJqui5N(ynn5z34qee z#SfK^l@@q>XNaVNvE>DP*CDp}!h6xZb=pcj*xD-K@4VP8?|skG{RwZ$XG?r&J=wfF zu?;4D4bLm}RRKKVgw4AVk~%bzTT#!fgI`fn{_WxKSCYMgT{`kWln$k6nT8|9t?tzl!3LwYNLTtTX+g>lx&*6hU|Ul|;Wj-O zOs2OH2#2&RDZd?@DTn$68)9bI&H-qQ$O*MO;wJr}*nKVK0oYvYU(NSaj9ble>&d}x z2tZ0;4B20Vy4oW^K8pXj^JpV`UWl&AcUg&ARI9Y+Ubn+~F{?P1_A1iac86koI-IU)a zEV~=k-xla<>hyVUsTySemrh|Ws6@yKpcSs5VlnuW54$J(Pm-sU)G0u0=a`;J9(Rqe zuq{E22D9RMAZ@!I#h0lS^!9L|t_IU_os9@B? z-ovlVjl@AsiV%5<)Rqk7&FBxJ%$xMtVhmH;2mDIb*kKTCdup()+s2Li*j^pIuZOQ= zFG>QP=3^@yfGU@t1E5^pOWA{*TsDyvlR?(4d-kQ6t>~R_e^eKcKv@u*Tj~@%7D{?J zS71P`h|(I^;4-vvQ#-jD3hsst^x-nH1M1o(8X;D+M;r%qw+zF+L%%oJ(S#c~N)m`e zf4K{N=bT(#P4$KCUQ*SX6B58@O3~$?0{R~IeKejiU-_5=cRi&k0s$wxovt-(nP^y? z;aeq!d#I1fQ}e9>vhcbqthG_1i}Sa=Pnv(gmGNGW&O+!e>GLJF_PJ8)GhzGdpYv<% z!4iG!tGR&fZWNk|4lUmE%`Da-dB8`Hpw8Q~3OMAgRZqHLrey8ppq9oTLafM@*fqB# z`-Dk!PQ%UO+$ctNJ;aIg1HFF@W;Xy?i4sneHzV zA6}S$^c41hjJ?Ra7uEc>TNB{b(u}krlVg5 zLWb7-gnC3~<^|qIc8|PH6H%i6+Az#Wc$49SPYSl4dq9~jB&;TdVKcR=r7mvw`9!CM z*#I-0F=|0qlDi_)7%jcuw&0E@SFP3Ry@W`69m;&`Eoo5_)Ea?7%N-l@A$W3DE02ON zg-ZM3o}gY~E!e}K8ocyuCoh2WTO~Rzk&m{rb}y7eUIw~9?~fEvz68u&Bb;la;75b= z26`hJs^2W8pc>({wNPuvvfg{OdtkWA*s*`gztx{X8?|QKjGs8(D0{OV1(9*&g?h!n z&bSrx)*U50KzsY(FX5Ud_$XKhdlZk&nSb#pcYXJa8)e-EEL0Tr^yt)>vg=PAUVwBN!g_5yZK*3I8kjXNp+ zLBDi*=*P01y87r7G5%z$EnP4a1ono2wDkwb(QFJ!K@3NX;%K-m>Cm5u7Fkh(8%3E0 z%X8cRK+Da^XT+x;4&c6?aOlq?Hmu5mKFKsa^m-U&iG}JXo9j$##13#&M_cx8RaC#a zsus`-ifQ|`ASL|kH(4i`8zEZ7uSBc@%UR$^Z!e5L_nx0Y0+k!}1YaR~77z@-stBJK z>Dn&eZh>$T;$EG(|HV>50vBKuSQ4QAy3o>k?382)+-1ECMuQKO0N$tZ*>5hi)Ku+nbF1|hAK4CjX|q570_(f5o{}As^kkXx!F2&*=1)X zO9Q|!<`AGQv+01_l95Mz;IURi$(Z zc2ORjgrAHAi+H{1IElk8Sn`Kew!rLkm|K7gmZfld z;P_ixM?o2>Yf(|~-F>n{EP*`-wCi%o>pkj1i{iTYH65%OX$ZAkGG$|e`$o#uxW1GB z5p*0bUQYYlt-cE^(nh<|A)16XwNLzqHt{6>^SMz z>e#kz+qS;gwvCSMbZpzUlbbuZ|KLu}w9cTO+Esh6^{zJliy2TEXg675)cGqvNuPjW zWzA<>8cjY26BtuHU!}g-pqzP3UAw5D^pM2_wo{=x4(}g2nJBgdgcLKKU$?92rLq0( zE>CP8_Y!oHK33o)>f^ z0B3X|v2PY>w&sw2>9l)qXv4<+&6SLxU4k0T6Mkl(a~Y-^oQ{Qrx1fBj$3jRhnSBRIJ^l3taMVZ71#8EA!c|>(RIfDcvUItS?5`_ zaf$LiRS|EHEMu7hD)RS9f6?{?9;g8a_(Pogzwq~@ez}BbKm@Q7U)an`M%S4*v)m%M zB@k*3iv&(#elV&d_b;F7ZIhKc_y?=eSabcGS%StW`U0XZsB!xKdl6dB-Pq=coqE4> zgG-TrXx-Q_=TVG8#t11S45Av*dy_bxcdi<$iU~w7NO*0y8H2NIXmTv5X~0B5rwMIY zzo~LdTwp>Se#Lq9j?tcfhp%TCfN;NI-t^duP_(xvG`|L=sO!mC0|@w6Fpy4ipg}{j zDK4q}kg4oC;lGrI=&5JxXGhe%1w9$19@~;3WU$Y5rzd|=UB%*p5dVvv91jF+3|4b% zP_3+2YQLUuF>PgOS8cJDJHCc2uL+Ue42A37<%KOSrJWtmuf>I!o#zbv-L>g>j>Dtm z@HL=}RUk6oM>9E-v&bHnmivL~-$m66gq4JNG&o@T-`C^80#k|Y zqN@eBJ~td&eOq1k32{pal4&h>E)FV|t3$1-6E`}a#-taa&e?t@7^d^2sT8B{9bB66 zdu~F^lyuQ*lken)BA(W&S?^j(?wok~vc-7Opn46dSxR^^)^kpoWc7tJXz$$&fsICbToC;Zp4-ch z;hx>3VRFIur4;c%GfkuWm^h~+MrDqv>-!%Iz^?Zb?vFS$|Fi`tp|f9=(?CI6f<3zG zlS~mlJxYN;l_my(7B2aK?32||qXK+;@%-6X51S`%6};$yQ17XkV#%o523y${(2-s5 zzkc{UKjpdLPgXeNnh_rq%u<&Z$IyqrzVon8rogpui^Rr6pay;P=1!?lOhE2sag7F# zG$O?70Fz(Ultb`!?kZHP)~7` zfX+1Wi6Q&=OJY)n6w5fxuWH3J(hRSAs?iqlye>iY=diROtNEgw! zr{M$}(gx)tI93;adL0BB`g6!uBuG@bj8$CIUyNlKqiT%u?-@V-2~^fI#$TSBZt(JXw@ClJ z?`t2~c9%$neC*cqX>Lb@rVy|*Y%Ut>kT>2NiH+>Ao`gX>)+Z{Fu8dG|pl@c^*wx*o zfcTypL8Q5C(hgq)7=*Vs@+@Xo&t~Sns>&Y#z? z_|P0uDFTj-92!5wpRsv^0=Wtfm42J?s}=P%KYdVIqBB0Gbj*!swEVRUE)^>M7gufKdCrJ;xmP){kM(m*s?|FRZyB1H~6@dJ?rfvTpx9aBXPKt@! z!Pdh${?E>8FFay}z5cT|n-c*5KMS4ZAtUE3Mc6I(6iY@w zwHFgUi^ZiaVqA;+GbT>50T|KV=@YBLqVlZ&)hpI?f=_3%*-g0v6-??7Q~MD6zE{E% z$hwnh?fGrph!PRP>+Z}??O4pzylPw*Vp3F>y+Kd^XY57l4-T)mE@cGREukqleI01+ z&kfB6#@l}a*}h=951~lS;vpN~o2iE`w*|lTu@QD@pKIR8tNV)Sac7W#HDPx!gxQ2A zmGkHzs(A(!-uB!L+_R@^7S$JN+b^5ZeamYR;*$YUOTT>waOve!QHx&lfR{k148WYi zf3d{lje@M$oKhr@`=>1xSG}mMDoB}v!?g|~A(wlMT8BrnMLfdNMfr`5ZT!s3)cgX? z(mP27r>Po;0o7>*Ddsy#xD{NPOgcfTKHSQGUFbyb97y3;9tA>P1La_MH2aDY6&Eq* zd&x~lkA5@N<0jtFsu6fs9*~=rA9JTV?)8IykG=X-JtCXK;ZRq$uf!+ppm4T| z1QyUk1Iyo*_M1SMdSDh7X=0R=wH(*u`Jxmxm6G;2Z#U|8M+>1>hzIQGUA1o`@}<)T z4$Qx0hm=DllHVkpRTo(}+aJrXRYM4+=W1M28A1=??DPW^UQ9s>D*$DCp;J7Li2|={ zB%dBx?cE~5zrJ*C6>Wbg(ua-$Z25Sr;~`wAX_G#}M`TP*+YxO+Yh)!?XlEo&+46K> z;!ZY>ihzFWQbJq7e9gH?XM8hWRQ|uT2Ah5&BOvqZHSp!YW33C(%~g4`4p#pfK)~45 z0Srafl0+zUre#M7Q4|S=$czsB(CDYxj@GC6&(%A%JTNa_bTPL#GK9^X+!*%XFIV_^ zU~*AwAtSt-+YZrfrkJqT!}tR|xJi_0(yT!+K5_1){LwsHt54gmhXwvSEBsG;XD2ON z65x_|h*HB5g&xU<28nI#e%`WX8?Rgt&L`2n7+eNjb(~fhY{f4LyP5-^)VRRjL2idB zF#{CMm2US5pu!+_~68XNai)hg`ev@ z0REytuDesHhd8el_wPV>3RCTN1F|=_RI?PI@d%qA2IuES$VgKsk!qu6X+<$H#?uY= zd|SA%G@CP!B=6x8xIWT5a;r~cuOyo&GcN>L3uZtZWrVja*JfUzhYaVv2uL~t+#iRb zyVVdPHw8A3t6gt|PRzG*^uj z#)fo0quT6W^W*Y!yem+={0y3`3qypI>YZ|z17^xmeTUeGaa@?V6ZkSqH(|oLL8_(} zF1W6N;!lA#3`u*JklgtAG3pFPj@|#q2h^c_i8=1_fUI!)=q$DUIL*E7m_a* zn?tljTV8vQpTGSl)mOxhuMxiUD@yiR!7KEV3~R-Drg65%R?08p`X2t)6}@;J8J#11 zJsJL{=5mEq`y*qgS%k0GZ6SP~T2Hv+Ry(3ZK+oq4O`VTx{}U}DD;$i5+rT)Wgys#p zM57piVHLfcm(d>_b%3oBT$AOYKk_@nC+#>zbzbbQrPi|_XHusCr7KKVTEq&6f|PSK)O$x=gK6zG8Ss zRh6FyNEE%6IazqXVxFC}y%peEHo}V9G6NgZVoR=}4q4U_o&`$&5p1lE{)f9-5;k&- zd;I7L*rAjQ`b6!}3wxQ)hplKWs>7z~5*i3*#zd2ef?SraXKLCJi(%T?py^e!PCt(6RRt(Y)1)Qfo>@m!G$~g`^_1WwkC$Y*ECF_jEc+R24ezo zF6S(@`~=7!eNKS-e6>4^MA+>xe>GwF7&fP2 zVJFFwm7&b;O@OVGc@{#5ZjL_9jjzPTV;mEhQ03gHpMwY1lpk(N`i^BkZn=k{A(ojp zQkE<}Jgu}T%rHL+H*%WB`eym?B`5zgKeKg$FUeVA8wxz#15cWHSRFu@#GE&g(H{H(j?YspN3+R zBv&77M1y^ZKZVb7@7HI48!D|<#nt!(n9~;sE8;1y+&&jy_bUL~-Tt>?p={Xdf zALzZm6?4pzvYp-X4Cna6d`{^df#v?wTl6`y@z?((vUzLXBcjtP%E>co8p1I(8#URxO!SGwDTe=iFl?<3#ge6v4^-Sg z2wO&=1iU(f=wKJh6qP6p_rf3M8aqzO)BydM4TrCPx&Bm3Vh7+_OdMA@mSx8QfNX{VP947@rZy#u#lgF3<2TrULUa$0Z z$#YHmzDX5kXe?xrS+q3A_5#Ck(qpsP<;Zoa{a7~(&7l#iX8>Ua@ou7@Yf}UQ^#aMk zdEEmbrba>(Gn1ZhzW%3~v6>wIn``?dTxe^dQ=?W=HrN@( zVA7JM2T|xC7FvZ3O2M0yu83yiCS%0Dd>rBw|8vnJofL=i?ufC*Jk4B9Rqh}kU{wp> zX3?I33Xgo*4^fMl--zFr#-U~hCUy(YU$ZaG84X)eLo;vk!8@z0=qQuYL|kZL%bn%Q z$YQDC%bYOAjxN+QNUlLcq~x1=CtAAUdh{a`u7~Ka#sptDDD*>BQzI17d(9+%ySM_2=4}T zp-&c8e)o;KQ4BU>Hde)IV4LBO%pYQr-eQK{0SslnGwtC2HqMJ?h`QCZBQocvS(@gO zZs8;GsqgT9*@%xq`o`9Jglr}9Hw?%vBF+yK&aU=~EAqqfi4{lMh1h-Eyy=|u?r6$B za)0)06Yg;w`%YsDEPMt+uV%i@xC{e$H=1lrpyXZSXzsWyJ{6iSr_z5eU} z!j}Nw9ffu8X2iSQOgs0h5CyuH-T8Hv`T7l1%y1!R2E84{gBILw4dXuwaVV+cS+eS?Mintuz5l@ndc3*&Ee8_kAj)H1B|HR zv5|T;Nf)*+opP|IsS@J@f>TzOgwHqhoJ}WB<*xW@?Y&IM9-jl%?Ex9`Z~$Z+@aWeW z(zk-7Od@1YIE<9^ZWTvw1A++{_Vn)TBLzPhZP?6n!yBn^A0Z(aA0FBF0MYOUnbX7- zhxIlBMLt}7=;rt1YV;Ty#^Tsp(_%wz?U3=<$7deB@@l=NRs$?fUEN+DD~wWcb?Txc zb}+DPSeH&0@~4t`qH$~z2eNdBc@|*3VJt%r7Rt8D33G-&{Byo%17S-7h-wC%*lcdz z=(@R$p$eJMr>BLT?O@y}1h&(;d@3eSE0iD#lp=bhT^F6Lwm;YK1eP zxo4OYf!hM1T5)a^L_vrfb3wlP9-35twk~^xw8SSQ(u`{b^Yeoc)-sJ-pVX1{`rVuo z)xbzyv`D^`N-_GxT^~-AO@tW9qDcE?EZGuX%Wt0jLf+lRg(Z<1`jm}NapwAzX782a zpUaDiSRSs8$G6K%QYUa-Cd!L=k*~&z#v*h{G$Z;iPKsgdiXAFiO9Sl=_x)`6vAg9| z__OESnVjVyMyS5#ze>sMH9`JApKm{LB1>k%9O-{IcsvhOt|v>Xpj%=Y+a0#L4aRsG z3&$WwDtd#(L?ewK8bKN((|}(CRFgO8)5{(~9$hwbAQpewx{qTQZOsX@XZ?ug!lR@+ zqnNq;hNj0gZ`rz)_}|^TpQv2f)YQ7R-ZQs*rf%Un(dqq6zf(9G_&4_N38m#Gu=>{k zg9z8=jeD;fyRAS++O^B?lJoD&v9SoB+wFjV7jA9iors1brzlxL-J8FkwsXqY6(1X) zm1CdHMbn$kjpRaCc7NS#Jt^AK#g=%(t$N;0J4Y@zzeG0{L|~q|ata`z=wdrp{?W zk4?6x;+k0aHV1%&-0wo*9FSfyKHQlxcb)Dj2oQdB^4X=CxZe-r!i}BIkyCDHt_++% z!~a>ejI@>%(!CssuPhE=xlX(DF(aolv(huy7PvQm#FCH5r~C@1xRD5b5h4OO)yo4Y z;zrtIV`-S{@xD3tE-bt2T;Z9}U1I;@oDtCf4ql6}>Nk6D_{_ywwjU|rY(I^#$RcP% zw&;xW=v3*`BEH*qTR<*6wX_x+L<4#9o^Niz=m%$OjTjAkc=Nunca0r8-%RK=5e4=3 zo!-~g!?}IXq$N1S{;lSP<*_ufe_z3u>*u-&kuGpY z{hU(Va%i|X@o2TPFd`0t4qH^Z8C*KeK9b-BiW+q<=k~+yN37J8DJf}G{|w2oXeGK( z&$E83QFe)$>pENXOm;BP#xIF#*uC9NAYb$=y15{DB^ouYR7dQ|#^Uu%~9#zN{cpQev0kq1A5tf#W1N)N`22gTB75i7Su7D-iRq zUIe&okMw6nd#%E{;Ow8)HtQ1phJEl{W}g_ho*IO;gC4`rS@NS<3tpp)qzvC`{Ja$V zHWg8SlD@)dAV@Y8X#YEAsSdH5=HFxt>Bh;sCG(+s2Es_&met>o8?4gFW-XpO$}E&t(r*26N4B4%6F%^ol{QMV5>w;%67#0dYk zr6=xL{BlGK9dE8(uHK`rM$7j?npE}$6$w8CX*DU)h;+w8K{t*TV_{!hBCliSv%~t@ z$&HbGu`Aje#a-rc{5C&V$9iz(C1=!&?bpplC7lmQrTKPb@6jadXJz=-niGsJHklWrC&kHqc6>7{mPlVi{Y zLjA;tC8HDjBJYTX!^PS8H`HCdVh<<2(JS7i&RpTS$j{$?HL7++MkF^rs%zSWWq4k^ zBS=lb9=wT6AghHFkKb2z`0`?eQ3jr5;_y8CilEwUI1`yzWRgM1eO)%9V;B zwARz|Z4jeCF$*rE#*PSPQ0Z+*A7#`CIhS5!D&ROtWT(i1HQ|PB zI68GbNd+M+*l-2r24?x0*gtYTpu&YJ*eQ|^GJSbAdIKjHwgp?z=&KG$J6`t zE^9OWDu&0P+%X(PTPM?0KbsN;G7C|SocnC$x^}6D8V>;x($50$fL81%zF3N%?R)CM zRwd$LaIgl+GzcH7Ne;eJoI2-8nf5G#RvYk3smg`YBd(7|{_z`dSLa~u zU2CGGjTh=A`oKhz=7fz{UQRcrG`bFD%Jm!t&ZnR}0~EK4>`up>R69VwwL{)3i45O7 zjmyrEz*LjigRvF|D`6a{_95`}pyGTGkQ1?>ple*_A!_jLS&p%K+ zAe%YulJ~P#kOBv0{x&p-ue?E(mk(;aQFlKTJqv~!19iic^1F|ML??0H-)G(Z5=$|5 z+_44<@9sp|;VuiD(kW)XO_b)8~S}%~QI?iJ1?q z-oMU6D9d0RpQYl$2?X)NBr9tK9+Cw*rfE@9jG>~VDv9EyZ+(+Ha$$G&$*ZZkw0}T6 zAKD{0oF;qH40FVE(N?p;AW=p<2W2L06Fw`aBc&@ljc6NSzhZ+FUOgzD$RV%*a=3WLUrF`8pG;gtwcmc9S zYW}ouBDcXW_pY?v`BO){f`LP_bLa}rkPRe|s3I}F-r9c`jz=fzjt3 zgURIt{yMgu(T8pcnrHRydsqZ`0T7RY@mCOo99QCgK@L2<@{jvT=F0s0SCXwFbp)!# z=wke1)d7J7wlT4foysVwDno;LC#Gehz7CEmpzUN0avK@iEc^TBn{{9lqd(9MJ zqmnC-2^EVP4XJUY--VXw?nF5ib;-r@0qGYY2tJ86y^`_J_W0X-Z- zZz1uJ%U*k+N{v%L^jz*Oqsi8iubq^=Fo#8^!JritSHI89)NYf257?*GcZw&XbY7t^ zAYA|HM&rL3jf9(>&{uCPg*V4vpJ(ag=}SA5@4zWNKm<0y6dl{Au0uwzn)IVx3H|aW z3hlg>emsV(%YqjJym~GgF@Ro@mvSJBIDV;9#CI^*Xp2p!n;9Z$M75y@o>`i{CXdvO z%#`tSx4$6vL^+$kg}0P^1nn?+LSpxu82bjXOWcSzf$3TPa0M670jtb`^iZ~05HF$0 zRdJ^s(l2YsmfXVSS`Z3q!!{S6Ps@V@cUXAC&Uu)z=ZwXUSVAYwN7*nKm=G zgiHeV^5~;YMA2gj>!WU#As;l6ar0zu@M8%$Su}FFFASF))WhFX=MYnSl2u8_3aP5| zR9WB!tp^?QR(Gxsvvjw4ZHf)djw8t3J9?FF8tuBgaMG7EWzr+|ds&ZH444`Vvg+Xs)IKBW!kLaKCsyvuk|JYa=HM#hr#TFHT} zxB_K8(2#2`PwgBP=u+~bm$&qtxcL-ny>}IEv@jv`>=m2na!xKa+H@KXRaJ1&(cG+|e$a^>+t!d#+g5Ykgy}uWUhqM; zOT+Ug^yfCTTmliLanUDirM41iv3+f1`ht8hJ%bO3r1oXNcX2h^KcOF+Xn(MpDs5nw zxvE6F_px4!_^LkMX#h^63c|@~L+OzJ98!sj9g3-Uh;IS{S@BNl@Dsk2HK8#_OLE~7 zw@V5VL$S*aLeHQJQp?KP1L7H*y{#wY=Dy@U6uC^Y!{+#Fk791UNP!v%{eDiI9HOv6 zJtpHF#9amMm-Q(q6r0AY`Q#86JH2*DUE{JwQT*e!7u*&r>(Z}0c03ON6T~TVv5@a= z#t70A+?V9!;4*2Mi+gR59T48eV{aF( zlV&!8@eV!>ZN{-ENcIDN*32a7pJeCP5;O@a5Q=>@YN%^%vMP`b<{=9~1mQ%_{$d09 zQ#WBZ}A3ulev9#w0coR|BIz)?yH=E9WzW*S}gg3#84L z`#fqNiffU--}n)L1&*5aAX5Z-HR)BUYi#kX75Wz~^V|LT5e&Dc#f5kC>qG~G^g_tv zSVv)%ZfBebW;Q;!(`bPO;$9zLCI@7MF)S;%X~oG!3Rxq()j0(?B1-ayIpLf=l9)lGz{F~k^t2z70$^2d!+FwFDVNi#X( zn5fwsx&8slOJ|jRW|as@m>d~?;e=m8_Qpd0maxfTxTu0UnJBpnI|3Yrzsy3^&v|f` zDE4a%do1XMQiVt2CM2(SgN>@+Z^m;;FVBLGyeGURy%x;;Bs6E{#pk=b?290CsvL2-Y@^S_Wsq=;s}JxgkQWUuQYz3R97siWJXtxNhw_U zZB5ZP{^M2?D{Ktx7q=56^VH&QO`cw?jQ#wD?he}bU=m~J#HTxsc5Rp#TC>8&fd;Uc zbQr{Qb_#&DGZG-nnRdZ3pfpNnBSNlKTqNykRtT04Md_(it)E^Hn|R7Nn7-m7E}ln2 z9=_$8UXe`|9HuMp3Dw5UbQ$|=RlQs9%5tHRz;C=cyJA0osq!TCDiCNQ;}>OecvQ?P z5X2Vk5Y+fbindQdl@|FQ^C@GojiUga;~IbSQ~vKFagP<>HrGF#7K^^M-aypQ=T3Z-LWH}jO?Q3_R=&)*v+hs&x6 z7y$99CN?$d;UxOInxrQnePOj&Gy&zr3L~RH$d`YK)L3IJby9Nj^gr&yeCf2T5-MM@ zLN5lClt5#+j=M|PuOH0|?;+w##qk2IS2Zakn7=A|&Ajol^E#_`gkFYca1mR|1BeB& z*sI8%sM--49GeX9*nD{-!;~^#Vp38CUdqR=))X{>oni|6Vd+VW(#~kjTJZE~xuro+ zhw6-TP4#UkdS@rq1I%l{C+SrT-i`uKso_f!dYY`TsL`6h7{!nX_37;iq%7H%xwa)* zfzO_ft^Qv9S2^D=xo*Th_@D}uxJ7@UZ)Ss6qBUn>#`N+HyEEs7_$V?PdlpJ;S?b+R zC+w&{=owWDY@N$z(AJ^tN^D3w@8_0Vcgv)}(5P5ai5tJ0=fZWBL1)tU?>($QuZw zlFxP%Ze+K1nDZ%=V;W|OcfC%_+q8JX^q+ktF3)zBSsz+ey_!Pc(DWXhqiX2#x437m zU5kh!mW`0=t!O4DTFE5dc5@0X-Jtr!8{nTVlCYAp!39JW# z)M*}>;$ba$9f?9p!+xn=5aW*m=>D*zpbY8@Vx=^EHo0C70vEK~k#e!&xNy1vs`9Hg z7%~*`S-gIJodfxTJcrZC`SGs|+urO#koVv5Zw|Z2IMGhcURX&|)RQ7_Nw4lS1(V0O zUQLwCpPt@`=sdET8zRD~Fs^8KytH#&d`!1+`IjExZvzue3Ro}5*ZOq4PRehX@j4#U zDfMvg!#z?jIdn>u3*QSyu))|n_fmC$^;oK|{(VG!eKrIY^MK2pT4_1PvKe%zPwA{8 zGW;yu2*p!O2Nn)y)Iui#eQqZ$llAe>x6oc$tj)@~*MB=SDMy+1lMREMeIGU3xCo<>IBb9YDZ|o&u2*jG!UxtmO z^(!mRmmrpwWoMuo@0+%4=B~OOst{3kUx?@*tx3iRjY=AfvWuErfhl$xN zm+8pDNBDX#q$mT2khCn9+2C{1b904Fb(KW&urzpwtILi zP?(4CqvklKtk8Z8*MzlJW0)-PxQiL6^=C57Rn~Z9zXmazP$&C-(}FXl^oF!)E;KI5 zRcYRQ^Ueo;2O*(gw(zgaRm9lLjzv>3RiQ7br2xq;OV1m3yY7SoX6-ysZv}0QWi}x8 zsOkednf2N6VhroQQ|G!lmn?RM6T`BRrS46*S0SG_~{O( z@-*KO7nOQ;(f2bjX!5m4@j_^uP4?mQ_&8+}K)=Q;6lpF13YT6G18;((B@lD{kBBmJf;7@uIw}oq zzlne%8u0Ux0XP6@*dWtG4z8P*Wuwfe_X*P_+2@MIjI9n+06yI7tSOW55|_GuyPKmx$Fz)S_gdc{3C64A$5>@W>RfFM4*-^3=P#FY;pVda zXz}&-r7^bfqNW-B%B9v}J7i~fpS)gez;qd@)Gp0$+SNBds6od6hs8Z0!-9BCjwk_-|sKv z?6ZnAkbXn@+YK<&3>s?vC(eM-pQWnojI|MO0+_4C3`!R&D4V$cqFeh24T+cl@(6+) z;gs;qp!z-u?1wDEC%ws?{~naq?3D|H7y(If;A(1Y*0r0&Vzn9OxeZM_-h)>e(uW8u zwW%POKdb;$x)Wy+Lqg1ySWGIwgU6ektD^T-906DoL9TNeg@M?fW9dXD&Ja~n<>S5A zk-o++N(hZE|5`@)JZgOj2M6W*{co@D@XxW#W(L~H9s-r}!(JKGH5y|JYRDbw%@?(L z?)0Z|XU3E6?lb7Rc`VkP|AA6UkHV&xEX{a|K9-@J0)V3zA7=lGV)nU|8bc+ep+ z73!&My;#Yrzu?De7hrzq=+h(NVG|p9dNse$2o48JAC6gy2VQJH4+6P&__1%3c0Y{# z1Eah{Q!XEE`r|o-a|M1;!ZIxGa#YMK$GYfj*58#j&czU{>~Mrg&R)zS>V-m};`+Mp zm%l52n;l#a&q%}26R>g&H_h&U*^0A{R6n7hCeZ01JSBi) z*DK%uz>?O_4MJQxMwB@{=9m+n516Gh9+`-rLcpJO*o}1rC5w7j+DZh6;CWJhydh!7 zq=Jr4(<|AgzQ<2Kgk;Qz&Yqkw<%iYDoDN8vYmGasU1PfY!2BE2elx3c&Q1&5Gb8i6 zhwN}1^2&`QQ~-Y&Sh9Bfp&^0|ZvUbg)8TG1xJWAvym3<<3R5tLL z@o#MRNz0}Y<_7@z9}Unx^C{A)?@-~BVKu*VRzT82c*}Z9NKL-z)>YEu?=?U$J{xve zrriSykc)U3qSTte3MJ7mP=0a#%3)Cyw91U+>c0}TCrNV9p`URWOF ziZ3Xb7qOF0tS)y1+me{&w0by=gB`ZSa4@+HVrDa*DDM#afYP1>E&fl3^NaDVTOG(k z;uk!RKeV1go;Ny0T91|kZVLIta^?M|&f4c08@PV>q={n5tKB|PIgl}7 zly=o0YvaJ-zhKfaD0LAIiETBghHnl_+L!6S1n2menwN#hhVrj>Y~>j8wx0$s1TN?3 z32@mRO9Ax1U69L$Q$6Rk__ChJO);+o#lm4xm7jvffDhlLGwJsoJ}f=|Xg7f7q=#K+ zHUvHDr->UpQy091j(0Xfhb@_&e&sdDJN02zr{4pRGx7}5 zlCe{lUe71%lV&0$#2}~S^;JPfSnLk~j@fQlW`&X*;rTK&?#>0B;IS@}O?z@XSJ+ZC z@m?dX_wzrTlmO+^yh5$AgR(@FzLC&bZbJ9UJUa)4S=tlK8e`Rp!uxwDop51|aVLRg zHP87uuez4_I|3;&wGS)>gDF^$Ld80RXNU~Nn0cjsZhPx74N57#0vSI85!g7tD$e&? zy1%s^#ixxKVafMKsL-b*4EA?Ic9Kj3L}$tV6gO?HU`v%?-Z=y5n-mv-Vx!|DDWE@S zydVkA z6zlk5F%3N%9#Qb8W$dY(x|ru~jEG`3lXkO&*7`l=iTy$Shwaj*fXK}~(yzB6;o zKzDUXFS7Q2f*HenL}_W;)H=0$xL5cfk3&Tml(sB5oZD7k5=$MT76#sXPUGR#jB)sp zdjfI3izDGU!(j&({EoLett-gHsl3LT21dG1{Ve3ER-?U-NUbh7iG25IRH^j9=1_oG z!*Ti3crcO=$UexqUV@5~EeP~_98+btO=CvJ0F!!#Z|FRpH-bs1c(ymNku6g*Lx)1; za79(i9fFXj3OKrLL92#vO^ks3@_xMH7OpfE}U+^-WeaD;C-!8UXNw34D_uyq631?=6RE@KPHEkze?p-alh6#xA#t2?nS`b&H} z8uNj3C*-#2-*)NF8&XOzS8Jl(2*w3##ZqW! zmBH6!iU@KNn<;bs9fg=t78EY&WfzjT!7l(~>1q$R)5o9Zg(J_b(1Z0);QD6US%76G_FMUc`H*vY1GnPb721D(F~&ru z-{hf2>=di8xekdmBu|h`DV(S(D7VLC2u7MNH;{N(U|sMDEnGuBLLaWjxti>$v`bW8 zdr8_4i?qc#LWD8_v9#Gvm%;Ev(z~=axyHz#emu3F*QBw6XGeHCH~tlG&Q)-3$fa?a ztIu%3wK@s3RuP*AWblx={^h>rG2}pWXvydZi(q zr*bTj3f?5`apI?iMPip!0VxRS+rJec1r<67$_y|u(~-Yoa*N?7mM5FwrhHiZHzz5e zAPO5N@99Zb&;{d++MdARsv$edgg^g zXw7kor$m6XN6#!i4PhhO*MZLE9pRSPwf^(@mW%A6dM-4K3uSzY; z4~@8gK99^K!r<2_=*=u}$K}+JL~1E81n1rlnNOONt?@b};zUS@-02kt~UN>knMY3G1XDpu~=FaE~mE2iQ-t8Y(GUT{(p zo{Tb`dT^K9W3)-LKb~b~BncG2q|b#+{1E26)%khv$`Z)IDa3<|zBGnx-@ErOfcs5T z+Ea7&nTVMWKD4azN(rFWg~I~+u6a* z-`U60V9FK!>`SANS^z`PZ_mnk{F>T>lPX*QqlGjJ9E6P-XE>I`K7%E1Qeq*uD=nCV zNof_FywG}0DomtkNX0#k<8;9|l*NL*-q(I}jgGs>4*&@UJZnNP8(g9cja~E=Fm~(S z-^oVip{O*Nf#9@3uaC*RZH<8t8^SXl?pW}loG9Des)t)? zu{d7P2@mn1hX;wfTBqP7IQtLy5&s8~gBYHBRq@?)tK-+X4_3u;QHumQFyT`XQK(%{T@! z*8(iMZ6%YaN2?x=wP#7?J~fBYeTw16my;qmCTTbCCryEqs85*+7f=k^xj(o{uUB*| zxA`{P<^t^p2?5JJ;@T>JI2&Zvp8HWGD!Kmg){gXDYiB;9qro#crYKk#mPE zcj!ZuIW_3pW3oS<9w7HyH0Rr?uuJhZNz9llkW*1jnlsqia?H$LkrYY`an6zU>k3EdgiV8eXL!4>k6 zkeGs~dU8C(7Dz=Dc7S8;0wm;?Com_m@k(PAphAr%O7Z9F*5;Fzfg=^&hy7ty*ZVkM zlhH7FfIrLnH3oZ&`sgM^hx_;F{3S+FZzBn}%tp=Ll-Q?-loU{?|Q*oUrt4C3p{ql=zX!Jb#Ll*9oqdCC;9Fj)li|RQS#k269!U2UP zo3H{~M5YcV-UKz0fJxD&i2j;g8jc>I9S z6|sTN{y_V8zsg~`#ejPwy}LnkEt^F|N`VT^5(>mnXH6qXbs_QWHkilFWuu-~71}_I z!KE5DviN3*<~^9_Ut0bE?KSLDeJ(!B=#OHP#3q)u04i)m`VupQ;NEzf22vfOupxQq zV+fz*)aSEvx}u0BU)H3JOUwyuOR63uE8Lx~(y;W46fpZ?O0$_)q8u|c`(r|nni=}4 zo~&o6zshn9U{!6Gb*ytWt}D5=oL98guD2CPG(1M9SLrT`a_4VH^b_L6=nKJ3wgFZ# zH@5Ge)4qxj8T$BxJuk=lAJWdDNqDy1qHWu@p0>@mZQHhO+qP}nwr$&X_t%s23(hQ~ zR8pzrO76Y0*7L@bgwZ5WuSqJ&!UWY2E2bQ`>a3f4ng zk=;*Uh72=6q7v6RuV-H}0uN&aQ4VX%f|B!d+Y)|O7GfiU3P2=Jr>q|I6V<}_qF{T9 zo~Y&9P<@FWx+g3}?t01EF_fqf$Q&qFN68Ms1?gEt&G79h1H@i(pKH+pnYfHOs#Kc(c&MMIq+I&zA9r(5>d-%T!$iS1sq z)M5{_iPcB;WG8iMb=qlCl@l?D>*C&CTS-|lM*yTAwi?>P}$aetva z(%$qp`9Iq?E62Pd5YGmj=(5kPl~U2p0(eqgBM+9tgC-5X1sn7pgC50$!lJgN8Oci- zQ5>zK+VS}RLfHX@`46noI%Jy5iXxvy@w-#;WJxx_JvW%Dz6=z2Y@l>rgX}NONOtGU zqctwVN+`6PNDvCut3t_BfMxl{(+1ma#Bc|-icg7}XHsOzC z_bjhnqPX4!Xu-u~0%{($@A+$`ILEl~r?#Q3J4Ldxgi^9Oo-6qKX#^;VDTvb*A z8{cPbBsS}eEgBKN}(>E7~_V_Ohym4_GxBC6B@(ixxx#y0C zGra13oc$0K09)l)G4hJ~2Y&iFxOPSIRURN}N zAzF!70xQ_QPeJmSC60}QC$hN$zvaXMxBEy)AAI5Z7RN74Al#T){k zgv2>@H>!0Drk&G$j>BoF{GzoN)9z82^(iBEZ-0luu8O)29+t$%FLv6FP^(0JNe%W< zt@*U#-F(JaxPb$jwW*Sv!e=&?MK8!oLgln8O^5Hx4GaxYazb(I2K17Y=qR^F?7QrgYfwjJ z;DScD7;C5?iHXu@;g|q~7NfA?tPDDl7w`t_Ayrjr*PCs=%{s9A^3uKvFEu%&_W}d1 zpRmc1Ote@*g3Gj{gIToTP)fc5gz!prBq&OIN(Vk7 zlqqlQNsBhy*xA>ui>gl@x~|}#C#D1#N`!;dXUp~f?B^BpVK5fyBL=qtFuX7Q$#m&S zvl;yE93;e%5vXb-ICX?rcFXjSY7cCTgU2pssa_MZ?*c;8wH_+NBoU|AGHkp8pB%1zL>u9?xCii{t=5;y-(_1%5ZG%-w~Z zJsK+Uv=PAacsG4BkILEckkpOg^lf*x2&($| zU7g-HQ!lRp$qOlB&VW@-TvEnL1_paMgJ)$uVBlZ5h#Ao z+F5qc;dpzPyStv@Zy`VxUa%RftbqgrmYphtEEOU|4)%qCMkqYYErldE znWf}TEq7Z0w-v;oTfVMDN2d0+X|RROi`Z^M3MrFrsWeV29)Yu3Ex-F+Y~Zq$fNEz7 zgQT>`)MDaOYXSph>L)MZ76UB9 zEg0nxLPdg{`Kt;RAh6$SCI|Wjr$lgHLbthIVjSe~xKLZUwK=Xm2KctlMrd0+o!dhP z_(pfRQm>Qg2k5zKtq4!{eUl=&wh0Ne9_5CvRKUE{V_IH=S+e1~hVKl?vY0NgC_X6~ z-dZj6eW~y=yi$$H_eLsg+`w@ z&&<+|THixLAI~*Wm6vHUAPK`MjB2_Sr>5}2Js{U7ojvb|wouS~xO$&=SgIrhtU&gXmruI)_UzgkVjj1!Y zif*dryWA*r24gXja;s+lgeo4eI7SLOcr+nk2x70TC4!FpPBn$f(dE zuj>?}KReXuYx^YM3x;9Q@YIddh|Qo^Em`6O?r5*s))4;9!SL>R4Tv=|sV{5G^+8^y zxx-xB2}`e z>Zr_BKg8E?-Xv55qu)Jdo*Zwl8rc+NrSm)B271+=8{4knXef~e`qjH3K2Ai{N%)ai zTi| z3>YpjmxqwmN3t3X!~`W1I~CtIMxI0~s*;&+3%K8fAcEY6Y?G~5bUirPQoCPh7A;P$ z%jue&XB0+HT{y54JrIWVejmvA&~F_9nXvv9U|UO-Ye3|o$-=Uh2ihIdrNOq%3+a}c z3lp?~&oA}a8qsRu7ZiBS@yaH(56JFAr_`iaFa&+EUsCJNB-@}mnftbF+KpQ{1hH_m zmFiwY5@|lG4PslXMFt^lkuHS?BuzJ{-_fYW6PR@Q4|Zt{p=z(kJ>^%Op)T{4En0Ze zZSwKiPRf6%x-AC= zNgLt=(qP%yh)+fph~(>Zv=?4d>!&ohBUhTI$H1!d|FmV-$>H{1CRV@p>xdY#?7@8r-W>Zp zPo6@F*+jyM>j-~9Yr81Fxc0L)=m(EcvatU&IEVSvt(@HDKZ_=Isw%ED0h@TEiWrC? z%~$yEou*(?`dksi3WX`dcmEuk2XpB#MeV<)gWs?51=8zBqVM!c%CGnDLyy`-Y>U2w zh2WWTsI*EA6S2Xaq-JMtmCzl1;1#Sy@Mkq$#J&{)@NuKoNw6D|F7ffEw8`HAwv*b# zilg=2PoI`f06)2Dr)_m{-*E-nFudDZ)~rUPq$7Ka4hN%lGwZ;^u0Us(Rrhrh_7C5` z8E{kOL`kd)bwP$G;J8!>2(AGMIAB6dZ}G|b21<4i%j8J`#h7E+-HC1s`K{i0l~mL4 z#$KTepi?^VXmBuaUwnU3$3w5mO@+-z7G8#D=+3#922Za;2Fxp{cu@aWU5Z$X0H}c-;llLKE?K+ zs+oI2dN~l5^mb=CoPe0qBugqgxCh^0UyD)Z#{9f8Hr}r{mtHAYeF>aKOct4~4is;u zrQP|!*mr5j2J8`9%R6n{1 zI|Lo(v)Tvi(o7p_5)6+j^V_wG+JGJ5BN1SX;OE2UzRz^MR_prk7NWKNE!62Z;n5`T zxYOU^kFQd(dgx2>O*#M z6M2C0<=ktQP|q6vkKM@5mCVrED=bBKFa%ga_ks6ax)>R2uheZasfstZ*zP5Czo z!Y-Iq=6N#Z;xNC#>5zj?9TG6;ZlyL)sbok$kI1`xsEzSyzi@k9zdU4 z95#NU`@E~WD*R7_^Vt_QBbmZrQa&mI7{FdkVqrX4rYra6(vs-nQSUWEzpUz~r#3dx zBhDdx;uSM{?}7E%7u3h>WHvrwK-qJ)F5XRqVG{nF070;lv4-;dcmUpQ$o&7(tB-6X zzCUhG@55F!YNWB>uePGE`|57vb}<4(Ida2jQXufsu@M@VhN1C+b776Qz`rz|3^X2F z6LU6P{%8uU^*7wd?oP^Q&jP4`v%y)xP-5Xn_!dN8BCG(wk9x6y|IR?tz?pPmctaPc z@%jmrrzr&W-IZNIy)Xy#)Rr+w4D+QZ(t3A#59MGl)q&)2jFz0}o ziO9H%kmcaZkoM;3r{U?@1Ij}Z`D_>siOpbh^z4r^_epSw!v7s0!0fBupZNOkM!Wt~ z5u5JC#o)I6`VQr-bQOpT%0x;68#HYs^k$%C5~ZcpXT$79?hAa!N`2unyqX0YhWt<( zY~^u!nHwff#P(3=wa`GZhG+<`bh(Qqz(8?MbN{J)t65+Yut#H*tDYJeqZUY5_hMiK z!@g#3{F-WR%G&U=l1avvc>T9J0_bREZDPwhz`!-hJed+WJ1#x=d3*|DKmsMUgb`_u zj6(D!_ofGWb#)4K`0Icc?uitOX#9Ri$_eSr{-glxVJ%!6%YQ4Rjj3Mk&F1y}Hv7q2 zBSLq_Q=3YSB1=xP0?A{|Js#B&Jy0--BSw#js8$$nrJ(zhV_W;Nc<$_ZempmFce<|& z*9eZZ;sGwu4>!O-Gj(xLf{LSH8i+K3Lnjq|*+mg{qEdfo(l-3>(9#PM{W8d3hufgP zTiEu{%`QDX4EA`fRUorMtT0EQM*^5D5s-@a%y^-1_aaj!nUxiX~N z*H){C55-h;*9(Xn8xc&DQoTE)|6b_eukBkhUo-L99alV`*E*79Eogy9c#i<#dJZS# zcH$aq3Tg`D)G{Fa7-Mg`zL+D89zso=U!u}Ek^s^V`d9`~C+iLKJa!iQsL*8SZ;{8!H38)1$X7F|wYIH4r zIbSDX^Sv)>g8SC=QrNeO$GfIgCe;-m&%nf441Ps;U#|Atdm#?u0BO_S zhYPSY3jBAOJ~$sf%QJM_8M~qHTs2}uxx4!d7euEFe;ec8L#LmDWu&uL7iEg0Dmk&< zM38vXeDG$LZ->}iO^;99vdZw!=qkq$UK|Zt@lWEpQHBUuqdr;*?!WZS!Tjn#27_iQ zAOgDS5uDe`jhk65Yy$L^4;kG_ED`47=ox>ha}a5w7fjv6LKE`Al26c<`-3w8G8`to{iofE9ecIS*Oa@0km_3jJpJ}MyN@c?`-K>89_oYz&QeF03WMfqjC zzzV}=j}iqGGP)EJ@>dqf3&d^}H;YNd!xaK9+tbQKr%bLX;$X;d@3G2DKJP#ogw=KY zVmG)LIq3v0chBD7=sb2K;yQALsfY0K0r!n_a1n`s`f4xp@8;8uL#J2Zwb&~e0AOKP z*ZA;WU``vP6x#vV8gPSkk%9;yXGq)*B>CR{9f5NNAA)Nw@B5J4n#jodc5%lLoCkyG z>o(QM(_LN+ZgVS$qe=HT$g|MUeoewzwUBs7LJfzR=U% zy9vmQkz^Gi6X1V;^?7Bv0SYRskS{pBlx51`FSIK6;>!2enl@UbFPzwpob)iNUN1MkPum2QF;3S?w7|Ky*Tn3<#X5#C?>I}$_xB?It) zg@;#0O+)}s<8g_u$enbpINb_f9$2kz{~_Lm{QB=N{`l#T-}!@P^cVjpM-+>8UGLR+ zWBe?( zMW`5}Nq!yc?68KQNY$&g*f(fE`*qpymY9xru_7+P>~2<*Q_M0F0a=;}z5*clKMM%a zESRBEMpBN3Bu7CM#Y!TIje3!ZMvFhuMzT6dIY_?|KH66@t9q zZT*wd6_x}gIvhONFc%P*Wu7Up{?dE7!R&8kNx6cwH_F&tZW^E)d(UQrj6ID>`KbA0 zzqfTn-^>2nAsHqia08wH8mO7?XENnVmqz^#)o=4i?gH`g8B2kp#=p~lqj`2zdA&)! zpX<oaP9sF&P6yF?le(J?BS0DXyA4)2KK8Yw) z6j}|aF7BfJ%-HKq9*+-^Cl!qXa7-r&)zWYiz&ndYy*!;5mK7d_%L(6e{U6;qQIsxM zFNy72`XG=K1q8;BxiA%y zup2U57VxH>)N)w5a7Odvf;U&tN0f-%SDazK#A^?A-|{H6+O>*ui~8vsA5cdgDd@c4F6FG*V>CIryTcFvah@+lZqo!Tu=Zu(1;$uEdu5c? zfsUv)kU)|J67LD858*r#>D%W+f=X4Axqu>T`0a@CsG&_24R)@g%K{HT&tWR73q0D| z@4xxN6}NW^o}{Ilv!V}eLbgDJMvj9NVLF_uJv#n$t3IXS(_xR=H^o@wE6tbkY-Zw> z)45Y;&O#V)KuOCzDo`h8RS70;zI@+%1`&kOfPID#WiPVh4905lOG9_YX(Aplt><{* zsVZo6|4(v(lo6Ec&VxDz8FrVwH@F5KJa)9?v**HACIlHRVyWv?_-HQ9;v0#vmBzc< z0PYmg^#a|#+yPrikFZ>{+wKWdA=4<^CSW{+VOSpadRprnPpGHuXj`DW_W0fIIgUk1 zC2GFvx!FAEFV!(u$E0WTP9sfosZN5IqKSF%ADQVNVE1lh3DXeutu-}sH5a&h|3Mfy zU&X*h!bX8jekB-er$*!K0H3_+VPHa8Rv2oj{Q-ab70L&rnflDfx!z$i zttQ&CsV8OdZo9hQCs8Ff5<$!YT852!k_s70BBAF2^nD#QVjKf{x3_a*iz=8tg4VYM zZh%jyF3qORmd9mY__Sz?hne#D&QYc9Fd@nU-v6ZH9KZU2ze?XB=O~~!5-4(Zh(2A~x#2`d~q1;y)@J9>88(`mFuCn2DCW zE+}#tcKVSj6qK9;w3ezE=?V=JE?F~w2_2kml&Kd%9p`owf>iknB)=PYUZFY7ij04103iYr4lt9ya)KFF?1&N)MF_u<8% z`E(UlThfROyHZzQXj|Cz@Z>@h$K$<37uUwQSaa8C7s9)&?&7C-d}_{cHn3&k<}AKV zh{0)D#9>`~C322#mcr@spl*8q7H#iR?M+3@cGIi=syXqT5{xU%(OzoETc{&BTw*H9CBKOsJ!c zLGLm-r0B`4_k}~m8{Ulv`ysWmciTE_xTlEfMb!4U?B;dMwX+TfH(6HG;_8z(4mpEI zc*6H(+RLL#5VB~f_;-&xPwAk2&D9{b^s!Rt<1gM@n+Q7L1TTNz9|p=Zqh3D}R)WKw@tA_hQKRhgj{$UCaN1n#kik zIw@PU`R#ft%#=ak)>gexdB{PqKHz~Egfla@*9sMecG5E0)y5}-9V$8XaS6R1S{NNPmp|@X|xF`h`zAAxzCcVTkk63nRsEn zuv8;wWmI`CpOHK;D_dxsA^EiQQrIKa_Z%VH4%S|_^(%>f*5N_Qqna}7?5TK-q*zpm zIV+ogQE8-!WyU^S7#Uom^R)_`a%~oGk;tQh`|1wiVuTCq$&Gl`v395Fh%wz2O}^Zp ziH)BVC%+gS?G_l-lJ(jp>rYI5_M4{Nj_g#)LmqY-8<7!>GBp1$R@vNR%dR)Bnv$Jh z9^7~t!6AIQ+kn-KJ5+L)b@QM|dAOsRf#<|*sMk}fn04=*eyK3~S(oRdhhb{M$6EO| zKJHkAHS-(U^s_zlYu_bW#sl=ZzFFEqs*=ZwFI(&$YeUW5T;4%y{79IsD~Bv);G)D2 zuCE5ZGG&kb6;COlK`+4vGuGoCva<}l^EsW5mQUbNR+PqxJ)BmwUYz!AJ9cFJ^lBq! z9(6Jg=tcyvFrOdC34o#oFW2tu4^BW1wR)eBAOub#nN*O$p&={FFz)N$Ra4VuOC7@* zL(oN$wv`qGT`+}^2OJ0dfwS}uxHZ}wit9EFbEERLz+0(FDT`7ezo#% zn>JiDPmA}6R3GJxLYBTQT&_Mc#_hK=-_=`g--lvWxKB8B=}WED{@h0tzPJ~BXfR$^ zlOXqcJwe-xuKqLDi3*F04~3GCBq@})mJbN(N!y7zi&Lii%T8#7bRFj~f|S*pjmL9V zq3^lqA<4?XSG1A?@KnRqOKuxAPy}u}ROp z&`~mu$z&-V@0~DmN9|uFryMFp+(B%paIeDi^AS7W&-;JQ6&=R*Se#7P7~kxOAY5ld z*OqhOLao#KyC$huzv0&%M!CLTRImAvuvGgsy>y7ZjWMd#nnj&TT@<6Xk!Uo$Q@yn6 z`y{`D$d@ny++I*!!Zdd}&7vGSGFSJ9QF?AJK63SRGXXU6mz8d1GVdSH|7GvxeT2f@ z;f48ntJIQw6347Coqm)C!flZy^>-K9TDxpUy195J@I}o>OD^d2xwnQ(?QUFW7Hm#i zTEnn4;%CU!a@ee=L49D?ajz+N*X;XI5^*H?*pCdsMV&M6Hq>0>Xxo$Obt-ZM+J4K` zAKLBQD0)Q}AdgMxj)v3O+&6k_Q|GTuI#q2((H8F3i$_be8Lgg{y~5|gfwa)Hg~2(~ zQ;=MKM(6@T#5Y0CEeGhb3S?7nV1;V3xW60Mb|PI z0Jg)g_TnSQFiw1DUg488vx4bz1_#CWE&W*0K+*;F?ZP)f*B>%@7eSt4VVtt7IWK+1 zo*7TDp1292ieC>dM_|S-QrrUR1f#$QUhZ+8DpQA?;?$9#odw{A1A6+2VV{6I3)Uja zoh46}<-{#HSP4i3_gHGz(0D|F=K~V1%RK7|RYk(`bQQ?_E-A_B>mPK+sTYC{IYmG4 zw${wlDnx0Mjb-oVFh~ax3O_}|4kuHkOrt690_4p%(HtT1*{3KAq0eI1d<%o1rDKTX z4d+190TP8p*p5ID0m(Zl(Jc5$OE>x|ofT`6$mZ{*k~Ov^y1M$r!q;eV4uoc zBdQOWLGTW&-tJz*C63;~DeQ3Eg{Gn>;%fnOe|J1O1wYQPZu~&$i*xY}O^mlKGrBJ) z;&h^g{NJ(7vTP{Cw=pd9Xnv!N*WgynfewgI(o;k{CC`1sXk(l!l_j8JOmKV};^bPa zC!_0PANaI_r2-F}Dc`a<`%ty751Gkrl*qnDB60)iL_}pZ1I6X3&au6vqVe?X;5rrP zSUKX)9(i-d@rgYbzcQEh$>U@G1u$5x-Sl=u*YU{gHy75S<~qEWLT7xa>$QlRDY4E3 zCxs|d1s(J3;VM(j&mU_D?-*&LD5{bJNi|Rwyy(RY*-8qJq6Xbo{?6p%S=n1Op|-hy z+D^lJ*x0W5FLYVh#!`Xpr|9OnaP&@reL!MBH#9+k^HP1LsR_pOy_ys$NmY_xqT+iA zvQZvE7KNbmSwF&`DvGLISuJey8NM!nO`8!hil}u!We=O55;Q+`IJQz;;nSFc!sqYq z5O^6gydxWNT3RSj68d5HM_sj@kTo?bwiWu0Y#9*$0q3pIBBXjf(VfeMkDIErmh}1j zk6wuUhjeeGj{(#2rAEHx#WkTfJs*0&$@gr-p=0|ZQWK>6PK*M8S5|&*r2+>Se{#VJ z3eN#6huqWb#D(G^m)|LHq~v^E)$+a6v9jY|9x#Gs>`sUftH1o*FoAR>2?+`oA<5+w zJ>Q8m%v9(wKcij-a6bh_wF5y9ybf$AIvt~w2n~h-eBn`^bi9uNVDOuuY`>1$mN^-P z+eTz6x~WL(?Q0Zj$H;O9FYte+3J*enHXfcIXG3d-DhWkUb+5xF`19KMja za=-kDAMAVo;C<-NxT)rGr*;Xs#@oY-Ss;(P`Y*j*2(LqX_aP+`hp9+am5%&FB}p2- zJmoYo(7n-N=f!mLIR5%&PR{oH;(*c#$l(u&zghxdFExNZJ^WUZ=$AgnsP=C^f46=r z9lGfLXrmWG;QitR$OHh(ixV5+_4ekkbP!< zN_tT0nUK0tz=DKPUxWjqJ~n}FJH(QKLrLoJ+~d@q9c3Xx*#h09&M|OS7&V)UF+f%l zkF>MVle1@02&Yd+-=x*LXei&Eef9#L%m`8plI)Y^aYSh6+pwIBVf;uc#HZ*a^f5VF zgsb{ZE&S55eVVr-Z@DHOx?XLt7l~Y347$5U4C0p1-k`9$mI|*<&GhsV^lj!oMql_MwJP8Q9j)n{zZKj>i|V9JwO|-Or{`Y{S`_>uZBdA>z-+z>M(y)iaQmZDb7B z&G^3kc=S;8-;-|h)myEZgB<#?PtBzr`xvu*q`CxWBJvj@HG3Kexh8=R(~Hu`qk;E% zw6K#w4j^2J{8NcM6DxHVEF`#(1uSU)frwXdG+dM8cBab<^jsag3!VYkxteHDq7C(c zr4?a3IvDR8h{;6rUkf^Ujc0FsKc{PnSidY?wwsc)uq9Nvdw^avsGijiXtoE+mZ^}? zer(1gaboJUFozcm-wLL&Q@Qw0@*cH^SnTQdPJxZVzWK{Y6B0~vCgZ=F#eh_~oQj|fy`pmVxzDv9S<7PJGf);XJ^~sR zF0|BEZa=%H9cWW6bB;g;TxCUBoQ8Tt^bDRf=BHR_PLZN%U9GKm)V5K7`zTjGU8GGH zo4G%ou8|j+P*~{JL>jGE^TVO9m&w%ayKuHgUI8r#pW0zQMUMPLEj&%##-P2C*Ym+T z-Ymtlj2l_gdK#-_4Y$+hpJg3p-b-KK^iCNAzU!$B@V$Y)l22_nJK*vnG*G6*PYy5# z{ECz5jSAgnC-yiBq*(=!uH<-nuj;GpC|_zxj|^HR?)^u42gghQHSOF~9_XyPvWpZ) z4$L(2)jHs`XU~@CGD> z({7U6m;C(_%*&$8KCQ;q#Qur?*ET2XJDg-KqLM?O^I_F2^iA(vv{h$Gzy8&DE!h&i zgrHO~jr*TN)Z{esx3v?-Z|&7YdH^XLu#SEpiCC-(MuP9+#&IyuP2biy(q4Dwox#dQ zaaDD!Ohk|A3E$7#SoCB*4qGEPve-|!&XN3x)6-+zFJ07~+xR1<-IpVO*+Z=xnVyS& z^m?_Uc;N3$ztXqW-3JF*4AkoNQfu^tiknyKxs&_H#7%fZ6sAhGPCivjpT&8>jwbob z^=H`xbRP0*F4MO?`0Ydv^!AQ=?ny~QZ(Z3T40VW#p2EQ15jsxw38=P-z5UHUjF8Rx zSSWQ>8@+W~v*pqs4ZR~^&uzxgLO2gDvLc+2##J8n<#qcX5xO`V$UH@OhzDVu6e<-He>)VB1yN^I zTz+oF=uCKha$C6`pzO0+i6`q85jrN~5Y1(2O4BF|7A{heSvv({)AvE=2Gy9IGcZC6 zSkM6jgJMIBgA5t*bNaE%c8%F$tHvQobD-AOQ94SeL)pw~8QmEz{|W1};77Gbou7jA zg-27+{w2@jyGXg$+jIT2pBwLs6Fw@))*ID1I-`7aRPIVAZdd7uh+DSNA{5HV0K)g z-7JQF)Jvw#D-(b*F{KFnXs^!kIA3=(U%vuYF}@lXAp7pi!7~v9dh19nE=MGoH(}(g zMf1Y<5xO*$XCWqa8G-DXTYRH7!}ZAxGYGhvc>nchfzCm^xpc%LJcn{PKj7ZSv|5tB zy#nP#?YAK?ktJT$0VI+1=y5{o1QjW|&6|2Hy2idCJ3DA2!x-d0&|oe!m=#JXDkdTF zjG)DN(!yNAAIm#YmSXrAN}Eg)Zjord;Q14_2%(11C+n^LS9&!V=C!nx|LlSgIGbAF z;xAp;@*mjtM9B?`TJ7?u>Y~aHz+-=x4&Qwhd21vx8}NvH3qUF0hdCpknOT3RVJ^Fd zKenWgdvcD|g_p3R#l@E|K3!kaCZq)fWzkfJJKH4;6k4HTPuYG@RJh%b`B+2ePzlf> z=nmG}aaM_Y)*iIe)hB@Ml!@>Q&_QIY9*%T*|Bf(!#z#PZh$DJOf}^xnPD_zkp#Kt3 zFEcH>n!BX)yVnMt4ZwIrWE&-Q@Yc^d_|wy!cF9^>2C7;$x#ytT3+) z0?#aA$!!Q~f3>I|dr{eSPnTjB^{5gmSApc#!6KQTA~1Hu^rP>p{Kx6GK12@RvR;Ql zQBL5OOcp2<2}jIDk(f9t4T3*HvD!#EYGO*de#dqHUBw1IxWXuI+QAlU&7~YL%@Y!t32eCB6SKEdB)J#))h74U=19lc)L1vc@sXAg=ab?N{rzt2 z0fqE&r1&apOER@~du+&Nn+C%=!v@0o%i{uzdv_B6^~4(Cjg@W#I|;vO*y&bd%Ty_Hr4C!6^{m6Q~BJz89iB1BNFUUsb>Tz+`14HCdYSMpEqYdxi zQ+Udoe+mX~?A`@{KGLO>5`@y{sotQLc3ou>TT`VDq|XQvyXLL8>&FKzb&@4aNSw}f zEBuEjC!psXd?c&r%nIn2TLI)gY$&IRIWQ>6om*CJN4X2<=DC&6ghexS`)GB}G(#W_ zg3fJW2ZzebcvcXsi>)5M zd35UN!aMD)lqWyhgPTCFVpvldxLx`7x)J|Ic4ZCnlP*2vrPa@d^~nw zL9c+pd<)_)h?C)$b|WxEy&fF`TNWI=#2l$Q&Qmx6(BXA_0Soslga|PX2cpkwgNjlt zfGaHs32hqBZCd^LSvp-qgl>Dg$qVU{lPdPhX@5D(zwkYw;2k)6h8Z z-qEoHz#>htMjUnaLx32qou1s(h(`r+lAx=BJhxVkOIqu(av7wf!PTln%iS`A9~eUy z6z(0Blcj+t;x^4(qG@!|7Sxq#I3Xx!r$ZE)v(n`kQFsY)C@Z7ZfUci)BsT%uXgnZl z-9qLVsJ5kb+34VvQ894V=n%2BjcORSc5mW?dHqHebDm_GqA;e5m8E!K8oXwmRZX;U zmwq)Li-|=odfI%Qo=sh&Yrfu6h=2BfY&NI@;KVq5eI1|+yrS$wl-(ZT_*ZIU_sY-W znMW-wy1Mu&TqMD9))g8hjE8fdMe|0Ndw=$iUff7l%(^-=LO0Cjhk9gNo17PUE=1akRrR%*<@CiU#4hX|v|F6omc=N5WyzKR z1E_PJJ4Uf^R(>}9kzhK2teYG_eNcQHWP^YR1%C*Og5 z`b#+i`AWK4d^8waeK=q-1`lK&D z4p)&Puj>0lgO<5^AKyM#Yqv<-`aS16Kna$NSRzzPI=->I=y05Yn7H^44fz()YdtEs z`cyce%hH^9lE($WYTmOnR}s@BIj!m~6pm1@?n?`(#>&>)TASUaqgs1lj;oa1cU=nd%&wv^2f7z&aeza!o64 zpcZ#(u_z=iQr{Kkic;iYQ7LAR2gjDaJpCZ>UV?!+#&k%o14y+iECgtVy8Z!$ic~cE z%>Yu*KVVop3;TUlB6Yco+fUC&kgyCAd4VE8V|<0v-f zae?7aK~q#XW|T?-W0bs*LBWrPvN&QiDvFvYBpg;~trevc^Qm1rei2DKXtGC&Nv1Pw zpNUruatZ11nJHBM7T|PDnKHA~jT(_z8vjEl!p=s{7b93$b>+uK#k#|=iGeqzbIj)% zqYwOu5Z9ZwN8m2Ju8Rh#_>03w(sPQ0|5u2d#c+AsM6);0QSrrjy$mVbi?)O3FZVrZ z3fCW{ImaMyi*`!y+UtpBH`LmenP$g4s3xEwe5QbcZG57X5n@rMZpyWu6;0*?nt8== z362!zQO|jK-oCVNdVYLBwXR&AuAw%Uz_!x&1iVu(^Z58?SvW^GxMttmC9exqBKa|fv3X5=tmJ{?+f=%NV^mm zR&=EiWVP877`1WbZu?2W_RY>JBHT1*No!2b9+wpsl1~9pSL_BnSemU z58=?jiG3$q0rK7a?kScF>2uxVsDfv|VllM788^KFlnqv|vqfN@P%0v5Il~U_NI7KrKThG( zFb1W?`E<9`_kMg^r4`Att1`?AMMUo5FFExYPpoq#lPgZ*14a)H#YF!Xpxs9dRD)z!y4zdv@pm(r|x_>5=myeA!=`Dr$nU8#VcdcYX z@bG3@KNdU9H@+4D)ZS1p8$HDRd@=Ao$(KA-deZHYNW3FIHsB?3llzH17PM%9RTh^X z0KTQ-rsgVG6oR2^NFNLp)#61epK{6Xi7IgYV&y->2Rop^qGx=$2J;Co+JDj4k#v6Y|_RmZ#g`B#Dq;!u#n zBPfbudjY^jQe~RZqL-|PQ>IA8{!2A_eQPyag_&L+3!tMo7=;UQ)xCPI=3Gao5h=MO zvE;UnCmp=+mihkkUA)mEIGcgXvuxvmPbb{aQnfI8! z04|I&QFsD<0?{L;^qkb7gzj3*6N?p;`e;CZU7-+;iY1SCarX)702pJ0U{1gcNLrhw zB7htjG9UV!35V;%#mv^yu`)baGp`bdZRA~N^FFKaoQQkP-{>UEzo@pY^W^cS*0RDKUF}QPz*#NVNdps9?} zwX6V%N`#q9feQBZl1gx2-51nIEz7OCl2~fh(Y_DJ>hTE3YR`<}V};YibQ$mIUa*44 zUkD!E%UMZ}ws~C_Ui}8gRGXIf@cbVMnPLOZHMZW3gXq8cq!bx%G$c{> z`8qN_%q3gVVi(WJ6jJF)kuA-dNmaPR$nCAH!>#G7LA6A0X!jyg(xku&1>^W^k>zCeU^ zmOgccf?!`k)c|NZDKFH0$tAu>vP3 z7J8SV=cNAq6c8f2_d4SG-tXWtj6FK*aCO-^nUDO+GY*280@h=r{`2z?ftN-IxqG$k za)FB=NRFiBRI#NK7`0c`6IK}d6_{py8P$o%32agvkzUqHPbp4fnDSr|6&~%I!2}^A z7_>2{;8XVQwVQ!4_9Up#rh)s}7MFsD?b&$~Y-QWg(lKkg6we~`+>CYh1WWJg{tDox z$mp-=eo6z69OgSc$ytado|9oOOLujvSIBq(TBACYZhJYc_hY8yKi_tSuO{~TH!8QI z|1IXq_cO4F6Acw}UbV!ahFbB-izVrcQYCin>wOH!&^)^3tk75HQAc{#G03HhEaW*r=!2 zTcq!~055Gpk892?$*k|uQaX7(F_eM(1j$_oP9z_eX^6!EBP#;APiVNzSdriQ)Ox>3 zE(0XM)NwcNC{Y%rJb|TVS{;-Agf*t=9F=5g5Tz4mgT1Hj}~SaF+zhhv(cxTlvg(>8FL(I zHH&CIo!gna&`-PR88^BC65D08`BniA#8AP@Qn@0z>-{7gW@9 ze?g88=bzMgavMMV5zUhV`I^Q{qWw4T6vpk==ltCe9mu4uuT4yIG20rCQ(80`}-}OqVT~m@k*p zkIZT-sqB#MYgBN62KwG$9Iz6%NEq8l{xbx6t4JM~#4-xw)=KJ*^pGOl;|%Ibj@^Yc z%w~J%%qS_~8(|WN=y3Vokz|Fgm&9N}%1>IU4mY+~UDfZqJq=%-Ax z3%YBF1XVTM<75&I<+uIWhhnooJxRaBEoL>>l2AJ7Y zc!ubch`mHD&VtUD$0h~Lgxpm#5_U#qEHc*#^RFGx0>M!XQk{g%_mh&KderP8+fYZ$x# za{aQS!|eAPI-Tb-?*SI%I0}x=RKCYOt8+A0eIdR`Q0)$QaDc5h$aIx&oQ^A0<`p>5r{j`*(P(P?$_LUe4NRf z(A3|i+SUl!R!xwsU7%!+xM*fEG=Mtl`i)Y*0)Jp?Vz9y?c(g!MzIb%khZ*uW8?V8( z-tWn+9q})Og4z3xKzIxnxKhudQ^5H=#2@h|id=ObYKL3@3e-Z}mu?(DaJ0?-$5j^C zR$NUMfa~YFzkbh*2)#cxCN5YIQ-;C-GWO+t=yuwM7lty=52gE=@1`*Zr{%gEzhTW> zlRVt}Iv;;@fF>pJXCx>~Z}8Nc%8`)qLd|h9SXibU61uECgbzz5!n!8KV2MokC1V91 zglXD&?6R^OsdjUB6x|aK?}^1B%I=8S)xKB3o7`mMEcEvd2~)YOQIUR>CI`4d%fJ3K zWv!iq4m>(0{Q<+rtH)$I95K$79ZV52+~E%hfs3?HGsJ68O?>R`?+0{G>YcXqY52XB zk1!YD&v_H(2DO@*CyYu_x{5NbF{I_K6-Y{E)@Qsg8nHxGi&r&Czh^E4*=lo$47XQ)%yrSEu%d7z1OiPeZRt;6`qVwQd6;~Z z?>#{yYu+5C_o1`v94g>hf9y(erEn7zO-Fc(OKL6=*rCCwhAUE-bF=xKx6dJ zPp%^G+2TCBv#xD7Tj{27t>vuoA;eQc5f(dya28Tk?Yq#=p~ZPetR8ek2L>B7{BevT zvw9vMGx^itLu_ZS^WL~hMuasM+{Z|i1#)1g#oAbS(kS3oSQ3e#ISl4CXUtr?2g0~e z-$yDB9J5iQ=Lx7pg0oFB4JzFpeE;K%g5w{^D;1964fPecdqA#4+=3Uf`M#{#TIV#6b9`XW_L@C`E|f%9f%G;G(S%+ zLyIhuykQtYA6%whO5hJsk2-c1+2yk=m59Juy1P=cK$1ISqN)_tzfT%bD7ZCTk^|JZ z;J^SP@cEG4lV-zpLm7XYe?)$*7@sF-`Y7l%!fnt$#CwZn4(p!QQW z2Fm#>tq=A(Ah$2w8$2i;YbA{6p=%CzX4+ZoYJVWps&#*D)31q88V}Sn5?daZ+qG@= zTam}ne9l~|4z^I9`1Xfxdayw0@9G4v56ttH9n1iYgWbKdC(&Z2F^O6fjC>WP02Enf zrt=vRU80njStRmTXMJs`&};dpzu%v{Ni=w~8s8*jQ+tv5Q2J)|}`N6a< z&K}5KwH49;%;Lak6l!n-+-iu_;On8Fk8fVfsPXL>=xpfL*^k#LJ1TG6p(VcCJxdc2 z3r{;B7fvt!bGLFhm#-q~1CdoH!@Jx?6Bb%I8?np_SGvguO;uUDuC_4t4$>%UWbb?j zgM7UF6EA|8FnjR}kDCMbu)~0Nc1R92MV)7ppht8&l9#vZlG)^HF_(k8?3Z;Sgd%(t zSqjx#vUPG#?9A6|yR)r(P8=M!@(@l}528QNU_yf7yM<4p`)zr)TtPKJ4poKJm#=rD zZIE;$iNSi-CUTDGN9Nb!Ps%sgjm?hD?WTfIroKKW2?bM+ zS*LQuXAp7(_6A02nG1Ye4$;C-?U|U4pQ#q4VB!Jfff_z6>EQVe(_~}9Py0vitVFLh zS{=O+`BC6P`pg7JErjAu6QqROxPaaxBeGiM&H5CUH1P8d>&d z6L({*;K*0C8NF=1%cOjqYcNmk)HgCB=x@xriOx%1Oy*8o|_NM7*{~b<*~oE5t!*R z^ZA)K@DNN#n(^;?!fD;_Ybh&*gRfP7l?{^D^n5`C*68&=8Y}p-DT0O|?aO7}nF^Il z%mWmtt-Kb(gkxHDnGT=X&(qB|O)7lzE#hmTH(Z;5eS*vgPG7l?-F)quWL9~HFB05q%;wgDSDO}1 zKq+6@lhKaA_!(Mdd!+0(3ccFc&ldq z_;C47utt*vY-#-Kvu>03W0!lCf_h_cd)0I8x~_PJ)#fc5ZYyCjPsi6cZ70YUQ(!A_ z-0$fsr_yiKpaobb)KdfKlf?p5p2YJn?Cq-B7Q`(ww$<0KLcz_j9OTnH{1^?D?3uVe zMvZCnUdYebG=E0}Zx822t&6+jaqO z=c!Occ%@OCLKzZ4uqGsFPKuvLncb^{ZhK6YtJXua%~Odz<79sG_CRBbC@ng_BCSn+ zLLbOLF5}Xxp|)LQ<*7#Mm1mIUWh+pkPG9fTtY4ilVbR%Nd%agMCeblb*YKmsmZulx z^tE?klUZK7oC@WPFs0{xIN?moRXjcJFi&b^R<==&}P`5neCg?vnVd|K|w6eao0)lm>DddM&D%2UZI?Hg- z%Hdcn#F#w?ZH@4mzHrNrvn9|?s}0EHok{%&sy1oxn#jCwsFWH8e! z93z7-vyNo8LGV^5r~p3rjzr3GM8_ZP8Sub(5mdBdlyeLt;XZY@6isJ)zGO>-$^w5*}jS`$2Si*pBkKOUbp0}W6y z7(S^3ydxVn$~@NChOL>5+_^+hC5HvQKL59mF*QP2UrxdY6tQ7g80k{%!@rdUJ(-$> zotTTGpP5)HYHfx7c_xusCBUjWvo%+$cUWT0Pb9erod9Y*%;)1DyDcs8kpS0-a9)zsaXY z{1hoFxnb4|xkOl+l)A5& z40W+$AX&*TKKUzTPlg1o*m;*`lP8%at=%ekVO&U4H9kC{4=Azb0!{Awu&>-dVgVtL zP~iDzk+p52-?$f%2c<#*RlX##u7;u_NSHh}gm_v*U-JAJrBrULWe*yctp&5=j1QmG zQz{IRNhG{}OF6u?{32RetNbSKwO$?tq^t@JhqO~SnlQxNEVX#pr``VRuQc(ayN3OF z3&;s)DYG^+-*KYiE1!?-XX;rwl(%a@8MpYRUi&fGM|gj9;tU%*`h*rp%g--yi(%k<~_3TQEsvl;v;Q;cE<<{ zS#2wnYM4r`GQs+A(oI6y_yc?6{zirAO1Iw~`{wz%MAUadlfoKTm76`~jELi@B@QF^ z;(Y>{(*@z{_+zXXU}=1XN`KID1sX?E^9F;uWeF~DeY{}JKAe_R;gtmLoWZm6ce{TF zoVI3mF1aW69Q|#l3s=CU3ShtO&1>3xbDJRm#dgR)!MuRGCGMwQN0rEt%l_WWjwbaj z(&T{vd#Pg;Na(nr4>dE^_+`)!kbE+S!Ok=31gry zI;Km~j&DrF+>1h=u~aAp6z_r+4-;NNvY;Pv8E}3^g(5&=4)CQ>rl_<ITEhVqw8f z+JB}a){!PsbqXz-_L5T-Fq*9q z6qCc=7^*4lB;ovp`IZFVhnp&j3R8h${!1sUw9OFM!dKK%K*9KEdsTa>lJ^I~QMDxx zYv2#~&7-?r6=4~Y1RRN8y3B6{@39ESvKd-{^?BzqIM> z+y>Bf<^4=ApZ(nqJM|lw(v6yc@$R3^jj+-vO01OZ$j`8&qOX~0ZrU@6Dyc6E3(NOb zZ<2Z!z14$|wu__cb^8#T_$}u0!&Da5QTy!%wbRyaMcfV}?*f`%UeTCFcMY7einpm+ z>_JBkYLsj}cWQA9XlE{_@Cap&amhICb~o+dKtilTjv{Er#VG0JceTSdE~pbY5OvxZ zCJ}bxNQBG+Jh!vOl00O`vb!@^p0Qf`OQjezDaP~uElmp(wLO=U$;Rr-D)wo^H7H;$ zKr%|<97mZLC@y0=jjjnH5EP-A3C;SBk#rc5$h=6A3ykAvP$CUSFq@imPZ$7G9=dy1 z9wx9zdrU$G=~mt5wsk!X4hR6mw+(edK|vF>3G0cx=60Kg*mI( z1~jiBboN}$MSSurc*cHg<8qw^`1GD59x30v(jH;!c2dkUulv4@&cz~dS)yF&`BlnD z21+{N8CE0kVg+(pInP23o26C~D;;39MhhYz?;FO9B)4`gH@%lh`bs(Q(dUR=BOU3Y zq)q0vU#n^g;j}uE?4i`H8FvH`k7n)hPk!Y^`ByCKH%gYuL=!grW#8bR<|Lm}bB=Mg z2o>`#70x3z4mCqLd;_x)GoA1spHc?xQPxpAr);o@Sl`yDS!5+a#cX0q6Py0Pet-=V zb|;3(NH25!bpHb3Rd)~{Gx^W#sTQyF@vL)aKC2|}+Xt0{sUB~)PJ?Y}nmkL==)MA` zqSH>NzoJ*TO~f7^5;yz;#6FNr^rd9WM`UQzluPH3-|w|Ls#%s$73^Y>^v4D#B_1$I z0g}dfXXg>rA3N)+7zoTRV0NueY}H&q;^A)mLk*V@B6m8~_OV27tKqM{u{%bLsXLvR z^B(u#KHNX6nmatsS2@Ken^nDs#J;FEBMT3~C5vtnA;KoCiQD-O5L)yS+-YF*X%81e z>3q50bQQpduQ6DD<`=`^H}q_AB@gfy9t1VsPZFTFT50?}(%+9Jb^KHb1dpqu?<_rQ zu+;Ob&}sN0S(QuYj+`UN2%UqC5BYQi)!1v%7wvv)*~ND8R+@r8zbl{@Z8p0?ndj7sH1#g__A|;7N|=XTBLp|)To+#tYQNJ8q!{6_OgM^TmE@Y3dYTIUJD^LYWt!jyXt~W$n2^H3{z1Uh`Yn;lgnYKlXCHZ*bKA z!SH^!$6Y!1@Hr5y&_!q~s1k~60M)Wxu8h1GV|cy}6;}5Z>~;sWiYbO0h=t`kSknDo z#TgKHW5{a1H*V&Ei`Fk*;cWd{7<-gz%r+8#q^WvHx%wc#(OK{suXChl#T;6l-;Cs{ z>*h3^^=FP|N-B`5+OTfJv;vfR-`&QIhFaKr`sU9t{oG-+Z-*<#lUQ4h) zge%zu8&TGW+m#F2AFW{3H#+~2Fe%;NZsdAT=<*Fz&$Q2dtn5qmM#N}hailp{6oC8Z z_@NnwTPKdAj;JU=KBZI9GoYY$NBge3<; zwJ#Gff1h)x6>NZtu(@KlsW4AxCP1U{fVIdo?6r1)zux31$72?T7}^!{ApBvXWSkv! z3>`*Hm~hAvT+Y;^NDYS65mO zs>wlNS=2VkJ%gBNazPu|<|>j#Kl6Xa+?z8A4OL*?;r1oBRHgOUwXH#n+(0f=D!Aa_TU5{L)%OkTLF-`hp^J#FLy$y`EM;=)qSgqo z@aUruwzG;cq3BrAOVH`_>X)~aZg}nr9Z0r^Up4*6TNB?*xRM`U4J_M8;P7$>mw|mH zn6|Y>s_8}cb%`SJk^nLqR`5!-`%=Qy_3Gn0@Ww3?bFgZ4svN>z3vkldfI~)53`T=b z7^M8bP%u)Z)j;1C7=)icc)_vXj_P|4p<$rz(A@>_FKc%&f9uEE77l_$M|tfU0G~zi z8yn3weh^@q`wBg5Uj@3&s%FB1qdpD7=!%0a;-tkuc|8xvl~ea>pMpjng+c4C|D0CZ z8f=9P(J83$be?etAWIw00j;CaUuQ-jFJ&2FQR{w4*b~0DZCsf=NXLamDfGTb?Yi}w zwvA}*N?PuO4j%Jy5zdH7PGbFbQ4K$DhI8|XsV7`9De)HE`HL~`zFn&5Nz^+o#^a!A zrD3`Ch-5hZ3jstQaA2)!gZn-ekT^Cwq%*< ziy;WAZEliUESMd?`o^321|?pq`SOJ6sym59wS)7&P45Ta-3p!VxCsnDXBk-*CKz8* z!2DUW%!rykzeFy$Bs@TTnH%LFr*|i|+fRJmBZkkmlhJ+fd8TD7dZD>^mGh%x;NsZ_ z1M>E7vlNZ|4vOe>Ck)$2?dIaQ=hMt~A%F9pINA|=G|S#p-jyM!s5I5r3aa-sjK?D; z`eNVjtch!`ZlPJ$<=;L~jT{tLKZ9qG=R30%l>`(UbHJRt9E-dkSZgl}Q>nj^FLLUT z3X32dySgOO07z61*WBr^DDcO90Jymq0IGC_LC%5pXdZ4A@(hA{+MJ!eEsCe%d|rD5 z|1tF&k0J{S)ERhpv*V|3ZD>BB%?jSGqHgyf?@}?|`wxfu-*V|Q$*;#CUIe2KcyUV_ zPu;4%DRx6?kb0g?S-LU6IqZ3(-)s=R~-Y^Izfg1$?!lQz_q z`1a>p`cianKPKWZx7d1k1ZiLjx~4M@Y`9(!XHE=p|9@c8@Zv$MhV7>2*m*P<_GjlY zPPT3m=cjSYOHi}xmN;vUNm(86&orSE%pplu>vBCy?YWDr*BE@PTTLNZRS7&L5MR*= zbik62608gx{#}kVs-CB$`v?|pi}?=KHb=SxcB2|SWVoxub2K% zt@p<7s6RyAz1(XAo3_yp><=+wh`8bYuMit!N(zq_9l9n{-=ZoO5moh>%l8SQyIa9*nzI| zBBZ=#M&_bxA|u~L?w1aqIfHsOiJO(3^x4d@WqR8v|kY z9g#369m4Y<`( z^B0-um&@)@1%*RxD9T?8pj87;EKwd;4x}G2u5i~(rW)E2YU>IN*3i+KdMU&+4-RW> zPewzOo=rik$C3bbMg-1%#1LL^<2f)@#P=)Je`Ur;pZ`C$38lo1QJGPnQRHz()5GdN zqEz)I?z>d9f(J=#_6}MfFhZ?k+TTNs?Njjd>^+E{7EQxUSw$-VHmRZ@9OQ zTQ$;pL`?gy%y|ryw8W@x6W*T?z1PSqJh_RQa$xL%`}NPZ#Lx+OYvsB#75+ed`_t(w9%Jg{wz+sODF*{ z^vzgbFa3!&=K=~a7!Utfh8)gkZL?>qshK!@lRJ_E;EtQdwUY)ty@%_8TvqA4()sc; zH|M)O+W6eXP=>(C9@2f`v;|Q}=Unl@dV8yIEEIoB2`dx}K9z1UqQ|jn0UR@$NIeEI zN6-;eclJeaESbG~D#5jQJ2=`KEFotJ8&iTXJFGjnmIi3Y1=bl{Q>gv;2tV0Y3(=APbL+@{Tg8%A(0JVlzzn;A!9rA z{sMd|3xlPxHalGpvaJ;_#evbH)Q)Vhfic~aq7Q~KGPkUcCP2P=~#;!TTS-iy+_>_&<7)UJfW0kHz!^P*GimP0Y;XXr)XCzG782 zW1rph9C`5diPT}ki4;X_|3x8X&EosS1d`1$$OckU59Dj1u?H^4Gyf*wco7l!yNvNQ zWxJqxs4Wfk3jN)Am1 z8vS*r#g*^A3Z_A*jDADB4n2E(&7WyyYpPz6#;}G zdHuGp__VzG6hKGr*-hVrd!7rkOB4Y(xvrRt^D*{Gftxe)VWCL@_DS|k^(;XpK?A16 z<(QIQ20>UaEt%PQ6e1<(j|s+9jd`7!dAhXf+8TuJRZOzCY!}cec^QBb?!1>d=`_Ko_%_KV_f9~*VMDC z3Tnfu+3NFyUP7K0=_c9S`bio?EYn`4sc&SwnkqGq+d`tySD6LmHCeo=wKY=DOh2+1 zHm@R__EY35E#mZ=`D}W6EFD4Tc-+oCBG&HcXu@Fr5!eM*OX@CS$nXPot5BMnZn9NlOUubkZ07W+_QGHfHm`emTM>>{1X(**!4c&nwxdc4n569c=U-m-75 z&-V1$QIFJXmlidAI(A1psJdM< zjvepVRS2!EhHG1qyP8E3(TazY3sFcTVrp7juNTkR?M-BoBPSp3E zP<0I%b>LIV`Z#U2Lu-&ablBcM6)SdaR0cLz!z<-COdX$&oj!yTe|q=c>7RdMqX58y zW1(aFP%PhvX~4Rm$ofQUtDn`&?R;4cX0PkCqq&%?@ zr_;Vp9C9m+Ccrz(7Gcx0{1yDuKH)82*{uM4u;*=sAL^ZT%6)Slnv`Wm;-xKbB}9@H zb?ieKWQ&UQF5H`Ti{ANYw=b`Etdv}HBW&`^ie&=G4c`xNt+1N0N&~F z$uG?D8FaFLPFj{eg3cTXx)v8Q^-fy!x%G4avB_73oExqs$vRf5dM76F00=lzKj9ZR zT}4RJn~~Lop_Q}D4va$t5dS+H${Kf*S<@@>O{UAG9M9->3 zO>+=A%IX#lVr5A>Gq<{hkMm7F-^_7biX&8sl3>BJz(dv z^oKj}mXofNx)!U&exCKbef-nyEWjRzkIDg7_>a7vU>p;kc?kLZgzIiE(C_tRsedMbLs3i>68nu^+P4)BJ}e#~ zZBSv(^vUu6Ix<*=#wlvRGg()61W!J9MFwlG>WFDLr;R} zy$BWxFJ3y=?RoZiruELbWf}RM-0z5r=H{BezZ}|t6+^z0lsXv9UA05wtQJ(5z`iU* zXJzo{y_K8&@T}4z!*U$Whh01!*FVP&5o&ddVWYQeLK=qquO0Fs-+i*7F1BBr&TWC+ z4NCKt?*s23JuU!xdyg3CoIl$$?s|`gCR;eA;pCS%bYLyYEeqr~c-OAlnziKv6})pT ze?1^&sM*E8aRe!-Z$4FycixZ=FtHQqbYB)5*niieV=_oO6SKl^iLkQvjS8RFl@ z_*}goZto1dy5)|Of6clTt?IXdsLU~ zpm_Q@P6Nz^H@>$;IXe~4b({&@#Y)Qh=-_JmT)m%^?Ei@_nuRoJBluO%PjSl9*FM&3 zt~q(J32bcn&F4h>XKQUVP9}MCelTau^p)iQ^26sXStMs!5RBjFDe67?5@1ihciQ%T z-g3wOP>K7VvtE&1t@X^IW1!58oIBfh%8|o#ehl8b;j276w@V~Zr8U3cME%+>CtoX% zYT{Vs_-3f5^FU7Y--dc|`kNv9byxk8+I_t~A8F5gTOIdpmG?~)oR~K|N8N20UyStL zHc_sC+g?3LXAjq5h4;?DZl3|6W-a52B`N>ynAFl~d{$x5scomTEj)+lz{&V6H^n z4dwhki9W=X=j~S3-*|aT<&SSCnupFnIgbFnyF}154fKD% Date: Thu, 19 Nov 2015 09:07:54 +0000 Subject: [PATCH 099/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 046e8dac96..c563e37b4c 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -6753,6 +6753,7 @@ "cocos/scripting/lua-bindings/auto/api/RichElement.lua", "cocos/scripting/lua-bindings/auto/api/RichElementCustomNode.lua", "cocos/scripting/lua-bindings/auto/api/RichElementImage.lua", + "cocos/scripting/lua-bindings/auto/api/RichElementNewLine.lua", "cocos/scripting/lua-bindings/auto/api/RichElementText.lua", "cocos/scripting/lua-bindings/auto/api/RichText.lua", "cocos/scripting/lua-bindings/auto/api/Ripple3D.lua", From 0893d7d4ff15423b1855edcb780c06348e85a9be Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 19 Nov 2015 17:17:17 +0800 Subject: [PATCH 100/192] Fix text color parser for TextField widget --- .../js-bindings/script/studio/parsers/uiParser-1.x.js | 7 +++++++ web | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/uiParser-1.x.js b/cocos/scripting/js-bindings/script/studio/parsers/uiParser-1.x.js index c14763e875..4f88976592 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/uiParser-1.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/uiParser-1.x.js @@ -662,6 +662,13 @@ var va = options["vAlignment"]; if(va) widget.setTextVerticalAlignment(va); + + var r = options["colorR"]; + var g = options["colorG"]; + var b = options["colorB"]; + if (r !== undefined && g !== undefined && b !== undefined) { + widget.setTextColor(cc.color(r, g, b)); + } }; var register = [ diff --git a/web b/web index 9f65531571..56c240983a 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 9f65531571443d7ea81beb86c3a7b5c2659057d0 +Subproject commit 56c240983a8c7a6b221f840e3c45ed3d733ef102 From eccde9fe114990551f3e0a8e7c8e3283845ced52 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 19 Nov 2015 17:17:59 +0800 Subject: [PATCH 101/192] Fix PhysicsSprite not working with moveTo action issue --- extensions/physics-nodes/CCPhysicsSprite.cpp | 37 ++++++++++++++++---- extensions/physics-nodes/CCPhysicsSprite.h | 5 +++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/extensions/physics-nodes/CCPhysicsSprite.cpp b/extensions/physics-nodes/CCPhysicsSprite.cpp index 86080ad7aa..aaacbfa89b 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.cpp +++ b/extensions/physics-nodes/CCPhysicsSprite.cpp @@ -195,6 +195,12 @@ float PhysicsSprite::getPositionY() const return getPosFromPhysics().y; } +Vec3 PhysicsSprite::getPosition3D() const +{ + Vec2 pos = getPosFromPhysics(); + return Vec3(pos.x, pos.y, 0); +} + // // Chipmunk only // @@ -280,19 +286,38 @@ const Vec2& PhysicsSprite::getPosFromPhysics() const return s_physicPosion; } -void PhysicsSprite::setPosition(const Vec2 &pos) +void PhysicsSprite::setPosition(float x, float y) { #if CC_ENABLE_CHIPMUNK_INTEGRATION - - cpVect cpPos = cpv(pos.x, pos.y); + + cpVect cpPos = cpv(x, y); cpBodySetPos(_CPBody, cpPos); - + #elif CC_ENABLE_BOX2D_INTEGRATION - + float angle = _pB2Body->GetAngle(); - _pB2Body->SetTransform(b2Vec2(pos.x / _PTMRatio, pos.y / _PTMRatio), angle); + _pB2Body->SetTransform(b2Vec2(x / _PTMRatio, y / _PTMRatio), angle); #endif +} +void PhysicsSprite::setPosition(const Vec2 &pos) +{ + setPosition(pos.x, pos.y); +} + +void PhysicsSprite::setPositionX(float x) +{ + setPosition(x, getPositionY()); +} + +void PhysicsSprite::setPositionY(float y) +{ + setPosition(getPositionX(), y); +} + +void PhysicsSprite::setPosition3D(const Vec3& position) +{ + setPosition(position.x, position.y); } float PhysicsSprite::getRotation() const diff --git a/extensions/physics-nodes/CCPhysicsSprite.h b/extensions/physics-nodes/CCPhysicsSprite.h index ae17b824a0..b8016f2681 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.h +++ b/extensions/physics-nodes/CCPhysicsSprite.h @@ -116,7 +116,12 @@ public: virtual void getPosition(float* x, float* y) const override; virtual float getPositionX() const override; virtual float getPositionY() const override; + virtual Vec3 getPosition3D() const override; virtual void setPosition(const Vec2 &position) override; + virtual void setPosition(float x, float y) override; + virtual void setPositionX(float x) override; + virtual void setPositionY(float y) override; + virtual void setPosition3D(const Vec3& position) override; virtual float getRotation() const override; virtual void setRotation(float fRotation) override; From 19257d6120ce5bce65f7c559f7b773b24ee537be Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 19 Nov 2015 18:14:46 +0800 Subject: [PATCH 102/192] Add Overflow feature char map font. 1. fix single line clamp. --- cocos/2d/CCLabel.cpp | 51 ++++++++++--------- cocos/2d/CCLabel.h | 3 +- .../Classes/LabelTest/LabelTestNew.cpp | 4 +- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 074d7efc23..356dcd636e 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -715,15 +715,7 @@ void Label::updateLabelLetters() auto py = letterInfo.positionY - letterDef.height / 2 + _letterOffsetY; letterSprite->setPosition(px, py); - if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0) { - _reusedLetter->setScale(_bmfontScale); - }else{ - if(fabs(_bmFontSize)setScale(0); - }else{ - _reusedLetter->setScale(1.0); - } - } + this->updateReusedLetterScale(); ++it; } } @@ -858,9 +850,9 @@ bool Label::updateQuads() } if(!_enableWrap){ - auto px = _lettersInfo[ctr].positionX + letterDef.width/2; + auto px = _lettersInfo[ctr].positionX + letterDef.width/2 + _linesOffsetX[_lettersInfo[ctr].lineIndex]; if(_labelWidth > 0.f){ - if (px > _contentSize.width) { + if (px > _contentSize.width || px < 0) { if(_overflow == Overflow::CLAMP){ _reusedRect.size.width = 0; }else if(_overflow == Overflow::SHRINK){ @@ -882,20 +874,13 @@ bool Label::updateQuads() if (_reusedRect.size.height > 0.f && _reusedRect.size.width > 0.f) { _reusedLetter->setTextureRect(_reusedRect, false, _reusedRect.size); - _reusedLetter->setPosition(_lettersInfo[ctr].positionX + _linesOffsetX[_lettersInfo[ctr].lineIndex], py); + float letterPositionX = _lettersInfo[ctr].positionX + _linesOffsetX[_lettersInfo[ctr].lineIndex]; + _reusedLetter->setPosition(letterPositionX, py); auto index = static_cast(_batchNodes.at(letterDef.textureID)->getTextureAtlas()->getTotalQuads()); _lettersInfo[ctr].atlasIndex = index; - if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0) { - _reusedLetter->setScale(_bmfontScale); - }else{ - if(fabs(_bmFontSize)setScale(0); - }else{ - _reusedLetter->setScale(1.0); - } - } - + this->updateReusedLetterScale(); + _batchNodes.at(letterDef.textureID)->insertQuadFromSprite(_reusedLetter, index); } } @@ -1959,7 +1944,8 @@ bool Label::isWrapEnabled()const void Label::setOverflow(Overflow overflow) { - if(_overflow == overflow || _currentLabelType == LabelType::CHARMAP){ + if(_overflow == overflow || + (_currentLabelType == LabelType::CHARMAP && overflow == Overflow::SHRINK)){ return; } @@ -1981,4 +1967,23 @@ Label::Overflow Label::getOverflow()const return _overflow; } +void Label::updateReusedLetterScale() +{ + if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0) + { + _reusedLetter->setScale(_bmfontScale); + } + else + { + if(fabs(_bmFontSize)setScale(0); + } + else + { + _reusedLetter->setScale(1.0); + } + } +} + NS_CC_END diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index c5884c926e..bd7e6c9255 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -413,7 +413,7 @@ public: bool isWrapEnabled()const; /** - * Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type. + * Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type. Char Map font also supports all the Overflow type except for SHRINK. * * @param overflow see `Overflow` */ @@ -590,6 +590,7 @@ protected: bool setTTFConfigInternal(const TTFConfig& ttfConfig); void setBMFontSizeInternal(float fontSize); void restoreFontSize(); + void updateReusedLetterScale(); void reset(); diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index 09d7300e61..c58dbb63bc 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -2171,10 +2171,10 @@ void LabelLayoutBaseTest::initSliders(const cocos2d::Size& size) slider2->setPercent(52); addChild(slider2); auto winSize = Director::getInstance()->getVisibleSize(); - auto labelSize = _label->getContentSize(); slider->addEventListener([=](Ref* ref, Slider::EventType event){ float percent = slider->getPercent(); + auto labelSize = _label->getContentSize(); auto drawNodeSize = Size(percent / 100.0 * winSize.width, labelSize.height); if(drawNodeSize.width <=0){ drawNodeSize.width = 0.1f; @@ -2185,6 +2185,7 @@ void LabelLayoutBaseTest::initSliders(const cocos2d::Size& size) slider2->addEventListener([=](Ref* ref, Slider::EventType event){ float percent = slider2->getPercent(); + auto labelSize = _label->getContentSize(); auto drawNodeSize = Size( labelSize.width, percent / 100.0 * winSize.height); if(drawNodeSize.height <= 0){ drawNodeSize.height = 0.1f; @@ -2310,6 +2311,7 @@ std::string LabelWrapByWordTest::subtitle() const LabelWrapByCharTest::LabelWrapByCharTest() { _label->setLineBreakWithoutSpace(true); + _label->setString("五六七八This \nis a very long sentence一二三四."); _label->setLineSpacing(5); _label->setAdditionalKerning(2); _label->setVerticalAlignment(TextVAlignment::TOP); From 8c257493665dd12a75b4d74381178a564e160fde Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 20 Nov 2015 10:54:05 +0800 Subject: [PATCH 103/192] minor improvement --- cocos/2d/CCLabel.cpp | 22 ++++++++++++++-------- cocos/2d/CCLabel.h | 6 ++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 356dcd636e..2852389849 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -769,12 +769,7 @@ bool Label::alignText() computeAlignmentOffset(); if(_enableWrap && _overflow == Overflow::SHRINK){ - float fontSize = 0; - if (_currentLabelType == LabelType::BMFONT) { - fontSize = _bmFontSize; - }else if(_currentLabelType == LabelType::TTF){ - fontSize = this->getTTFConfig().fontSize; - } + float fontSize = this->getRenderingFontSize(); if(fontSize > 0 && isVerticalClamp()){ this->shrinkLabelToContentSize(CC_CALLBACK_0(Label::isVerticalClamp, this)); @@ -1944,10 +1939,21 @@ bool Label::isWrapEnabled()const void Label::setOverflow(Overflow overflow) { - if(_overflow == overflow || - (_currentLabelType == LabelType::CHARMAP && overflow == Overflow::SHRINK)){ + if(_overflow == overflow){ return; } + + if (_currentLabelType == LabelType::CHARMAP) { + if (overflow == Overflow::SHRINK) { + return; + } + } + + if (_currentLabelType == LabelType::STRING_TEXTURE) { + if (overflow == Overflow::CLAMP || overflow == Overflow::SHRINK) { + return; + } + } if(overflow == Overflow::RESIZE_HEIGHT){ this->setDimensions(_labelDimensions.width,0); diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index bd7e6c9255..4870fccb5f 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -399,7 +399,7 @@ public: float getBMFontSize()const; /** - * Toggle wrap option the label. + * Toggle wrap option of the label. * Note: System font doesn't support manually toggle wrap. * * @param enable Set true to enable wrap and false to disable wrap. @@ -413,7 +413,9 @@ public: bool isWrapEnabled()const; /** - * Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type. Char Map font also supports all the Overflow type except for SHRINK. + * Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type. + * Char Map font supports all the Overflow type except for SHRINK, because we can't measure it's font size. + * System font only support Overflow::Normal and Overflow::RESIZE_HEIGHT. * * @param overflow see `Overflow` */ From 4829a037f7d78cf90d617378b32611a472eede1d Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Fri, 20 Nov 2015 15:53:36 +0900 Subject: [PATCH 104/192] Fix #14440 --- cocos/ui/UILayoutComponent.cpp | 4 ++-- cocos/ui/UIPageView.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/ui/UILayoutComponent.cpp b/cocos/ui/UILayoutComponent.cpp index 56fbee58a7..b36f568c50 100644 --- a/cocos/ui/UILayoutComponent.cpp +++ b/cocos/ui/UILayoutComponent.cpp @@ -672,8 +672,8 @@ namespace ui { PageView* page = static_cast(_owner); page->forceDoLayout(); - Vector _layoutVector = page->getPages(); - for(auto& item : _layoutVector) + Vector _widgetVector = page->getItems(); + for(auto& item : _widgetVector) { ui::Helper::doLayout(item); } diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 42198f6f0c..17904d2c38 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -298,7 +298,7 @@ ssize_t PageView::getCurPageIndex() const Vector& PageView::getPages() { - CCASSERT(false, "This method is obsolete!"); + CCLOG("This method is obsolete!"); // Temporary code to keep backward compatibility. static Vector pages; From 7ee82f20fce7b2d57f499fe83342448170187c05 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 20 Nov 2015 16:39:48 +0800 Subject: [PATCH 105/192] fix getLetter crash issue. 1. make vertical clamp works in non-wrap mode. 2. make the lineHeight and letterSprite scale work correct. --- cocos/2d/CCLabel.cpp | 34 +++++++++++-------- cocos/2d/CCLabel.h | 3 +- cocos/2d/CCLabelTextFormatter.cpp | 2 +- .../Classes/LabelTest/LabelTestNew.cpp | 14 ++++++++ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 2852389849..e9d3e93906 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -699,6 +699,8 @@ void Label::updateLabelLetters() uvRect.origin.x = letterDef.U; uvRect.origin.y = letterDef.V; + auto batchNode = _batchNodes.at(letterDef.textureID); + letterSprite->setTextureAtlas(batchNode->getTextureAtlas()); letterSprite->setTexture(_fontAtlas->getTexture(letterDef.textureID)); if (letterDef.width <= 0.f || letterDef.height <= 0.f) { @@ -715,7 +717,7 @@ void Label::updateLabelLetters() auto py = letterInfo.positionY - letterDef.height / 2 + _letterOffsetY; letterSprite->setPosition(px, py); - this->updateReusedLetterScale(); + this->updateLetterSpriteScale(letterSprite); ++it; } } @@ -768,7 +770,7 @@ bool Label::alignText() } computeAlignmentOffset(); - if(_enableWrap && _overflow == Overflow::SHRINK){ + if(_overflow == Overflow::SHRINK){ float fontSize = this->getRenderingFontSize(); if(fontSize > 0 && isVerticalClamp()){ @@ -874,7 +876,7 @@ bool Label::updateQuads() auto index = static_cast(_batchNodes.at(letterDef.textureID)->getTextureAtlas()->getTotalQuads()); _lettersInfo[ctr].atlasIndex = index; - this->updateReusedLetterScale(); + this->updateLetterSpriteScale(_reusedLetter); _batchNodes.at(letterDef.textureID)->insertQuadFromSprite(_reusedLetter, index); } @@ -1611,7 +1613,7 @@ void Label::setLineHeight(float height) float Label::getLineHeight() const { CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!"); - return _textSprite ? 0.0f : _lineHeight; + return _textSprite ? 0.0f : _lineHeight * _bmfontScale; } void Label::setLineSpacing(float height) @@ -1924,10 +1926,8 @@ void Label::enableWrap(bool enable) } this->_enableWrap = enable; - auto renderingFontSize = this->getRenderingFontSize(); - if (fabs(_originalFontSize - renderingFontSize) >= 1) { - this->scaleFontSizeDown(_originalFontSize); - } + + this->rescaleWithOriginalFontSize(); _contentDirty = true; } @@ -1961,11 +1961,17 @@ void Label::setOverflow(Overflow overflow) } _overflow = overflow; + this->rescaleWithOriginalFontSize(); + + _contentDirty = true; +} + +void Label::rescaleWithOriginalFontSize() +{ auto renderingFontSize = this->getRenderingFontSize(); - if (fabs(_originalFontSize - renderingFontSize) >= 1) { + if (_originalFontSize - renderingFontSize >= 1) { this->scaleFontSizeDown(_originalFontSize); } - _contentDirty = true; } Label::Overflow Label::getOverflow()const @@ -1973,21 +1979,21 @@ Label::Overflow Label::getOverflow()const return _overflow; } -void Label::updateReusedLetterScale() +void Label::updateLetterSpriteScale(Sprite* sprite) { if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0) { - _reusedLetter->setScale(_bmfontScale); + sprite->setScale(_bmfontScale); } else { if(fabs(_bmFontSize)setScale(0); + sprite->setScale(0); } else { - _reusedLetter->setScale(1.0); + sprite->setScale(1.0); } } } diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 4870fccb5f..1bfa698a87 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -572,6 +572,7 @@ protected: bool isHorizontalClamp(); bool isVerticalClamp(); float getRenderingFontSize()const; + void rescaleWithOriginalFontSize(); void updateLabelLetters(); virtual bool alignText(); @@ -592,7 +593,7 @@ protected: bool setTTFConfigInternal(const TTFConfig& ttfConfig); void setBMFontSizeInternal(float fontSize); void restoreFontSize(); - void updateReusedLetterScale(); + void updateLetterSpriteScale(Sprite* sprite); void reset(); diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index cc22d83b8c..9e5f6d83a5 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -371,7 +371,7 @@ void Label::shrinkLabelToContentSize(std::function lambda) int i = 0; auto letterDefinition = _fontAtlas->_letterDefinitions; auto tempLetterDefinition = letterDefinition; - float originalLineHeight = this->getLineHeight(); + float originalLineHeight = _lineHeight; bool flag = true; while (lambda()) { ++i; diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index c58dbb63bc..486d0a7725 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -2264,6 +2264,14 @@ void LabelLayoutBaseTest::valueChanged(cocos2d::Ref *sender, cocos2d::extension: _label->setBMFontSize(fontSize); } this->updateDrawNodeSize(_label->getContentSize()); + + //FIXME::When calling getLetter, the label Overflow feature will be invalid. +// auto letterSprite = _label->getLetter(1); +// auto moveBy = ScaleBy::create(1.0,2.0); +// letterSprite->stopAllActions(); +// letterSprite->runAction(Sequence::create(moveBy, moveBy->clone()->reverse(), nullptr )); +// +// CCLOG("label line height = %f", _label->getLineHeight()); } void LabelLayoutBaseTest::updateDrawNodeSize(const cocos2d::Size &drawNodeSize) @@ -2578,6 +2586,12 @@ LabelSystemFontTest::LabelSystemFontTest() _label->setVerticalAlignment(TextVAlignment::CENTER); _label->setOverflow(Label::Overflow::NORMAL); _label->setSystemFontName("Hiragino Sans GB"); + + auto stepper = (ControlStepper*)this->getChildByName("stepper"); + stepper->setEnabled(false); + + auto checkbox = (CheckBox*)(this->getChildByName("toggleType")); + checkbox->setEnabled(false); this->updateDrawNodeSize(_label->getContentSize()); From 9328a7c1d072b7eb4c0e73f85359ff2d75d8fc4c Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 20 Nov 2015 17:35:29 +0800 Subject: [PATCH 106/192] fix scalesprite opacity issue. Ref: https://github.com/cocos2d/cocos2d-x/issues/14436 --- cocos/ui/UIScale9Sprite.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 35605110f9..f7607a49f0 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -1198,8 +1198,18 @@ namespace ui { const unsigned short sliceQuadIndices[] = {4,0,5, 1,5,0}; const unsigned short simpleQuadIndices[] = {0,1,2, 3,2,1}; + auto displayedColor = _scale9Image->getDisplayedColor(); + auto displayedOpacity = _scale9Image->getDisplayedOpacity(); + Color4B color4( displayedColor.r, displayedColor.g, displayedColor.b, displayedOpacity ); + + // special opacity for premultiplied textures + if (_scale9Image->isOpacityModifyRGB()) + { + color4.r *= displayedOpacity/255.0f; + color4.g *= displayedOpacity/255.0f; + color4.b *= displayedOpacity/255.0f; + } - Color4B color4 = Color4B(_scale9Image->getDisplayedColor()); int vertexCount = (int)(vertices.size() - 1); for (int j = 0; j <= vertexCount; ++j) From 23d8b63fcac30f6bc6c5afe16bbe02f2d1fe8c00 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 23 Nov 2015 11:41:42 +0800 Subject: [PATCH 107/192] update header file to fix studio UI js binding compile error --- cocos/ui/CocosGUI.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/ui/CocosGUI.h b/cocos/ui/CocosGUI.h index 375bf9da10..856b6fed28 100644 --- a/cocos/ui/CocosGUI.h +++ b/cocos/ui/CocosGUI.h @@ -57,6 +57,7 @@ THE SOFTWARE. #include "ui/UIScale9Sprite.h" #include "ui/UIEditBox/UIEditBox.h" #include "ui/UILayoutComponent.h" +#include "2d/CocosStudioExtension.h" /** * @addtogroup ui From 12df5ae1cc95f53f84d98555523589d256aa6f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupayrat?= Date: Mon, 16 Nov 2015 17:53:23 +0100 Subject: [PATCH 108/192] Fix wrong variable use for setPlaceholderFontName 1. fix editbox scale not affect native font size --- cocos/ui/UIEditBox/UIEditBox.cpp | 2 +- cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp | 6 +++--- .../UITest/CocoStudioGUITest/UIEditBoxTest.cpp | 14 +++++++++++--- .../UITest/CocoStudioGUITest/UIEditBoxTest.h | 1 + 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBox.cpp b/cocos/ui/UIEditBox/UIEditBox.cpp index 32e4c708df..d87e6a64f4 100644 --- a/cocos/ui/UIEditBox/UIEditBox.cpp +++ b/cocos/ui/UIEditBox/UIEditBox.cpp @@ -268,7 +268,7 @@ void EditBox::setPlaceholderFontName(const char* pFontName) _placeholderFontName = pFontName; if (_editBoxImpl != nullptr) { - _editBoxImpl->setPlaceholderFont(pFontName, _fontSize); + _editBoxImpl->setPlaceholderFont(pFontName, _placeholderFontSize); } } diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp index c44dec4468..1ecc199abb 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp @@ -124,7 +124,7 @@ void EditBoxImplCommon::setInactiveText(const char* pText) void EditBoxImplCommon::setFont(const char* pFontName, int fontSize) { - this->setNativeFont(pFontName, fontSize); + this->setNativeFont(pFontName, fontSize * _label->getNodeToWorldAffineTransform().a); if(strlen(pFontName) > 0) { @@ -145,7 +145,7 @@ void EditBoxImplCommon::setFontColor(const Color4B& color) void EditBoxImplCommon::setPlaceholderFont(const char* pFontName, int fontSize) { - this->setNativePlaceholderFont(pFontName, fontSize); + this->setNativePlaceholderFont(pFontName, fontSize * _labelPlaceHolder->getNodeToWorldAffineTransform().a); if( strlen(pFontName) > 0) { @@ -249,7 +249,7 @@ void EditBoxImplCommon::setContentSize(const Size& size) auto director = cocos2d::Director::getInstance(); auto glview = director->getOpenGLView(); - Size controlSize = Size(size.width * glview->getScaleX(),size.height * glview->getScaleY()); + Size controlSize = Size(size.width * glview->getScaleX() * _label->getNodeToWorldAffineTransform().a,size.height * glview->getScaleY() * _label->getNodeToWorldAffineTransform().a); this->setNativeContentSize(controlSize); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp index c6dd7d9a31..81819a5e11 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp @@ -100,17 +100,25 @@ bool UIEditBoxTest::init() addChild(buttonPassword); // bottom + // Add an intermediate Node to test scaling and content size relative to world + _editEmailParent = Node::create(); + _editEmailParent->setScale(0.5); + _editEmailParent->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2-50, visibleOrigin.y+visibleSize.height/4)); + addChild(_editEmailParent); + auto bottomButtonSize = Size(editBoxSize.width, editBoxSize.height + 10); _editEmail = ui::EditBox::create(bottomButtonSize, "extensions/yellow_edit.png"); - _editEmail->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2-50, visibleOrigin.y+visibleSize.height/4)); _editEmail->setPlaceHolder("Email:"); _editEmail->setInputMode(ui::EditBox::InputMode::EMAIL_ADDRESS); _editEmail->setDelegate(this); - addChild(_editEmail); + _editEmailParent->addChild(_editEmail); + //It is required to use setFontSize and setContentSize after adding it to the hierarchy, so that native EditBox get the right size + _editEmail->setFontSize(30); + _editEmail->setContentSize(bottomButtonSize); auto buttonEmail = (ui::Button*)button->clone(); buttonEmail->setTitleText("Multiline"); - buttonEmail->setPosition(_editEmail->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); + buttonEmail->setPosition(_editEmailParent->getPosition() + Vec2(editBoxSize.width/2 + buttonSize.width/2, 0 )); buttonEmail->addClickEventListener([=](Ref* ref){ _editEmail->setInputMode(ui::EditBox::InputMode::ANY); }); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h index c4680c30c6..57c0ee3354 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h @@ -47,6 +47,7 @@ protected: cocos2d::ui::EditBox* _editName; cocos2d::ui::EditBox* _editPassword; cocos2d::ui::EditBox* _editEmail; + cocos2d::Node* _editEmailParent; }; #endif /* defined(__cocos2d_tests__UIEditBoxTest__) */ From 361daf7f5f3f6c4bb9abfa1a3fef57c271d714d6 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 23 Nov 2015 11:48:28 +0800 Subject: [PATCH 109/192] fix wrong indentation --- .../cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h index 57c0ee3354..1a07feed1c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h @@ -47,7 +47,7 @@ protected: cocos2d::ui::EditBox* _editName; cocos2d::ui::EditBox* _editPassword; cocos2d::ui::EditBox* _editEmail; - cocos2d::Node* _editEmailParent; + cocos2d::Node* _editEmailParent; }; #endif /* defined(__cocos2d_tests__UIEditBoxTest__) */ From dfe4999a06bda4b8f2a2554d475a3345dbb1ba0e Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 23 Nov 2015 16:53:18 +0800 Subject: [PATCH 110/192] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb13bfb315..ec9aca0708 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ Build Requirements Runtime Requirements -------------------- - * iOS 5.0+ for iPhone / iPad games + * iOS 6.0+ for iPhone / iPad games * Android 2.3+ for Android games * Windows 8.1 or Windows 10.0 for Windows Phone/Store 8.1 games * Windows 10.0 for Windows Phone/Store 10.0 games From 7676b1cb73734dd332348c2c2d7749fcde85451a Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 23 Nov 2015 17:47:30 +0800 Subject: [PATCH 111/192] improve label layout logic --- cocos/2d/CCLabel.h | 1 + cocos/2d/CCLabelTextFormatter.cpp | 190 +++++------------- .../Classes/LabelTest/LabelTestNew.cpp | 6 +- 3 files changed, 57 insertions(+), 140 deletions(-) diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 1bfa698a87..1d4e5188b9 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -568,6 +568,7 @@ protected: bool multilineTextWrapByChar(); bool multilineTextWrapByWord(); + bool multilineTextWrap(std::function lambda); void shrinkLabelToContentSize(std::function lambda); bool isHorizontalClamp(); bool isVerticalClamp(); diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 9e5f6d83a5..9454b39e46 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -72,6 +72,11 @@ void Label::computeAlignmentOffset() } } +static int getFirstCharLen(const std::u16string& utf16Text, int startIndex, int textLen) +{ + return 1; +} + static int getFirstWordLen(const std::u16string& utf16Text, int startIndex, int textLen) { auto character = utf16Text[startIndex]; @@ -106,24 +111,24 @@ void Label::updateBMFontScale() } } -bool Label::multilineTextWrapByWord() +bool Label::multilineTextWrap(std::function nextTokenLen) { int textLen = getStringLength(); int lineIndex = 0; - float nextWordX = 0.f; - float nextWordY = 0.f; + float nextTokenX = 0.f; + float nextTokenY = 0.f; float longestLine = 0.f; float letterRight = 0.f; - - auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR(); + + auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR(); float lineSpacing = _lineSpacing * contentScaleFactor; float highestY = 0.f; float lowestY = 0.f; FontLetterDefinition letterDef; Vec2 letterPosition; - + this->updateBMFontScale(); - + for (int index = 0; index < textLen; ) { auto character = _utf16Text[index]; @@ -132,20 +137,20 @@ bool Label::multilineTextWrapByWord() _linesWidth.push_back(letterRight); letterRight = 0.f; lineIndex++; - nextWordX = 0.f; - nextWordY -= _lineHeight*_bmfontScale + lineSpacing; + nextTokenX = 0.f; + nextTokenY -= _lineHeight*_bmfontScale + lineSpacing; recordPlaceholderInfo(index, character); index++; continue; } - - auto wordLen = getFirstWordLen(_utf16Text, index, textLen); - float wordHighestY = highestY;; - float wordLowestY = lowestY; - float wordRight = letterRight; - float nextLetterX = nextWordX; + + auto tokenLen = nextTokenLen(_utf16Text, index, textLen); + float tokenHighestY = highestY;; + float tokenLowestY = lowestY; + float tokenRight = letterRight; + float nextLetterX = nextTokenX; bool newLine = false; - for (int tmp = 0; tmp < wordLen;++tmp) + for (int tmp = 0; tmp < tokenLen;++tmp) { int letterIndex = index + tmp; character = _utf16Text[letterIndex]; @@ -160,15 +165,15 @@ bool Label::multilineTextWrapByWord() CCLOG("LabelTextFormatter error:can't find letter definition in font file for letter: %c", character); continue; } - + auto letterX = (nextLetterX + letterDef.offsetX * _bmfontScale) / contentScaleFactor; - if (_enableWrap && _maxLineWidth > 0.f && nextWordX > 0.f && letterX + letterDef.width * _bmfontScale > _maxLineWidth) + if (_enableWrap && _maxLineWidth > 0.f && nextTokenX > 0.f && letterX + letterDef.width * _bmfontScale > _maxLineWidth) { _linesWidth.push_back(letterRight); letterRight = 0.f; lineIndex++; - nextWordX = 0.f; - nextWordY -= (_lineHeight*_bmfontScale + lineSpacing); + nextTokenX = 0.f; + nextTokenY -= (_lineHeight*_bmfontScale + lineSpacing); newLine = true; break; } @@ -176,40 +181,40 @@ bool Label::multilineTextWrapByWord() { letterPosition.x = letterX; } - letterPosition.y = (nextWordY - letterDef.offsetY * _bmfontScale) / contentScaleFactor; + letterPosition.y = (nextTokenY - letterDef.offsetY * _bmfontScale) / contentScaleFactor; recordLetterInfo(letterPosition, character, letterIndex, lineIndex); - + if (_horizontalKernings && letterIndex < textLen - 1) nextLetterX += _horizontalKernings[letterIndex + 1]; nextLetterX += letterDef.xAdvance * _bmfontScale + _additionalKerning; - - wordRight = letterPosition.x + letterDef.width * _bmfontScale; - - if (wordHighestY < letterPosition.y) - wordHighestY = letterPosition.y; - if (wordLowestY > letterPosition.y - letterDef.height * _bmfontScale) - wordLowestY = letterPosition.y - letterDef.height * _bmfontScale; + + tokenRight = letterPosition.x + letterDef.width * _bmfontScale; + + if (tokenHighestY < letterPosition.y) + tokenHighestY = letterPosition.y; + if (tokenLowestY > letterPosition.y - letterDef.height * _bmfontScale) + tokenLowestY = letterPosition.y - letterDef.height * _bmfontScale; } if (newLine) { continue; } - - nextWordX = nextLetterX; - letterRight = wordRight; - if (highestY < wordHighestY) - highestY = wordHighestY; - if (lowestY > wordLowestY) - lowestY = wordLowestY; + + nextTokenX = nextLetterX; + letterRight = tokenRight; + if (highestY < tokenHighestY) + highestY = tokenHighestY; + if (lowestY > tokenLowestY) + lowestY = tokenLowestY; if (longestLine < letterRight) longestLine = letterRight; - - index += wordLen; + + index += tokenLen; } - + _linesWidth.push_back(letterRight); - + _numberOfLines = lineIndex + 1; _textDesiredHeight = (_numberOfLines * _lineHeight * _bmfontScale) / contentScaleFactor; if (_numberOfLines > 1) @@ -220,114 +225,25 @@ bool Label::multilineTextWrapByWord() if (_labelHeight <= 0.f) contentSize.height = _textDesiredHeight; setContentSize(contentSize); - + _tailoredTopY = contentSize.height; _tailoredBottomY = 0.f; if (highestY > 0.f) _tailoredTopY = contentSize.height + highestY; if (lowestY < -_textDesiredHeight) _tailoredBottomY = _textDesiredHeight + lowestY; - + return true; } +bool Label::multilineTextWrapByWord() +{ + return multilineTextWrap(std::bind(getFirstWordLen, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); +} + bool Label::multilineTextWrapByChar() { - int textLen = getStringLength(); - int lineIndex = 0; - float nextLetterX = 0.f; - float nextLetterY = 0.f; - float longestLine = 0.f; - float letterRight = 0.f; - - auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR(); - float lineSpacing = _lineSpacing * contentScaleFactor; - float highestY = 0.f; - float lowestY = 0.f; - FontLetterDefinition letterDef; - Vec2 letterPosition; - - this->updateBMFontScale(); - - for (int index = 0; index < textLen; index++) - { - auto character = _utf16Text[index]; - if (character == '\r') - { - recordPlaceholderInfo(index, character); - continue; - } - if (character == '\n') - { - _linesWidth.push_back(letterRight); - letterRight = 0.f; - lineIndex++; - nextLetterX = 0.f; - nextLetterY -= _lineHeight * _bmfontScale + lineSpacing; - recordPlaceholderInfo(index, character); - continue; - } - - if (_fontAtlas->getLetterDefinitionForChar(character, letterDef) == false) - { - recordPlaceholderInfo(index, character); - CCLOG("LabelTextFormatter error:can't find letter definition in font file for letter: %c", character); - continue; - } - - auto letterX = (nextLetterX + letterDef.offsetX * _bmfontScale) / contentScaleFactor; - if (_enableWrap && _maxLineWidth > 0.f && nextLetterX > 0.f && letterX + letterDef.width * _bmfontScale > _maxLineWidth) - { - _linesWidth.push_back(letterRight); - letterRight = 0.f; - lineIndex++; - nextLetterX = 0.f; - nextLetterY -= _lineHeight * _bmfontScale + lineSpacing; - letterPosition.x = letterDef.offsetX * _bmfontScale / contentScaleFactor; - } - else - { - letterPosition.x = letterX; - } - letterPosition.y = (nextLetterY - letterDef.offsetY * _bmfontScale) / contentScaleFactor; - recordLetterInfo(letterPosition, character, index, lineIndex); - - if (_horizontalKernings && index < textLen - 1) - nextLetterX += _horizontalKernings[index + 1]; - nextLetterX += letterDef.xAdvance * _bmfontScale + _additionalKerning; - - letterRight = letterPosition.x + letterDef.width * _bmfontScale; - - if (highestY < letterPosition.y) - highestY = letterPosition.y; - if (lowestY > letterPosition.y - letterDef.height * _bmfontScale) - lowestY = letterPosition.y - letterDef.height * _bmfontScale; - if (longestLine < letterRight) - longestLine = letterRight; - } - - _linesWidth.push_back(letterRight); - - _numberOfLines = lineIndex + 1; - _textDesiredHeight = (_numberOfLines * _lineHeight * _bmfontScale) / contentScaleFactor; - if (_numberOfLines > 1) - _textDesiredHeight += (_numberOfLines - 1) * _lineSpacing; - Size contentSize(_labelWidth, _labelHeight); - if (_labelWidth <= 0.f) - contentSize.width = longestLine; - if (_labelHeight <= 0.f) - contentSize.height = _textDesiredHeight; - - setContentSize(contentSize); - - _tailoredTopY = contentSize.height; - _tailoredBottomY = 0.f; - if (highestY > 0.f) - _tailoredTopY = contentSize.height + highestY; - if (lowestY < -_textDesiredHeight) - _tailoredBottomY = _textDesiredHeight + lowestY; - - return true; + return multilineTextWrap(std::bind(getFirstCharLen, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); } bool Label::isVerticalClamp() diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index 486d0a7725..71147954cc 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -2405,7 +2405,7 @@ LabelResizeTest::LabelResizeTest() auto stepper = (ControlStepper*)this->getChildByName("stepper"); stepper->setValue(12); - auto label = Label::createWithSystemFont("Word Line break:", "Arial", 10); + auto label = Label::createWithSystemFont("Char Line break:", "Arial", 10); label->setColor(Color3B::WHITE); label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); this->addChild(label); @@ -2471,7 +2471,7 @@ LabelToggleTypeTest::LabelToggleTypeTest() auto stepper = (ControlStepper*)this->getChildByName("stepper"); stepper->setValue(12); - auto label = Label::createWithSystemFont("Word Line break:", "Arial", 10); + auto label = Label::createWithSystemFont("Char Line break:", "Arial", 10); label->setColor(Color3B::WHITE); label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); this->addChild(label); @@ -2612,7 +2612,7 @@ LabelSystemFontTest::LabelSystemFontTest() }); - auto label = Label::createWithSystemFont("Word Line break:", "Arial", 10); + auto label = Label::createWithSystemFont("char Line break:", "Arial", 10); label->setColor(Color3B::WHITE); label->setPosition(Vec2(winSize.width * 0.1f, winSize.height * 0.8f)); this->addChild(label); From ded045ae261c9359c64ec7fdb978f6ca15808899 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 24 Nov 2015 07:01:07 +0000 Subject: [PATCH 112/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js | 8 ++++---- cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp | 8 ++++---- cocos/scripting/lua-bindings/auto/api/Terrain.lua | 4 ++-- .../scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js index 92337a2a8f..5a78dd38db 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js @@ -1329,11 +1329,11 @@ jsb.Terrain = { /** * @method initHeightMap - * @param {char} arg0 + * @param {String} arg0 * @return {bool} */ initHeightMap : function ( -char +str ) { return false; @@ -1373,10 +1373,10 @@ map /** * @method resetHeightMap - * @param {char} arg0 + * @param {String} arg0 */ resetHeightMap : function ( -char +str ) { }, diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp index ec78c50728..f5e50cb934 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -3823,8 +3823,8 @@ bool js_cocos2dx_3d_Terrain_initHeightMap(JSContext *cx, uint32_t argc, jsval *v cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_initHeightMap : Invalid Native Object"); if (argc == 1) { - const char* arg0 = nullptr; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_initHeightMap : Error processing arguments"); bool ret = cobj->initHeightMap(arg0); jsval jsret = JSVAL_NULL; @@ -3908,8 +3908,8 @@ bool js_cocos2dx_3d_Terrain_resetHeightMap(JSContext *cx, uint32_t argc, jsval * cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_resetHeightMap : Invalid Native Object"); if (argc == 1) { - const char* arg0 = nullptr; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_resetHeightMap : Error processing arguments"); cobj->resetHeightMap(arg0); args.rval().setUndefined(); diff --git a/cocos/scripting/lua-bindings/auto/api/Terrain.lua b/cocos/scripting/lua-bindings/auto/api/Terrain.lua index 385372f31b..357fceef0f 100644 --- a/cocos/scripting/lua-bindings/auto/api/Terrain.lua +++ b/cocos/scripting/lua-bindings/auto/api/Terrain.lua @@ -8,7 +8,7 @@ -- initialize heightMap data -- @function [parent=#Terrain] initHeightMap -- @param self --- @param #char heightMap +-- @param #string heightMap -- @return bool#bool ret (return value: bool) -------------------------------- @@ -44,7 +44,7 @@ -- reset the heightmap data. -- @function [parent=#Terrain] resetHeightMap -- @param self --- @param #char heightMap +-- @param #string heightMap -- @return Terrain#Terrain self (return value: cc.Terrain) -------------------------------- diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 7200ac1752..03954153d2 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -4969,9 +4969,9 @@ int lua_cocos2dx_3d_Terrain_initHeightMap(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - const char* arg0; + std::string arg0; - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.Terrain:initHeightMap"); arg0 = arg0_tmp.c_str(); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Terrain:initHeightMap"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_initHeightMap'", nullptr); @@ -5220,9 +5220,9 @@ int lua_cocos2dx_3d_Terrain_resetHeightMap(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - const char* arg0; + std::string arg0; - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.Terrain:resetHeightMap"); arg0 = arg0_tmp.c_str(); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Terrain:resetHeightMap"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_resetHeightMap'", nullptr); From 1ac82fa273431688ccde506fb48fef79c92c84f8 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 24 Nov 2015 15:13:52 +0800 Subject: [PATCH 113/192] fix terrain ray trace bug when there is offset --- cocos/3d/CCTerrain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 80e9adba95..79b4731a5e 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -548,7 +548,7 @@ bool Terrain::getIntersectionPoint(const Ray & ray_, Vec3 & intersectionPoint) c getWorldToNodeTransform().transformPoint(&(ray._origin)); std::set closeList; - Vec2 start = Vec2(ray._origin.x,ray._origin.z); + Vec2 start = Vec2(ray_._origin.x,ray_._origin.z); Vec2 dir = Vec2(ray._direction.x,ray._direction.z); start = convertToTerrainSpace(start); start.x /=(_terrainData._chunkSize.width+1); From a6fdd9aa098b009dc833ca4e3fac83df41cc018a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 24 Nov 2015 16:31:14 +0800 Subject: [PATCH 114/192] Improve js template documentation --- templates/js-template-default/main.js | 5 +++-- templates/js-template-runtime/main.js | 5 +++-- tests/js-tests/main.js | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/templates/js-template-default/main.js b/templates/js-template-default/main.js index 56bfaaadc4..cf03d3beb3 100644 --- a/templates/js-template-default/main.js +++ b/templates/js-template-default/main.js @@ -23,8 +23,9 @@ // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. "noCache" : false, - // Set "noCache" to true can make the loader ignoring the html page cache while loading your resources, - // especially useful in Android web browsers. + // "noCache" set whether your resources will be loaded with a timestamp suffix in the url. + // In this way, your resources will be force updated even if the browser holds a cache of it. + // It's very useful for mobile browser debuging. "id" : "gameCanvas", // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. diff --git a/templates/js-template-runtime/main.js b/templates/js-template-runtime/main.js index 0cff41c312..1cc53ae4d2 100644 --- a/templates/js-template-runtime/main.js +++ b/templates/js-template-runtime/main.js @@ -23,8 +23,9 @@ // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. "noCache" : false, - // Set "noCache" to true can make the loader ignoring the html page cache while loading your resources, - // especially useful in Android web browsers. + // "noCache" set whether your resources will be loaded with a timestamp suffix in the url. + // In this way, your resources will be force updated even if the browser holds a cache of it. + // It's very useful for mobile browser debuging. "id" : "gameCanvas", // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. diff --git a/tests/js-tests/main.js b/tests/js-tests/main.js index c5cb70295f..0a1e22bb9c 100644 --- a/tests/js-tests/main.js +++ b/tests/js-tests/main.js @@ -45,6 +45,11 @@ "frameRate" : 60, // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + + "noCache" : false, + // "noCache" set whether your resources will be loaded with a timestamp suffix in the url. + // In this way, your resources will be force updated even if the browser holds a cache of it. + // It's very useful for mobile browser debuging. "id" : "gameCanvas", // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. From 930405d52c7296af41d8c839740bea52f836baee Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 24 Nov 2015 16:32:02 +0800 Subject: [PATCH 115/192] Remove useless manual bindings for MenuItems --- .../js-bindings/manual/cocos2d_specifics.cpp | 234 ------------------ .../js-bindings/script/jsb_cocos2d.js | 7 + .../js-bindings/script/jsb_create_apis.js | 23 +- tools/tojs/cocos2dx.ini | 2 - 4 files changed, 24 insertions(+), 242 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index a83c18ce34..fcb1682745 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -276,31 +276,8 @@ static void addCallBackAndThis(JSObject *obj, jsval callback, jsval &thisObj) } } -template -JSObject* bind_menu_item(JSContext *cx, T* nativeObj, jsval callback, jsval thisObj) { - js_proxy_t *p = jsb_get_native_proxy(nativeObj); - if (p) { - addCallBackAndThis(p->obj, callback, thisObj); - return p->obj; - } else { - js_type_class_t *classType = js_get_type_from_native(nativeObj); - assert(classType); - JS::RootedObject proto(cx, classType->proto); - JS::RootedObject parent(cx, classType->parentProto); - JSObject *tmp = JS_NewObject(cx, classType->jsclass, proto, parent); - - // bind nativeObj <-> JSObject - js_proxy_t *proxy = jsb_new_proxy(nativeObj, tmp); - JS::AddNamedObjectRoot(cx, &proxy->obj, typeid(*nativeObj).name()); - addCallBackAndThis(tmp, callback, thisObj); - - return tmp; - } -} - bool js_cocos2dx_CCMenu_create(JSContext *cx, uint32_t argc, jsval *vp) { -// jsval *argv = JS_ARGV(cx, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc > 0) { Vector items; @@ -330,7 +307,6 @@ bool js_cocos2dx_CCMenu_create(JSContext *cx, uint32_t argc, jsval *vp) jsret = JSVAL_NULL; } } while (0); -// args.rval().set(jsret); args.rval().set(jsret); return true; } @@ -351,7 +327,6 @@ bool js_cocos2dx_CCMenu_create(JSContext *cx, uint32_t argc, jsval *vp) jsret = JSVAL_NULL; } } while (0); -// JS_SET_RVAL(cx, vp, jsret); args.rval().set(jsret); return true; } @@ -361,7 +336,6 @@ bool js_cocos2dx_CCMenu_create(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CCSequence_create(JSContext *cx, uint32_t argc, jsval *vp) { -// jsval *argv = JS_ARGV(cx, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc > 0) { Vector array; @@ -397,7 +371,6 @@ bool js_cocos2dx_CCSequence_create(JSContext *cx, uint32_t argc, jsval *vp) jsret = JSVAL_NULL; } } while (0); -// JS_SET_RVAL(cx, vp, jsret); args.rval().set(jsret); return true; } @@ -449,141 +422,6 @@ bool js_cocos2dx_CCSpawn_create(JSContext *cx, uint32_t argc, jsval *vp) return false; } -bool js_cocos2dx_CCMenuItem_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - if (argc >= 1) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - cocos2d::MenuItem* ret = cocos2d::MenuItem::create(); - JSObject *obj = bind_menu_item(cx, ret, args.get(0), argc == 2? args.get(1) : JSVAL_VOID); - args.rval().set(OBJECT_TO_JSVAL(obj)); - return true; - } - JS_ReportError(cx, "wrong number of arguments"); - return false; -} - -// "create" in JS -// cc.MenuItemSprite.create( normalSprite, selectedSprite, [disabledSprite], [callback_fn], [this] -bool js_cocos2dx_CCMenuItemSprite_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - if (argc >= 2 && argc <= 5) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy; - JSObject *tmpObj; - - tmpObj = args.get(0).toObjectOrNull(); - proxy = jsb_get_js_proxy(tmpObj); - cocos2d::Node* arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg0); - - tmpObj = args.get(1).toObjectOrNull(); - proxy = jsb_get_js_proxy(tmpObj); - cocos2d::Node* arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg1); - - int last = 2; - bool thirdArgIsCallback = false; - - jsval jsCallback = JSVAL_VOID; - jsval jsThis = JSVAL_VOID; - - cocos2d::Node* arg2 = NULL; - if (argc >= 3) { - tmpObj = args.get(2).toObjectOrNull(); - thirdArgIsCallback = JS_ObjectIsFunction(cx, tmpObj); - if (!thirdArgIsCallback) { - proxy = jsb_get_js_proxy(tmpObj); - arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg2); - last = 3; - } - } - cocos2d::MenuItemSprite* ret = cocos2d::MenuItemSprite::create(arg0, arg1, arg2); - if (argc >= 3) { - if (thirdArgIsCallback) { - //cc.MenuItemSprite.create( normalSprite, selectedSprite, callback_fn, [this] ) - jsCallback = args.get(last++); - if (argc == 4) { - jsThis = args.get(last); - } - } - else { - //cc.MenuItemSprite.create( normalSprite, selectedSprite, disabledSprite, callback_fn, [this] ) - if (argc >= 4) { - jsCallback = args.get(last++); - if (argc == 5) { - jsThis = args.get(last); - } - } - } - } - - JSObject *obj = bind_menu_item(cx, ret, jsCallback, jsThis); - - args.rval().set(OBJECT_TO_JSVAL(obj)); - return true; - } - JS_ReportError(cx, "Invalid number of arguments. Expecting: 2 <= args <= 5"); - return false; -} - -// "create" in JS: -// cc.MenuItemLabel.create( label, callback_fn, [this] ); -bool js_cocos2dx_CCMenuItemLabel_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - if (argc >= 1 && argc <= 3) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - proxy = jsb_get_js_proxy(tmpObj); - cocos2d::Node* arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); - TEST_NATIVE_OBJECT(cx, arg0) - cocos2d::MenuItemLabel* ret = cocos2d::MenuItemLabel::create(arg0); - JSObject *obj = bind_menu_item(cx, ret, (argc >= 2 ? args.get(1) : JSVAL_VOID), (argc == 3 ? args.get(2) : JSVAL_VOID) ); - args.rval().set(OBJECT_TO_JSVAL(obj)); - return true; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d or %d or %d", argc, 1, 2, 3); - return false; -} - -bool js_cocos2dx_CCMenuItemAtlasFont_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - if (argc >= 5) { - bool ok = true; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSStringWrapper arg0(args.get(0)); - JSStringWrapper arg1(args.get(1)); - int arg2; ok &= jsval_to_int32(cx, args.get(2), &arg2); - int arg3; ok &= jsval_to_int32(cx, args.get(3), &arg3); - int arg4; ok &= jsval_to_int32(cx, args.get(4), &arg4); - JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); - cocos2d::MenuItemAtlasFont* ret = cocos2d::MenuItemAtlasFont::create(arg0.get(), arg1.get(), arg2, arg3, arg4); - JSObject *obj = bind_menu_item(cx, ret, (argc >= 6 ? args.get(5) : JSVAL_VOID), (argc == 7 ? args.get(6) : JSVAL_VOID)); - args.rval().set(OBJECT_TO_JSVAL(obj)); - return true; - } - JS_ReportError(cx, "wrong number of arguments"); - return false; -} - -// "create" in JS -// cc.MenuItemFont.create( string, callback_fn, [this] ); -bool js_cocos2dx_CCMenuItemFont_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - if (argc >= 1 && argc <= 3) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSStringWrapper arg0(args.get(0)); - cocos2d::MenuItemFont* ret = cocos2d::MenuItemFont::create(arg0.get()); - JSObject *obj = bind_menu_item(cx, ret, (argc >= 2 ? args.get(1) : JSVAL_VOID), (argc == 3 ? args.get(2) : JSVAL_VOID)); - args.rval().set(OBJECT_TO_JSVAL(obj)); - return true; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d or %d or %d", argc, 1, 2, 3); - return false; -} - - bool js_cocos2dx_CCMenuItemToggle_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { @@ -622,63 +460,6 @@ bool js_cocos2dx_CCMenuItemToggle_create(JSContext *cx, uint32_t argc, jsval *vp return false; } -bool js_cocos2dx_MenuItem_setCallback(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_setCallback : Invalid Native Object"); - if (argc == 1 || argc == 2) { - std::function arg0; - do { - if(JS_TypeOfValue(cx, args[0]) == JSTYPE_FUNCTION) - { - JSObject* thisObj; - if (args.get(1).isObject()) - { - thisObj = args.get(1).toObjectOrNull(); - } - else - { - thisObj = JS_THIS_OBJECT(cx, vp); - } - std::shared_ptr func(new JSFunctionWrapper(cx, thisObj, args[0])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { - if (larg0) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); - largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - largv[0] = JSVAL_NULL; - } - } while (0); - JS::RootedValue rval(cx); - bool invoke_ok = func->invoke(1, &largv[0], &rval); - if (!invoke_ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; - } - else - { - arg0 = nullptr; - } - } while(0) - ; - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItem_setCallback : Error processing arguments"); - cobj->setCallback(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_MenuItem_setCallback : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} - bool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) { bool ok = true; @@ -6255,21 +6036,6 @@ void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) JS_GetProperty(cx, ccObj, "Menu", &tmpVal); tmpObj = tmpVal.toObjectOrNull(); JS_DefineFunction(cx, tmpObj, "_create", js_cocos2dx_CCMenu_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_GetProperty(cx, ccObj, "MenuItem", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItem_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_GetProperty(cx, ccObj, "MenuItemSprite", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemSprite_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_GetProperty(cx, ccObj, "MenuItemLabel", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemLabel_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_GetProperty(cx, ccObj, "MenuItemAtlasFont", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemAtlasFont_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_GetProperty(cx, ccObj, "MenuItemFont", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemFont_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_GetProperty(cx, ccObj, "MenuItemToggle", &tmpVal); tmpObj = tmpVal.toObjectOrNull(); JS_DefineFunction(cx, tmpObj, "_create", js_cocos2dx_CCMenuItemToggle_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index d545151eb3..6c0cb46b1f 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -2599,6 +2599,13 @@ cc.Texture2D.prototype.setTexParameters = function (texParams, magFilter, wrapS, cc.Texture2D.prototype.handleLoadedTexture = function (premultipled) {}; +// +// MenuItem setCallback support target +// +cc.MenuItem.prototype._setCallback = cc.MenuItem.prototype.setCallback; +cc.MenuItem.prototype.setCallback = function (callback, target) { + this._setCallback(callback.bind(target)); +}; // // MenuItemImage support sprite frame name as paramter diff --git a/cocos/scripting/js-bindings/script/jsb_create_apis.js b/cocos/scripting/js-bindings/script/jsb_create_apis.js index e38362db87..5fe8be19c2 100644 --- a/cocos/scripting/js-bindings/script/jsb_create_apis.js +++ b/cocos/scripting/js-bindings/script/jsb_create_apis.js @@ -1084,14 +1084,25 @@ cc.TMXTiledMap.create = function (tmxFile, resourcePath) { return null; }; - -// MenuItemImage +// MenuItems +cc.MenuItem.create = function (callback, target) { + return new cc.MenuItem(callback, target); +}; +cc.MenuItemLabel.create = function (label, selector, target) { + return new cc.MenuItemLabel(label, selector, target); +}; +cc.MenuItemAtlasFont.create = function (value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) { + return new cc.MenuItemAtlasFont(value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target); +}; +cc.MenuItemFont.create = function (value, callback, target) { + return new cc.MenuItemFont(value, callback, target); +}; +cc.MenuItemSprite.create = function (normalSprite, selectedSprite, three, four, five) { + return new cc.MenuItemSprite(normalSprite, selectedSprite, three, four, five || undefined); +}; cc.MenuItemImage.create = function(normalImage, selectedImage, three, four, five) { return new cc.MenuItemImage(normalImage, selectedImage, three, four, five); -} - - -// MenuItemToggle +}; cc.MenuItemToggle.create = function(/* var args */) { var n = arguments.length; diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 3cb2ee0ebd..d4981d6f76 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -50,8 +50,6 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat Director::[getAccelerometer getProjection getFrustum getRenderer getConsole getCocos2dThreadId], Layer.*::[didAccelerate keyPressed keyReleased], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], - MenuItem.*::[create setCallback], - MenuItemToggle::[initWithCallback], Copying::[*], LabelProtocol::[*], LabelTextFormatProtocol::[*], From 9c2130e88ae5c1193b7e1378798e10d886322d36 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 24 Nov 2015 18:01:50 +0800 Subject: [PATCH 116/192] fix Layout and ClippingNode nested rendering issue --- build/cocos2d_libs.xcodeproj/project.pbxproj | 22 +++++++-- cocos/2d/CCClippingNode.cpp | 10 ++-- cocos/2d/libcocos2d.vcxproj | 6 ++- cocos/2d/libcocos2d.vcxproj.filters | 10 +++- .../libcocos2d_8_1.Shared.vcxitems | 6 ++- .../libcocos2d_8_1.Shared.vcxitems.filters | 10 +++- cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 6 ++- .../libcocos2d.vcxproj.filters | 10 +++- cocos/Android.mk | 1 + cocos/base/CCStencilBitsManager.cpp | 44 +++++++++++++++++ cocos/base/CCStencilBitsManager.hpp | 49 +++++++++++++++++++ cocos/base/CMakeLists.txt | 1 + cocos/ui/UILayout.cpp | 7 ++- .../UIListViewTest/UIListViewTest.cpp | 10 ++++ 14 files changed, 170 insertions(+), 22 deletions(-) create mode 100644 cocos/base/CCStencilBitsManager.cpp create mode 100644 cocos/base/CCStencilBitsManager.hpp diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index b98cba41f3..7357b4b972 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1234,6 +1234,11 @@ 2980F02B1BA9A5550059E678 /* UITextView+CCUITextInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 2980F0201BA9A5550059E678 /* UITextView+CCUITextInput.h */; }; 2980F02C1BA9A5550059E678 /* UITextView+CCUITextInput.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */; }; 2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; }; + 298C75D51C0465D0006BAE63 /* CCStencilBitsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */; }; + 298C75D61C0465D1006BAE63 /* CCStencilBitsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */; }; + 298C75D71C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */; }; + 298C75D81C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */; }; + 298C75D91C04681F006BAE63 /* CCStencilBitsManager.hpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */; }; 299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; 299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; @@ -2072,10 +2077,10 @@ B5668D7E1B3838E4003CBD5E /* UIScrollViewBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5668D7B1B3838E4003CBD5E /* UIScrollViewBar.cpp */; }; B5668D7F1B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; }; B5668D801B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; }; - B5A738961BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; settings = {ASSET_TAGS = (); }; }; - B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; settings = {ASSET_TAGS = (); }; }; - B5A738981BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; settings = {ASSET_TAGS = (); }; }; - B5A738991BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; settings = {ASSET_TAGS = (); }; }; + B5A738961BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; }; + B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; }; + B5A738981BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; }; + B5A738991BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; }; B5CE6DBE1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; }; B5CE6DBF1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; }; B5CE6DC01B3BF2B1002B0419 /* UIAbstractCheckButton.h in Headers */ = {isa = PBXBuildFile; fileRef = B5CE6DBD1B3BF2B1002B0419 /* UIAbstractCheckButton.h */; }; @@ -4144,6 +4149,8 @@ 2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UITextView+CCUITextInput.mm"; sourceTree = ""; }; 2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = ""; }; 2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = ""; }; + 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCStencilBitsManager.cpp; path = ../base/CCStencilBitsManager.cpp; sourceTree = ""; }; + 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CCStencilBitsManager.hpp; path = ../base/CCStencilBitsManager.hpp; sourceTree = ""; }; 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = ""; }; 299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = ""; }; 299CF1F919A434BC00C378C1 /* ccRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ccRandom.cpp; path = ../base/ccRandom.cpp; sourceTree = ""; }; @@ -6037,6 +6044,8 @@ 50ABBE1C1925AB6F00A911A9 /* utlist.h */, 50ABBE1D1925AB6F00A911A9 /* ZipUtils.cpp */, 50ABBE1E1925AB6F00A911A9 /* ZipUtils.h */, + 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */, + 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */, ); name = base; path = ../cocos/2d; @@ -9229,6 +9238,7 @@ 15AE182A19AAD2F700C27E9E /* CCMeshSkin.h in Headers */, B276EF5F1988D1D500CD400F /* CCVertexIndexData.h in Headers */, 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, + 298C75D71C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */, B6DD2FDB1B04825B00E47F5F /* DetourLocalBoundary.h in Headers */, B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */, B677B0DB1B18492D006762CB /* CCNavMeshUtils.h in Headers */, @@ -10669,6 +10679,7 @@ 85505F051B60E3B2003F2CD4 /* CCBoneNode.h in Headers */, B665E2491AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffectorTranslator.h in Headers */, B6CAB4461AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */, + 298C75D81C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */, 15AE18D119AAD33D00C27E9E /* CCNodeLoaderLibrary.h in Headers */, 15AE1AC319AAD40300C27E9E /* b2DistanceJoint.h in Headers */, B6CAB5261AF9AA1A00B9B856 /* btQuickprof.h in Headers */, @@ -11830,6 +11841,7 @@ B665E2EE1AA80A6500DDB1C5 /* CCPULineEmitter.cpp in Sources */, B6CAB2DD1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */, B665E4121AA80A6600DDB1C5 /* CCPUTextureAnimator.cpp in Sources */, + 298C75D51C0465D0006BAE63 /* CCStencilBitsManager.cpp in Sources */, B665E3D21AA80A6600DDB1C5 /* CCPUScriptLexer.cpp in Sources */, B665E4021AA80A6600DDB1C5 /* CCPUSphereColliderTranslator.cpp in Sources */, 15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */, @@ -11964,6 +11976,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 298C75D91C04681F006BAE63 /* CCStencilBitsManager.hpp in Sources */, D0FD03541A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */, 15AE1B9819AADAA100C27E9E /* UIVideoPlayer-ios.mm in Sources */, B665E38F1AA80A6500DDB1C5 /* CCPUPlaneCollider.cpp in Sources */, @@ -12114,6 +12127,7 @@ 15AE193C19AAD35100C27E9E /* CCArmatureDefine.cpp in Sources */, B665E35F1AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.cpp in Sources */, B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */, + 298C75D61C0465D1006BAE63 /* CCStencilBitsManager.cpp in Sources */, 15AE194B19AAD35100C27E9E /* CCComRender.cpp in Sources */, 382384451A25915C002C4610 /* SpriteReader.cpp in Sources */, B6CAB2321AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */, diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index fa1a5fdd55..e6e1b6a5cc 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -32,6 +32,7 @@ #include "renderer/CCRenderer.h" #include "renderer/CCRenderState.h" #include "base/CCDirector.h" +#include "base/CCStencilBitsManager.hpp" #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) #define CC_CLIPPING_NODE_OPENGLES 0 @@ -42,10 +43,7 @@ NS_CC_BEGIN static GLint g_sStencilBits = -1; -// store the current stencil layer (position in the stencil buffer), -// this will allow nesting up to n ClippingNode, -// where n is the number of bits of the stencil buffer. -static GLint s_layer = -1; + #if CC_CLIPPING_NODE_OPENGLES static void setProgram(Node *n, GLProgram *p) @@ -398,7 +396,9 @@ void ClippingNode::onBeforeVisit() // INIT // increment the current layer + auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); s_layer++; + StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); // mask of the current layer (ie: for layer 3: 00000100) GLint mask_layer = 0x1 << s_layer; @@ -563,7 +563,9 @@ void ClippingNode::onAfterVisit() } // we are done using this layer, decrement + auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); s_layer--; + StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); } NS_CC_END diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 7f4b973e6d..8752d8ba2f 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -1,4 +1,4 @@ - + @@ -433,6 +433,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -1015,6 +1016,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -1383,4 +1385,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - \ No newline at end of file + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index d664d13291..01067a13cf 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -1896,6 +1896,9 @@ base + + base + renderer @@ -3728,6 +3731,9 @@ base + + base + renderer @@ -3807,4 +3813,4 @@ 3d
- \ No newline at end of file + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 55826bcba5..3ca9b6814f 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -286,6 +286,7 @@ + @@ -917,6 +918,7 @@
+ @@ -1286,4 +1288,4 @@ - \ No newline at end of file + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 67cb711ca5..5cd31d8512 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1,4 +1,4 @@ - + @@ -1812,6 +1812,9 @@ base + + base + physics3d @@ -3525,6 +3528,9 @@ base + + base + physics3d @@ -3979,4 +3985,4 @@ - \ No newline at end of file + diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index 05a3f1c085..cd02a95bd9 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -1,4 +1,4 @@ - + @@ -415,6 +415,7 @@ + @@ -1013,6 +1014,7 @@ + @@ -1673,4 +1675,4 @@ - \ No newline at end of file + diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters index d5bb1efb55..67d153e5e9 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -1767,6 +1767,9 @@ base + + base + renderer @@ -3635,6 +3638,9 @@ base + + base + renderer @@ -4017,4 +4023,4 @@ 3d - \ No newline at end of file + diff --git a/cocos/Android.mk b/cocos/Android.mk index c8bbba2b0e..a6f789ce7b 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -107,6 +107,7 @@ math/Vec2.cpp \ math/Vec3.cpp \ math/Vec4.cpp \ base/CCNinePatchImageParser.cpp \ +base/CCStencilBitsManager.cpp \ base/CCAsyncTaskPool.cpp \ base/CCAutoreleasePool.cpp \ base/CCConfiguration.cpp \ diff --git a/cocos/base/CCStencilBitsManager.cpp b/cocos/base/CCStencilBitsManager.cpp new file mode 100644 index 0000000000..ab6f20d7eb --- /dev/null +++ b/cocos/base/CCStencilBitsManager.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCStencilBitsManager.hpp" + +StencilBitsManager* StencilBitsManager::_stencilBitsManager = nullptr; + +GLint StencilBitsManager::getStencilLayerMask()const +{ + return _stencilLayerMask; +} + +void StencilBitsManager::setStencilLayerMask(GLint stencilLayer) +{ + _stencilLayerMask = stencilLayer; +} + +StencilBitsManager::StencilBitsManager() +:_stencilLayerMask(-1) +{ + +} \ No newline at end of file diff --git a/cocos/base/CCStencilBitsManager.hpp b/cocos/base/CCStencilBitsManager.hpp new file mode 100644 index 0000000000..86a5476f9b --- /dev/null +++ b/cocos/base/CCStencilBitsManager.hpp @@ -0,0 +1,49 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#ifndef StencilBitsManager_hpp +#define StencilBitsManager_hpp + +class StencilBitsManager +{ +public: + static StencilBitsManager* getInstance() + { + if(nullptr == _stencilBitsManager) + { + _stencilBitsManager = new StencilBitsManager(); + } + return _stencilBitsManager; + } + GLint getStencilLayerMask()const; + void setStencilLayerMask(GLint stencilLayer); +private: + static StencilBitsManager* _stencilBitsManager; + StencilBitsManager(); + StencilBitsManager(const StencilBitsManager& other); + StencilBitsManager& operator=(const StencilBitsManager& other); + GLint _stencilLayerMask; +}; + +#endif /* StencilBitsManager_hpp */ diff --git a/cocos/base/CMakeLists.txt b/cocos/base/CMakeLists.txt index ec3884ddeb..7f18a43b18 100644 --- a/cocos/base/CMakeLists.txt +++ b/cocos/base/CMakeLists.txt @@ -45,6 +45,7 @@ set(COCOS_BASE_SRC base/CCUserDefault.cpp base/CCValue.cpp base/ObjectFactory.cpp + base/CCStencilBitsManager.cpp base/TGAlib.cpp base/ZipUtils.cpp base/allocator/CCAllocatorDiagnostics.cpp diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 3f8cc02db8..cc6df90d6d 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -37,7 +37,7 @@ THE SOFTWARE. #include "2d/CCLayer.h" #include "2d/CCSprite.h" #include "base/CCEventFocus.h" - +#include "base/CCStencilBitsManager.hpp" NS_CC_BEGIN @@ -47,7 +47,6 @@ static const int BACKGROUNDIMAGE_Z = (-1); static const int BCAKGROUNDCOLORRENDERER_Z = (-2); static GLint g_sStencilBits = -1; -static GLint s_layer = -1; IMPLEMENT_CLASS_GUI_INFO(Layout) @@ -329,7 +328,9 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4& parentTransfor void Layout::onBeforeVisitStencil() { + auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); s_layer++; + StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); GLint mask_layer = 0x1 << s_layer; GLint mask_layer_l = mask_layer - 1; _mask_layer_le = mask_layer | mask_layer_l; @@ -454,7 +455,9 @@ void Layout::onAfterVisitStencil() glDisable(GL_STENCIL_TEST); // RenderState::StateBlock::_defaultState->setStencilTest(false); } + auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); s_layer--; + StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); } void Layout::onBeforeVisitScissor() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp index b9e4655aed..7628a20ccf 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp @@ -123,6 +123,16 @@ bool UIListViewTest_Vertical::init() custom_item->addChild(custom_button); listView->addChild(custom_item); + + auto clippingNode = ClippingNode::create(); + auto sprite = Sprite::create("cocosui/clippingHead.jpg"); + clippingNode->addChild(sprite); + auto stencil = Sprite::create("cocosui/clippingStencil.jpg"); + clippingNode->setStencil(stencil); + auto custom_item_contentSize = custom_item->getContentSize(); + clippingNode->setPosition(custom_item_contentSize.width/2, custom_item_contentSize.height/2); + clippingNode->setScale(0.5); + custom_item->addChild(clippingNode); } // insert custom item Vector& items = listView->getItems(); From b36f464c091b759b67c790be01269175acd7d1a7 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 24 Nov 2015 18:06:11 +0800 Subject: [PATCH 117/192] update ccs-res submodule --- tests/cpp-tests/Resources/ccs-res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/Resources/ccs-res b/tests/cpp-tests/Resources/ccs-res index 636129882b..e82bd71212 160000 --- a/tests/cpp-tests/Resources/ccs-res +++ b/tests/cpp-tests/Resources/ccs-res @@ -1 +1 @@ -Subproject commit 636129882b612b5fe6d1d21be1eec136a2b1340b +Subproject commit e82bd71212e53e016bf5f262f8e4bc1c50b54203 From 722f20c4b6463417867301fd01834d770c03820d Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 24 Nov 2015 18:29:58 +0800 Subject: [PATCH 118/192] Update implement remove condition macro check. --- cocos/3d/CCBundle3D.cpp | 2 -- cocos/3d/CCMesh.cpp | 4 ---- cocos/platform/CCImage.h | 1 + cocos/renderer/CCTexture2D.cpp | 2 +- cocos/renderer/CCTexture2D.h | 6 ------ cocos/renderer/CCTextureCache.cpp | 26 ++++++++++++++++++-------- cocos/renderer/CCTextureCache.h | 6 ++---- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index f6510ea58a..8be4e25243 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -1048,9 +1048,7 @@ bool Bundle3D::loadJson(const std::string& path) if (_jsonReader.ParseInsitu<0>(_jsonBuffer).HasParseError()) { clear(); -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only CCASSERT(false, "Parse json failed"); -#endif return false; } diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 1abf4ad5b5..f48510e672 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -80,11 +80,7 @@ void Mesh::resetLightUniformValues() _spotLightUniformColorValues.assign(maxSpotLight, Vec3::ZERO); _spotLightUniformPositionValues.assign(maxSpotLight, Vec3::ZERO); _spotLightUniformDirValues.assign(maxSpotLight, Vec3::ZERO); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - _spotLightUniformInnerAngleCosValues.assign(maxSpotLight, 0.0f); -#else _spotLightUniformInnerAngleCosValues.assign(maxSpotLight, 1.0f); -#endif // CC_STUDIO_ENABLED_VIEW _spotLightUniformOuterAngleCosValues.assign(maxSpotLight, 0.0f); _spotLightUniformRangeInverseValues.assign(maxSpotLight, 0.0f); } diff --git a/cocos/platform/CCImage.h b/cocos/platform/CCImage.h index 87df93981a..cbf5ef6de1 100644 --- a/cocos/platform/CCImage.h +++ b/cocos/platform/CCImage.h @@ -131,6 +131,7 @@ public: inline MipmapInfo* getMipmaps() { return _mipmaps; } inline bool hasPremultipliedAlpha() { return _hasPremultipliedAlpha; } CC_DEPRECATED_ATTRIBUTE inline bool isPremultipliedAlpha() { return _hasPremultipliedAlpha; } + inline std::string getFilePath() const { return _filePath; } int getBitPerPixel(); bool hasAlpha(); diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index e2ef8610e3..e35e2196a4 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -730,7 +730,7 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format) int imageWidth = image->getWidth(); int imageHeight = image->getHeight(); - + this->_filePath = image->getFilePath(); Configuration *conf = Configuration::getInstance(); int maxTextureSize = conf->getMaxTextureSize(); diff --git a/cocos/renderer/CCTexture2D.h b/cocos/renderer/CCTexture2D.h index e4c197fc23..28d8059c5e 100644 --- a/cocos/renderer/CCTexture2D.h +++ b/cocos/renderer/CCTexture2D.h @@ -410,12 +410,6 @@ public: bool isValid() const { return _valid; } std::string getPath()const { return _filePath; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - // Following function must be use carefully, it may cause resource management issue. - // So it limited to use as cocostudio internal. - void setPath(std::string file) { _filePath = file; } -#endif - public: /** Get pixel info map, the key-value pairs is PixelFormat and PixelFormatInfo.*/ static const PixelFormatInfoMap& getPixelFormatInfoMap(); diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index cd2896c007..1430ae5891 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -493,7 +493,8 @@ void TextureCache::removeTexture(Texture2D* texture) for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */ ) { if( it->second == texture ) { - texture->release(); + texture->setValid(false); + texture->autorelease(); _textures.erase(it++); break; } else @@ -512,7 +513,8 @@ void TextureCache::removeTextureForKey(const std::string &textureKeyName) } if( it != _textures.end() ) { - (it->second)->release(); + it->second->setValid(false); + (it->second)->autorelease(); _textures.erase(it); } } @@ -598,7 +600,6 @@ std::string TextureCache::getCachedTextureInfo() const return buffer; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void TextureCache::renameTextureWithKey(std::string srcName, std::string dstName) { std::string key = srcName; @@ -612,13 +613,22 @@ void TextureCache::renameTextureWithKey(std::string srcName, std::string dstName if( it != _textures.end() ) { std::string fullpath = FileUtils::getInstance()->fullPathForFilename(dstName); Texture2D* tex = it->second; - tex->setPath(key); - _textures.insert(std::make_pair(fullpath, tex)); - _textures.erase(it); - this->setDirty(true); + + Image* image = new Image(); + if (image) + { + bool ret = image->initWithImageFile(dstName); + if (ret) + { + tex->initWithImage(image); + _textures.insert(std::make_pair(fullpath, tex)); + _textures.erase(it); + this->setDirty(true); + } + CC_SAFE_DELETE(image); + } } } -#endif #if CC_ENABLE_CACHE_TEXTURE_DATA diff --git a/cocos/renderer/CCTextureCache.h b/cocos/renderer/CCTextureCache.h index 51dcdc3968..5b769491ba 100644 --- a/cocos/renderer/CCTextureCache.h +++ b/cocos/renderer/CCTextureCache.h @@ -206,11 +206,9 @@ public: void setDirty(bool dirty) { _dirty = dirty; } bool isDirty() const { return _dirty; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - // This function use Texture2D::setPath function, which set to use in - // CococsStudio internal only, so this function also been set internal only + void renameTextureWithKey(std::string srcName, std::string dstName); -#endif + private: void addImageAsyncCallBack(float dt); From 27f6d6a6ba6f39cbffc0c12999f9e510077266dd Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 24 Nov 2015 19:17:38 +0800 Subject: [PATCH 119/192] Remove condition macro check. --- cocos/cocos2d.h | 2 +- cocos/ui/UIAbstractCheckButton.cpp | 30 ------------------------------ cocos/ui/UIButton.cpp | 21 --------------------- cocos/ui/UIImageView.h | 2 +- cocos/ui/UISlider.cpp | 30 ------------------------------ 5 files changed, 2 insertions(+), 83 deletions(-) diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 1f3a539d2c..282321f4fb 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -30,7 +30,7 @@ THE SOFTWARE. // 0x00 HI ME LO // 00 03 08 00 -#define COCOS2D_VERSION 0x00030900 +#define COCOS2D_VERSION 0x00030800 // // all cocos2d include files diff --git a/cocos/ui/UIAbstractCheckButton.cpp b/cocos/ui/UIAbstractCheckButton.cpp index b5886da07a..cfff50539f 100644 --- a/cocos/ui/UIAbstractCheckButton.cpp +++ b/cocos/ui/UIAbstractCheckButton.cpp @@ -136,12 +136,6 @@ void AbstractCheckButton::loadTextures(const std::string& backGround, void AbstractCheckButton::loadTextureBackGround(const std::string& backGround,TextureResType texType) { _backGroundFileName = backGround; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (backGround.empty()) - { - return; - } -#endif _backGroundTexType = texType; switch (_backGroundTexType) @@ -178,12 +172,6 @@ void AbstractCheckButton::loadTextureBackGroundSelected(const std::string& backG { _backGroundSelectedFileName = backGroundSelected; _isBackgroundSelectedTextureLoaded = !backGroundSelected.empty(); -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (backGroundSelected.empty()) - { - return; - } -#endif _backGroundSelectedTexType = texType; switch (_backGroundSelectedTexType) @@ -215,12 +203,6 @@ void AbstractCheckButton::setupBackgroundSelectedTexture() void AbstractCheckButton::loadTextureFrontCross(const std::string& cross,TextureResType texType) { _frontCrossFileName = cross; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (cross.empty()) - { - return; - } -#endif _frontCrossTexType = texType; switch (_frontCrossTexType) @@ -253,12 +235,6 @@ void AbstractCheckButton::loadTextureBackGroundDisabled(const std::string& backG { _backGroundDisabledFileName = backGroundDisabled; _isBackgroundDisabledTextureLoaded = !backGroundDisabled.empty(); -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (backGroundDisabled.empty()) - { - return; - } -#endif _backGroundDisabledTexType = texType; switch (_backGroundDisabledTexType) @@ -292,12 +268,6 @@ void AbstractCheckButton::loadTextureFrontCrossDisabled(const std::string& front { _frontCrossDisabledFileName = frontCrossDisabled; _isFrontCrossDisabledTextureLoaded = !frontCrossDisabled.empty(); -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (frontCrossDisabled.empty()) - { - return; - } -#endif _frontCrossDisabledTexType = texType; switch (_frontCrossDisabledTexType) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 060cc89f4e..afa194912f 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -233,13 +233,6 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) _normalFileName = normal; _normalTexType = texType; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (normal.empty()) - { - return; - } -#endif - switch (texType) { case TextureResType::LOCAL: @@ -290,13 +283,6 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy _clickedFileName = selected; _pressedTexType = texType; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (selected.empty()) - { - return; - } -#endif - switch (texType) { case TextureResType::LOCAL: @@ -333,13 +319,6 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT _disabledFileName = disabled; _disabledTexType = texType; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (disabled.empty()) - { - return; - } -#endif - switch (texType) { case TextureResType::LOCAL: diff --git a/cocos/ui/UIImageView.h b/cocos/ui/UIImageView.h index 7c2a82ac27..bcd3f700a5 100644 --- a/cocos/ui/UIImageView.h +++ b/cocos/ui/UIImageView.h @@ -38,7 +38,7 @@ struct CC_DLL ResouceData; namespace ui { class Scale9Sprite; - /** +/** * @brief A widget to display images. */ class CC_GUI_DLL ImageView : public Widget diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index ec571ba532..15d6b594c8 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -154,12 +154,6 @@ void Slider::initRenderer() void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) { _textureFile = fileName; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (fileName.empty()) - { - return; - } -#endif _barTexType = texType; switch (_barTexType) { @@ -192,12 +186,6 @@ void Slider::setupBarTexture() void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType texType) { _progressBarTextureFile = fileName; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (fileName.empty()) - { - return; - } -#endif _progressBarTexType = texType; switch (_progressBarTexType) { @@ -318,12 +306,6 @@ void Slider::loadSlidBallTextures(const std::string& normal, void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType texType) { _slidBallNormalTextureFile = normal; -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (normal.empty()) - { - return; - } -#endif _ballNTexType = texType; switch (_ballNTexType) { @@ -348,12 +330,6 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp { _slidBallPressedTextureFile = pressed; _isSliderBallPressedTextureLoaded = !pressed.empty(); -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (pressed.empty()) - { - return; - } -#endif _ballPTexType = texType; switch (_ballPTexType) { @@ -380,12 +356,6 @@ void Slider::loadSlidBallTextureDisabled(const std::string& disabled,TextureResT { _slidBallDisabledTextureFile = disabled; _isSliderBallDisabledTexturedLoaded = !disabled.empty(); -#ifndef CC_STUDIO_ENABLED_VIEW // for cocostudio only - if (disabled.empty()) - { - return; - } -#endif _ballDTexType = texType; switch (_ballDTexType) { From 866c992f412a3f4514bb647080b9eb38d3d90018 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 24 Nov 2015 20:26:48 +0800 Subject: [PATCH 120/192] add cocos2d namespace --- cocos/base/CCStencilBitsManager.cpp | 6 +++++- cocos/base/CCStencilBitsManager.hpp | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cocos/base/CCStencilBitsManager.cpp b/cocos/base/CCStencilBitsManager.cpp index ab6f20d7eb..be689286f5 100644 --- a/cocos/base/CCStencilBitsManager.cpp +++ b/cocos/base/CCStencilBitsManager.cpp @@ -25,6 +25,8 @@ #include "CCStencilBitsManager.hpp" +NS_CC_BEGIN + StencilBitsManager* StencilBitsManager::_stencilBitsManager = nullptr; GLint StencilBitsManager::getStencilLayerMask()const @@ -41,4 +43,6 @@ StencilBitsManager::StencilBitsManager() :_stencilLayerMask(-1) { -} \ No newline at end of file +} + +NS_CC_END diff --git a/cocos/base/CCStencilBitsManager.hpp b/cocos/base/CCStencilBitsManager.hpp index 86a5476f9b..b630f83068 100644 --- a/cocos/base/CCStencilBitsManager.hpp +++ b/cocos/base/CCStencilBitsManager.hpp @@ -24,8 +24,17 @@ ****************************************************************************/ #ifndef StencilBitsManager_hpp #define StencilBitsManager_hpp +#include "base/ccConfig.h" +#include "platform/CCPlatformMacros.h" +#include "platform/CCGL.h" -class StencilBitsManager +/** + * @addtogroup base + * @{ + */ +NS_CC_BEGIN + +class CC_DLL StencilBitsManager { public: static StencilBitsManager* getInstance() @@ -46,4 +55,7 @@ private: GLint _stencilLayerMask; }; +NS_CC_END +// end of base group +/** @} */ #endif /* StencilBitsManager_hpp */ From c0f7ecfcde2a664b10c1aa1e69054c576625592a Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 09:49:19 +0800 Subject: [PATCH 121/192] User GetModuleFileNameW in all condition, it is more safe than _get_wpgmptr --- cocos/platform/win32/CCFileUtils-win32.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cocos/platform/win32/CCFileUtils-win32.cpp b/cocos/platform/win32/CCFileUtils-win32.cpp index 3469b11e61..c4c376ded1 100644 --- a/cocos/platform/win32/CCFileUtils-win32.cpp +++ b/cocos/platform/win32/CCFileUtils-win32.cpp @@ -136,14 +136,9 @@ static void _checkPath() { if (s_resourcePath.empty()) { - WCHAR *pUtf16ExePath = nullptr; -#ifdef CC_STUDIO_ENABLED_VIEW WCHAR utf16Path[CC_MAX_PATH] = { 0 }; GetModuleFileNameW(NULL, utf16Path, CC_MAX_PATH - 1); - pUtf16ExePath = &(utf16Path[0]); -#else - _get_wpgmptr(&pUtf16ExePath); // CocoStudio Notice : This function won't work under studio, will cause a assert in system library -#endif + WCHAR *pUtf16ExePath = &(utf16Path[0]); // We need only directory part without exe WCHAR *pUtf16DirEnd = wcsrchr(pUtf16ExePath, L'\\'); From d0cd640ac8a3e549c20114203cad800390a7d312 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 11:15:17 +0800 Subject: [PATCH 122/192] Update --- cocos/3d/CCSprite3D.h | 2 +- cocos/renderer/CCTextureCache.cpp | 2 +- cocos/renderer/CCTextureCache.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index c9f729d70f..48d8452c5a 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -200,7 +200,7 @@ public: */ void setForce2DQueue(bool force2D); - Vector& getMeshes() { return _meshes; } + const Vector& getMeshes() const { return _meshes; } const AABB& getAABB(bool world) const; CC_CONSTRUCTOR_ACCESS: diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index 1430ae5891..89c70188ba 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -600,7 +600,7 @@ std::string TextureCache::getCachedTextureInfo() const return buffer; } -void TextureCache::renameTextureWithKey(std::string srcName, std::string dstName) +void TextureCache::renameTextureWithKey(const std::string srcName, const std::string dstName) { std::string key = srcName; auto it = _textures.find(key); diff --git a/cocos/renderer/CCTextureCache.h b/cocos/renderer/CCTextureCache.h index 5b769491ba..730f3ea3fa 100644 --- a/cocos/renderer/CCTextureCache.h +++ b/cocos/renderer/CCTextureCache.h @@ -207,7 +207,7 @@ public: void setDirty(bool dirty) { _dirty = dirty; } bool isDirty() const { return _dirty; } - void renameTextureWithKey(std::string srcName, std::string dstName); + void renameTextureWithKey(const std::string srcName, const std::string dstName); private: From 09606e96cd462da6cdd742d116be012dc240acfc Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 11:33:24 +0800 Subject: [PATCH 123/192] Add comment for new function --- cocos/3d/CCSprite3D.h | 12 ++++++++++++ cocos/renderer/CCTextureCache.h | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 48d8452c5a..be9defb3a3 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -200,7 +200,19 @@ public: */ void setForce2DQueue(bool force2D); + /** + * Get meshes used in sprite 3d + */ const Vector& getMeshes() const { return _meshes; } + + /* + * Get AABB + * If the sprite has animation, it can't be calculated accurately, + * because bone can drive the vertices, we just use the origin vertices + * to calculate the AABB. + * + * @param world Use world transform or not. + */ const AABB& getAABB(bool world) const; CC_CONSTRUCTOR_ACCESS: diff --git a/cocos/renderer/CCTextureCache.h b/cocos/renderer/CCTextureCache.h index 730f3ea3fa..aa64debb7d 100644 --- a/cocos/renderer/CCTextureCache.h +++ b/cocos/renderer/CCTextureCache.h @@ -207,6 +207,14 @@ public: void setDirty(bool dirty) { _dirty = dirty; } bool isDirty() const { return _dirty; } + /** Reload texuture from a new file. + * This function is mainly for editor, won't suggest use it in game for performance reason. + * + * @param srcName Original texture file name. + * @param dstName New texture file name. + * + * @since v3.10 + */ void renameTextureWithKey(const std::string srcName, const std::string dstName); From 23f27534f6e6c1162ea53b5f3000e93820948fbb Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 25 Nov 2015 14:03:56 +0800 Subject: [PATCH 124/192] Solve a possible memory leak in HttpRequest --- cocos/network/HttpRequest.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index ea3de64a2d..1e13f9d1e6 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -252,7 +252,7 @@ public: * @param pTarget the target object pointer. * @param pSelector the SEL_HttpResponse function. */ - CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) + inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) { doSetResponseCallback(pTarget, pSelector); } @@ -339,9 +339,13 @@ public: private: inline void doSetResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) { + if (_pTarget) + { + _pTarget->release(); + } + _pTarget = pTarget; _pSelector = pSelector; - if (_pTarget) { _pTarget->retain(); From 5fef0886957d4cec37925d370ecd65e3e8a0f51e Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 25 Nov 2015 14:14:17 +0800 Subject: [PATCH 125/192] refactor stencil state management code --- cocos/2d/CCClippingNode.cpp | 267 ++------------------------ cocos/2d/CCClippingNode.h | 31 +-- cocos/base/CCStencilBitsManager.cpp | 281 +++++++++++++++++++++++++++- cocos/base/CCStencilBitsManager.hpp | 50 +++-- cocos/ui/UILayout.cpp | 163 +--------------- cocos/ui/UILayout.h | 25 +-- 6 files changed, 327 insertions(+), 490 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index e6e1b6a5cc..e2490e14fd 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -42,9 +42,6 @@ NS_CC_BEGIN -static GLint g_sStencilBits = -1; - - #if CC_CLIPPING_NODE_OPENGLES static void setProgram(Node *n, GLProgram *p) { @@ -59,22 +56,8 @@ static void setProgram(Node *n, GLProgram *p) ClippingNode::ClippingNode() : _stencil(nullptr) -, _alphaThreshold(0.0f) -, _inverted(false) -, _currentStencilEnabled(GL_FALSE) -, _currentStencilWriteMask(~0) -, _currentStencilFunc(GL_ALWAYS) -, _currentStencilRef(0) -, _currentStencilValueMask(~0) -, _currentStencilFail(GL_KEEP) -, _currentStencilPassDepthFail(GL_KEEP) -, _currentStencilPassDepthPass(GL_KEEP) -, _currentDepthWriteMask(GL_TRUE) -, _currentAlphaTestEnabled(GL_FALSE) -, _currentAlphaTestFunc(GL_ALWAYS) -, _currentAlphaTestRef(1) +,_stencilStateManager(new StencilStateManager()) { - } ClippingNode::~ClippingNode() @@ -127,19 +110,8 @@ bool ClippingNode::init(Node *stencil) _stencil = stencil; CC_SAFE_RETAIN(_stencil); - _alphaThreshold = 1; - _inverted = false; - // get (only once) the number of bits of the stencil buffer - static bool once = true; - if (once) - { - glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits); - if (g_sStencilBits <= 0) - { - CCLOG("Stencil buffer is not enabled."); - } - once = false; - } + _stencilStateManager->setAlphaThreshold(1.0f); + _stencilStateManager->setInverted(false); return true; } @@ -220,45 +192,6 @@ void ClippingNode::onExit() Node::onExit(); } -void ClippingNode::drawFullScreenQuadClearStencil() -{ - Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when setting matrix stack"); - - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - - Vec2 vertices[] = { - Vec2(-1.0f, -1.0f), - Vec2(1.0f, -1.0f), - Vec2(1.0f, 1.0f), - Vec2(-1.0f, 1.0f) - }; - - auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); - - int colorLocation = glProgram->getUniformLocation("u_color"); - CHECK_GL_ERROR_DEBUG(); - - Color4F color(1, 1, 1, 1); - - glProgram->use(); - glProgram->setUniformsForBuiltins(); - glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); - - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); -} void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { @@ -283,9 +216,10 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 renderer->pushGroup(_groupCommand.getRenderQueueID()); _beforeVisitCmd.init(_globalZOrder); - _beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this); + _beforeVisitCmd.func = CC_CALLBACK_0(StencilStateManager::onBeforeVisit, _stencilStateManager); renderer->addCommand(&_beforeVisitCmd); - if (_alphaThreshold < 1) + + if (_stencilStateManager->getAlphaThreshold() < 1) { #if CC_CLIPPING_NODE_OPENGLES // since glAlphaTest do not exists in OES, use a shader that writes @@ -305,7 +239,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 _stencil->visit(renderer, _modelViewTransform, flags); _afterDrawStencilCmd.init(_globalZOrder); - _afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this); + _afterDrawStencilCmd.func = CC_CALLBACK_0(StencilStateManager::onAfterDrawStencil, _stencilStateManager); renderer->addCommand(&_afterDrawStencilCmd); int i = 0; @@ -337,7 +271,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 } _afterVisitCmd.init(_globalZOrder); - _afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this); + _afterVisitCmd.func = CC_CALLBACK_0(StencilStateManager::onAfterVisit, _stencilStateManager); renderer->addCommand(&_afterVisitCmd); renderer->popGroup(); @@ -372,200 +306,23 @@ bool ClippingNode::hasContent() const GLfloat ClippingNode::getAlphaThreshold() const { - return _alphaThreshold; + return _stencilStateManager->getAlphaThreshold(); } void ClippingNode::setAlphaThreshold(GLfloat alphaThreshold) { - _alphaThreshold = alphaThreshold; + _stencilStateManager->setAlphaThreshold(alphaThreshold); } bool ClippingNode::isInverted() const { - return _inverted; + return _stencilStateManager->isInverted(); } void ClippingNode::setInverted(bool inverted) { - _inverted = inverted; + _stencilStateManager->setInverted(inverted); } -void ClippingNode::onBeforeVisit() -{ - /////////////////////////////////// - // INIT - - // increment the current layer - auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); - s_layer++; - StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); - - // mask of the current layer (ie: for layer 3: 00000100) - GLint mask_layer = 0x1 << s_layer; - // mask of all layers less than the current (ie: for layer 3: 00000011) - GLint mask_layer_l = mask_layer - 1; - // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) - _mask_layer_le = mask_layer | mask_layer_l; - - // manually save the stencil state - - _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); - glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); - glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); - glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); - glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); - glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); - - // enable stencil use - glEnable(GL_STENCIL_TEST); -// RenderState::StateBlock::_defaultState->setStencilTest(true); - - // check for OpenGL error while enabling stencil test - CHECK_GL_ERROR_DEBUG(); - - // all bits on the stencil buffer are readonly, except the current layer bit, - // this means that operation like glClear or glStencilOp will be masked with this value - glStencilMask(mask_layer); -// RenderState::StateBlock::_defaultState->setStencilWrite(mask_layer); - - // manually save the depth test state - - glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); - - // disable depth test while drawing the stencil - //glDisable(GL_DEPTH_TEST); - // disable update to the depth buffer while drawing the stencil, - // as the stencil is not meant to be rendered in the real scene, - // it should never prevent something else to be drawn, - // only disabling depth buffer update should do - glDepthMask(GL_FALSE); - RenderState::StateBlock::_defaultState->setDepthWrite(false); - - /////////////////////////////////// - // CLEAR STENCIL BUFFER - - // manually clear the stencil buffer by drawing a fullscreen rectangle on it - // setup the stencil test func like this: - // for each pixel in the fullscreen rectangle - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 0 in the stencil buffer - // if in inverted mode: set the current layer value to 1 in the stencil buffer - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); - - // draw a fullscreen solid rectangle to clear the stencil buffer - //ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); - drawFullScreenQuadClearStencil(); - - /////////////////////////////////// - // DRAW CLIPPING STENCIL - - // setup the stencil test func like this: - // for each pixel in the stencil node - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 1 in the stencil buffer - // if in inverted mode: set the current layer value to 0 in the stencil buffer - glStencilFunc(GL_NEVER, mask_layer, mask_layer); -// RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_NEVER, mask_layer, mask_layer); - - glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP); -// RenderState::StateBlock::_defaultState->setStencilOperation( -// !_inverted ? RenderState::STENCIL_OP_REPLACE : RenderState::STENCIL_OP_ZERO, -// RenderState::STENCIL_OP_KEEP, -// RenderState::STENCIL_OP_KEEP); - - - // enable alpha test only if the alpha threshold < 1, - // indeed if alpha threshold == 1, every pixel will be drawn anyways - if (_alphaThreshold < 1) { -#if !CC_CLIPPING_NODE_OPENGLES - // manually save the alpha test state - _currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); - glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc); - glGetFloatv(GL_ALPHA_TEST_REF, &_currentAlphaTestRef); - // enable alpha testing - glEnable(GL_ALPHA_TEST); - // check for OpenGL error while enabling alpha test - CHECK_GL_ERROR_DEBUG(); - // pixel will be drawn only if greater than an alpha threshold - glAlphaFunc(GL_GREATER, _alphaThreshold); -#endif - } - - //Draw _stencil -} - -void ClippingNode::onAfterDrawStencil() -{ - // restore alpha test state - if (_alphaThreshold < 1) - { -#if CC_CLIPPING_NODE_OPENGLES - // FIXME: we need to find a way to restore the shaders of the stencil node and its children -#else - // manually restore the alpha test state - glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef); - if (!_currentAlphaTestEnabled) - { - glDisable(GL_ALPHA_TEST); - } -#endif - } - - // restore the depth test state - glDepthMask(_currentDepthWriteMask); - RenderState::StateBlock::_defaultState->setDepthWrite(_currentDepthWriteMask != 0); - - //if (currentDepthTestEnabled) { - // glEnable(GL_DEPTH_TEST); - //} - - /////////////////////////////////// - // DRAW CONTENT - - // setup the stencil test function like this: - // for each pixel of this node and its children - // if all layers less than or equals to the current are set to 1 in the stencil buffer - // draw the pixel and keep the current layer in the stencil buffer - // else - // do not draw the pixel but keep the current layer in the stencil buffer - glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); -// RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_EQUAL, _mask_layer_le, _mask_layer_le); - - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); -// RenderState::StateBlock::_defaultState->setStencilOperation(RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP); - - // draw (according to the stencil test function) this node and its children -} - - -void ClippingNode::onAfterVisit() -{ - /////////////////////////////////// - // CLEANUP - - // manually restore the stencil state - glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); -// RenderState::StateBlock::_defaultState->setStencilFunction((RenderState::StencilFunction)_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); - - glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); -// RenderState::StateBlock::_defaultState->setStencilOperation((RenderState::StencilOperation)_currentStencilFail, -// (RenderState::StencilOperation)_currentStencilPassDepthFail, -// (RenderState::StencilOperation)_currentStencilPassDepthPass); - - glStencilMask(_currentStencilWriteMask); - if (!_currentStencilEnabled) - { - glDisable(GL_STENCIL_TEST); -// RenderState::StateBlock::_defaultState->setStencilTest(false); - } - - // we are done using this layer, decrement - auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); - s_layer--; - StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); -} NS_CC_END diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index 63ea9140ca..faba9dfd3b 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -34,6 +34,8 @@ #include "renderer/CCCustomCommand.h" NS_CC_BEGIN + +class StencilStateManager; /** * @addtogroup _2d * @{ @@ -153,34 +155,9 @@ CC_CONSTRUCTOR_ACCESS: virtual bool init(Node *stencil); protected: - /**draw fullscreen quad to clear stencil bits - */ - void drawFullScreenQuadClearStencil(); - Node* _stencil; - GLfloat _alphaThreshold; - bool _inverted; - - //renderData and callback - void onBeforeVisit(); - void onAfterDrawStencil(); - void onAfterVisit(); - - GLboolean _currentStencilEnabled; - GLuint _currentStencilWriteMask; - GLenum _currentStencilFunc; - GLint _currentStencilRef; - GLuint _currentStencilValueMask; - GLenum _currentStencilFail; - GLenum _currentStencilPassDepthFail; - GLenum _currentStencilPassDepthPass; - GLboolean _currentDepthWriteMask; - - GLboolean _currentAlphaTestEnabled; - GLenum _currentAlphaTestFunc; - GLclampf _currentAlphaTestRef; - - GLint _mask_layer_le; + + StencilStateManager* _stencilStateManager; GroupCommand _groupCommand; CustomCommand _beforeVisitCmd; diff --git a/cocos/base/CCStencilBitsManager.cpp b/cocos/base/CCStencilBitsManager.cpp index be689286f5..e1c6835f50 100644 --- a/cocos/base/CCStencilBitsManager.cpp +++ b/cocos/base/CCStencilBitsManager.cpp @@ -24,25 +24,286 @@ ****************************************************************************/ #include "CCStencilBitsManager.hpp" +#include "base/CCDirector.h" +#include "renderer/CCGLProgramCache.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCRenderer.h" +#include "renderer/CCRenderState.h" +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) +#define CC_CLIPPING_NODE_OPENGLES 0 +#else +#define CC_CLIPPING_NODE_OPENGLES 1 +#endif NS_CC_BEGIN -StencilBitsManager* StencilBitsManager::_stencilBitsManager = nullptr; +GLint StencilStateManager::s_layer = -1; +static GLint g_sStencilBits = -1; + +StencilStateManager::StencilStateManager() +: _alphaThreshold(0.0f) +, _inverted(false) +, _currentStencilEnabled(GL_FALSE) +, _currentStencilWriteMask(~0) +, _currentStencilFunc(GL_ALWAYS) +, _currentStencilRef(0) +, _currentStencilValueMask(~0) +, _currentStencilFail(GL_KEEP) +, _currentStencilPassDepthFail(GL_KEEP) +, _currentStencilPassDepthPass(GL_KEEP) +, _currentDepthWriteMask(GL_TRUE) +, _currentAlphaTestEnabled(GL_FALSE) +, _currentAlphaTestFunc(GL_ALWAYS) +, _currentAlphaTestRef(1) -GLint StencilBitsManager::getStencilLayerMask()const { - return _stencilLayerMask; + // get (only once) the number of bits of the stencil buffer + static bool once = true; + if (once) + { + glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits); + if (g_sStencilBits <= 0) + { + CCLOG("Stencil buffer is not enabled."); + } + once = false; + } } -void StencilBitsManager::setStencilLayerMask(GLint stencilLayer) -{ - _stencilLayerMask = stencilLayer; -} - -StencilBitsManager::StencilBitsManager() -:_stencilLayerMask(-1) +void StencilStateManager::drawFullScreenQuadClearStencil() { + Director* director = Director::getInstance(); + CCASSERT(nullptr != director, "Director is null when setting matrix stack"); + director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + + director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + + Vec2 vertices[] = { + Vec2(-1.0f, -1.0f), + Vec2(1.0f, -1.0f), + Vec2(1.0f, 1.0f), + Vec2(-1.0f, 1.0f) + }; + + auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); + + int colorLocation = glProgram->getUniformLocation("u_color"); + CHECK_GL_ERROR_DEBUG(); + + Color4F color(1, 1, 1, 1); + + glProgram->use(); + glProgram->setUniformsForBuiltins(); + glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); + + director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } + +void StencilStateManager::setAlphaThreshold(GLfloat alphaThreshold) +{ + _alphaThreshold = alphaThreshold; +} + +GLfloat StencilStateManager::getAlphaThreshold()const +{ + return _alphaThreshold; +} + +void StencilStateManager::setInverted(bool inverted) +{ + _inverted = inverted; +} + +bool StencilStateManager::isInverted()const +{ + return _inverted; +} + +void StencilStateManager::onBeforeVisit() +{ + /////////////////////////////////// + // INIT + + // increment the current layer + s_layer++; + + // mask of the current layer (ie: for layer 3: 00000100) + GLint mask_layer = 0x1 << s_layer; + // mask of all layers less than the current (ie: for layer 3: 00000011) + GLint mask_layer_l = mask_layer - 1; + // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) + _mask_layer_le = mask_layer | mask_layer_l; + + // manually save the stencil state + + _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); + glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); + glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); + glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); + glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); + glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); + + // enable stencil use + glEnable(GL_STENCIL_TEST); + // RenderState::StateBlock::_defaultState->setStencilTest(true); + + // check for OpenGL error while enabling stencil test + CHECK_GL_ERROR_DEBUG(); + + // all bits on the stencil buffer are readonly, except the current layer bit, + // this means that operation like glClear or glStencilOp will be masked with this value + glStencilMask(mask_layer); + // RenderState::StateBlock::_defaultState->setStencilWrite(mask_layer); + + // manually save the depth test state + + glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); + + // disable depth test while drawing the stencil + //glDisable(GL_DEPTH_TEST); + // disable update to the depth buffer while drawing the stencil, + // as the stencil is not meant to be rendered in the real scene, + // it should never prevent something else to be drawn, + // only disabling depth buffer update should do + glDepthMask(GL_FALSE); + RenderState::StateBlock::_defaultState->setDepthWrite(false); + + /////////////////////////////////// + // CLEAR STENCIL BUFFER + + // manually clear the stencil buffer by drawing a fullscreen rectangle on it + // setup the stencil test func like this: + // for each pixel in the fullscreen rectangle + // never draw it into the frame buffer + // if not in inverted mode: set the current layer value to 0 in the stencil buffer + // if in inverted mode: set the current layer value to 1 in the stencil buffer + glStencilFunc(GL_NEVER, mask_layer, mask_layer); + glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); + + // draw a fullscreen solid rectangle to clear the stencil buffer + //ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); + drawFullScreenQuadClearStencil(); + + /////////////////////////////////// + // DRAW CLIPPING STENCIL + + // setup the stencil test func like this: + // for each pixel in the stencil node + // never draw it into the frame buffer + // if not in inverted mode: set the current layer value to 1 in the stencil buffer + // if in inverted mode: set the current layer value to 0 in the stencil buffer + glStencilFunc(GL_NEVER, mask_layer, mask_layer); + // RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_NEVER, mask_layer, mask_layer); + + glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP); + // RenderState::StateBlock::_defaultState->setStencilOperation( + // !_inverted ? RenderState::STENCIL_OP_REPLACE : RenderState::STENCIL_OP_ZERO, + // RenderState::STENCIL_OP_KEEP, + // RenderState::STENCIL_OP_KEEP); + + + // enable alpha test only if the alpha threshold < 1, + // indeed if alpha threshold == 1, every pixel will be drawn anyways + if (_alphaThreshold < 1) { +#if !CC_CLIPPING_NODE_OPENGLES + // manually save the alpha test state + _currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); + glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc); + glGetFloatv(GL_ALPHA_TEST_REF, &_currentAlphaTestRef); + // enable alpha testing + glEnable(GL_ALPHA_TEST); + // check for OpenGL error while enabling alpha test + CHECK_GL_ERROR_DEBUG(); + // pixel will be drawn only if greater than an alpha threshold + glAlphaFunc(GL_GREATER, _alphaThreshold); +#endif + } + + //Draw _stencil +} + +void StencilStateManager::onAfterDrawStencil() +{ + // restore alpha test state + if (_alphaThreshold < 1) + { +#if CC_CLIPPING_NODE_OPENGLES + // FIXME: we need to find a way to restore the shaders of the stencil node and its children +#else + // manually restore the alpha test state + glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef); + if (!_currentAlphaTestEnabled) + { + glDisable(GL_ALPHA_TEST); + } +#endif + } + + // restore the depth test state + glDepthMask(_currentDepthWriteMask); + RenderState::StateBlock::_defaultState->setDepthWrite(_currentDepthWriteMask != 0); + + //if (currentDepthTestEnabled) { + // glEnable(GL_DEPTH_TEST); + //} + + /////////////////////////////////// + // DRAW CONTENT + + // setup the stencil test function like this: + // for each pixel of this node and its children + // if all layers less than or equals to the current are set to 1 in the stencil buffer + // draw the pixel and keep the current layer in the stencil buffer + // else + // do not draw the pixel but keep the current layer in the stencil buffer + glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); + // RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_EQUAL, _mask_layer_le, _mask_layer_le); + + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + // RenderState::StateBlock::_defaultState->setStencilOperation(RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP); + + // draw (according to the stencil test function) this node and its children + +} + +void StencilStateManager::onAfterVisit() +{ + /////////////////////////////////// + // CLEANUP + + // manually restore the stencil state + glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); + // RenderState::StateBlock::_defaultState->setStencilFunction((RenderState::StencilFunction)_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); + + glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); + // RenderState::StateBlock::_defaultState->setStencilOperation((RenderState::StencilOperation)_currentStencilFail, + // (RenderState::StencilOperation)_currentStencilPassDepthFail, + // (RenderState::StencilOperation)_currentStencilPassDepthPass); + + glStencilMask(_currentStencilWriteMask); + if (!_currentStencilEnabled) + { + glDisable(GL_STENCIL_TEST); + // RenderState::StateBlock::_defaultState->setStencilTest(false); + } + + // we are done using this layer, decrement + s_layer--; +} + + NS_CC_END diff --git a/cocos/base/CCStencilBitsManager.hpp b/cocos/base/CCStencilBitsManager.hpp index b630f83068..be67f58c90 100644 --- a/cocos/base/CCStencilBitsManager.hpp +++ b/cocos/base/CCStencilBitsManager.hpp @@ -34,25 +34,43 @@ */ NS_CC_BEGIN -class CC_DLL StencilBitsManager +class CC_DLL StencilStateManager { public: - static StencilBitsManager* getInstance() - { - if(nullptr == _stencilBitsManager) - { - _stencilBitsManager = new StencilBitsManager(); - } - return _stencilBitsManager; - } - GLint getStencilLayerMask()const; - void setStencilLayerMask(GLint stencilLayer); + StencilStateManager(); + void onBeforeVisit(); + void onAfterDrawStencil(); + void onAfterVisit(); + void setAlphaThreshold(GLfloat alphaThreshold); + void setInverted(bool inverted); + bool isInverted()const; + GLfloat getAlphaThreshold()const; private: - static StencilBitsManager* _stencilBitsManager; - StencilBitsManager(); - StencilBitsManager(const StencilBitsManager& other); - StencilBitsManager& operator=(const StencilBitsManager& other); - GLint _stencilLayerMask; + CC_DISALLOW_COPY_AND_ASSIGN(StencilStateManager); + static GLint s_layer; + /**draw fullscreen quad to clear stencil bits + */ + void drawFullScreenQuadClearStencil(); + + + GLfloat _alphaThreshold; + bool _inverted; + + GLboolean _currentStencilEnabled; + GLuint _currentStencilWriteMask; + GLenum _currentStencilFunc; + GLint _currentStencilRef; + GLuint _currentStencilValueMask; + GLenum _currentStencilFail; + GLenum _currentStencilPassDepthFail; + GLenum _currentStencilPassDepthPass; + GLboolean _currentDepthWriteMask; + + GLboolean _currentAlphaTestEnabled; + GLenum _currentAlphaTestFunc; + GLclampf _currentAlphaTestRef; + + GLint _mask_layer_le; }; NS_CC_END diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index cc6df90d6d..17c441f887 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -74,18 +74,7 @@ _clippingStencil(nullptr), _clippingRect(Rect::ZERO), _clippingParent(nullptr), _clippingRectDirty(true), -_currentStencilEnabled(GL_FALSE), -_currentStencilWriteMask(~0), -_currentStencilFunc(GL_ALWAYS), -_currentStencilRef(0), -_currentStencilValueMask(~0), -_currentStencilFail(GL_KEEP), -_currentStencilPassDepthFail(GL_KEEP), -_currentStencilPassDepthPass(GL_KEEP), -_currentDepthWriteMask(GL_TRUE), -_currentAlphaTestEnabled(GL_FALSE), -_currentAlphaTestFunc(GL_ALWAYS), -_currentAlphaTestRef(1), +_stencileStateManager(new StencilStateManager()), _doLayoutDirty(true), _isInterceptTouch(false), _loopFocus(false), @@ -264,13 +253,13 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4& parentTransfor renderer->pushGroup(_groupCommand.getRenderQueueID()); _beforeVisitCmdStencil.init(_globalZOrder); - _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this); + _beforeVisitCmdStencil.func = CC_CALLBACK_0(StencilStateManager::onBeforeVisit, _stencileStateManager); renderer->addCommand(&_beforeVisitCmdStencil); _clippingStencil->visit(renderer, _modelViewTransform, flags); _afterDrawStencilCmd.init(_globalZOrder); - _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this); + _afterDrawStencilCmd.func = CC_CALLBACK_0(StencilStateManager::onAfterDrawStencil, _stencileStateManager); renderer->addCommand(&_afterDrawStencilCmd); int i = 0; // used by _children @@ -318,7 +307,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4& parentTransfor _afterVisitCmdStencil.init(_globalZOrder); - _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this); + _afterVisitCmdStencil.func = CC_CALLBACK_0(StencilStateManager::onAfterVisit, _stencileStateManager); renderer->addCommand(&_afterVisitCmdStencil); renderer->popGroup(); @@ -326,140 +315,6 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4& parentTransfor director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void Layout::onBeforeVisitStencil() -{ - auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); - s_layer++; - StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); - GLint mask_layer = 0x1 << s_layer; - GLint mask_layer_l = mask_layer - 1; - _mask_layer_le = mask_layer | mask_layer_l; - _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); - glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); - glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); - glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); - glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); - glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); - - glEnable(GL_STENCIL_TEST); -// RenderState::StateBlock::_defaultState->setStencilTest(true); - - CHECK_GL_ERROR_DEBUG(); - glStencilMask(mask_layer); -// RenderState::StateBlock::_defaultState->setStencilWrite(mask_layer); - - glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); - - glDepthMask(GL_FALSE); - RenderState::StateBlock::_defaultState->setDepthWrite(false); - - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP); - - - this->drawFullScreenQuadClearStencil(); - - glStencilFunc(GL_NEVER, mask_layer, mask_layer); -// RenderState::StateBlock::_defaultState->setStencilFunction( -// RenderState::STENCIL_NEVER, -// mask_layer, -// mask_layer); - - glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); -// RenderState::StateBlock::_defaultState->setStencilOperation( -// RenderState::STENCIL_OP_REPLACE, -// RenderState::STENCIL_OP_KEEP, -// RenderState::STENCIL_OP_KEEP); -} - -void Layout::drawFullScreenQuadClearStencil() -{ - Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when setting matrix stack"); - - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - - Vec2 vertices[] = - { - Vec2(-1, -1), - Vec2(1, -1), - Vec2(1, 1), - Vec2(-1, 1) - }; - - auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); - - int colorLocation = glProgram->getUniformLocation("u_color"); - CHECK_GL_ERROR_DEBUG(); - - Color4F color(1, 1, 1, 1); - - glProgram->use(); - glProgram->setUniformsForBuiltins(); - glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1); - - GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); - - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); - - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); -} - -void Layout::onAfterDrawStencil() -{ - glDepthMask(_currentDepthWriteMask); - RenderState::StateBlock::_defaultState->setDepthWrite(_currentDepthWriteMask != 0); - - glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); -// RenderState::StateBlock::_defaultState->setStencilFunction( -// RenderState::STENCIL_EQUAL, -// _mask_layer_le, -// _mask_layer_le); - - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); -// RenderState::StateBlock::_defaultState->setStencilOperation( -// RenderState::STENCIL_OP_KEEP, -// RenderState::STENCIL_OP_KEEP, -// RenderState::STENCIL_OP_KEEP); - -} - - -void Layout::onAfterVisitStencil() -{ - glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); -// RenderState::StateBlock::_defaultState->setStencilFunction( -// (RenderState::StencilFunction)_currentStencilFunc, -// _currentStencilRef, -// _currentStencilValueMask); - - glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); -// RenderState::StateBlock::_defaultState->setStencilOperation( -// (RenderState::StencilOperation)_currentStencilFail, -// (RenderState::StencilOperation)_currentStencilPassDepthFail, -// (RenderState::StencilOperation)_currentStencilPassDepthPass); - - glStencilMask(_currentStencilWriteMask); - if (!_currentStencilEnabled) - { - glDisable(GL_STENCIL_TEST); -// RenderState::StateBlock::_defaultState->setStencilTest(false); - } - auto s_layer = StencilBitsManager::getInstance()->getStencilLayerMask(); - s_layer--; - StencilBitsManager::getInstance()->setStencilLayerMask(s_layer); -} - void Layout::onBeforeVisitScissor() { auto glview = Director::getInstance()->getOpenGLView(); @@ -532,16 +387,6 @@ void Layout::setClippingEnabled(bool able) case ClippingType::STENCIL: if (able) { - static bool once = true; - if (once) - { - glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits); - if (g_sStencilBits <= 0) - { - CCLOG("Stencil buffer is not enabled."); - } - once = false; - } _clippingStencil = DrawNode::create(); if (_running) { diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index f98c37bcdf..5975162ed0 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -39,7 +39,7 @@ NS_CC_BEGIN class DrawNode; class LayerColor; class LayerGradient; - +class StencilStateManager; namespace ui { @@ -486,12 +486,6 @@ protected: virtual const Vector& getLayoutElements()const override; //clipping - void onBeforeVisitStencil(); - void onAfterDrawStencil(); - void onAfterVisitStencil(); - /**draw fullscreen quad to clear stencil bits - */ - void drawFullScreenQuadClearStencil(); void onBeforeVisitScissor(); void onAfterVisitScissor(); @@ -635,23 +629,8 @@ protected: bool _clippingRectDirty; //clipping + StencilStateManager *_stencileStateManager; - GLboolean _currentStencilEnabled; - GLuint _currentStencilWriteMask; - GLenum _currentStencilFunc; - GLint _currentStencilRef; - GLuint _currentStencilValueMask; - GLenum _currentStencilFail; - GLenum _currentStencilPassDepthFail; - GLenum _currentStencilPassDepthPass; - GLboolean _currentDepthWriteMask; - - GLboolean _currentAlphaTestEnabled; - GLenum _currentAlphaTestFunc; - GLclampf _currentAlphaTestRef; - - - GLint _mask_layer_le; GroupCommand _groupCommand; CustomCommand _beforeVisitCmdStencil; CustomCommand _afterDrawStencilCmd; From be2a3077c2c4bbce0942c6b59168f909ccc8596f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 25 Nov 2015 14:15:45 +0800 Subject: [PATCH 126/192] Remove useless manual bindings for addEventListener functions in UI --- .../manual/ui/jsb_cocos2dx_ui_manual.cpp | 450 ------------------ .../js-bindings/script/ccui/jsb_cocos2d_ui.js | 30 ++ tools/bindings-generator | 2 +- tools/tojs/cocos2dx_ui.ini | 2 +- 4 files changed, 32 insertions(+), 452 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp index 82495331fb..2d8ff188b5 100755 --- a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp @@ -29,433 +29,6 @@ using namespace cocos2d; using namespace cocos2d::ui; -class JSStudioEventListenerWrapper: public JSCallbackWrapper { -public: - virtual void eventCallbackFunc(Ref*,int); -}; - -void JSStudioEventListenerWrapper::eventCallbackFunc(Ref* sender,int eventType) -{ - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RootedObject thisObj(cx, getJSCallbackThis().toObjectOrNull()); - JS::RootedValue callback(cx, getJSCallbackFunc()); - js_proxy_t *proxy = js_get_or_create_proxy(cx, sender); - JS::RootedValue retval(cx); - if (!callback.isNullOrUndefined()) - { - jsval touchVal = INT_TO_JSVAL(eventType); - - jsval valArr[2]; - valArr[0] = OBJECT_TO_JSVAL(proxy->obj); - valArr[1] = touchVal; - - JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - JS_CallFunctionValue(cx, thisObj, callback, JS::HandleValueArray::fromMarkedLocation(2, valArr), &retval); - } -} - -class CallbacksComponent: public cocos2d::Component { -public: - CallbacksComponent(); - virtual ~CallbacksComponent(); - - cocos2d::__Dictionary* callbacks; - static const std::string NAME; -}; - -const std::string CallbacksComponent::NAME = "JSB_Callbacks"; - -CallbacksComponent::CallbacksComponent() -{ - setName(NAME); - callbacks = cocos2d::__Dictionary::create(); - CC_SAFE_RETAIN(callbacks); -} - -CallbacksComponent::~CallbacksComponent() -{ - CC_SAFE_RELEASE(callbacks); -} - -static bool 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); - ui::Widget* cobj = (ui::Widget *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); - - if (argc == 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); - tmpObj->autorelease(); - - CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); - if (nullptr == comp) - { - comp = new CallbacksComponent(); - comp->autorelease(); - cobj->addComponent(comp); - } - cocos2d::__Dictionary* dict = comp->callbacks; - dict->setObject(tmpObj, "widgetTouchEvent"); - - tmpObj->setJSCallbackFunc(args.get(0)); - tmpObj->setJSCallbackThis(args.get(1)); - - cobj->addTouchEventListener(tmpObj, toucheventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); - - return true; - } - else if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); - cobj->addTouchEventListener([=](Ref* widget, Widget::TouchEventType type)->void{ - jsval arg[2]; - js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); - if(proxy) - arg[0] = OBJECT_TO_JSVAL(proxy->obj); - else - arg[0] = JSVAL_NULL; - arg[1] = int32_to_jsval(cx, (int32_t)type); - JS::RootedValue rval(cx); - - bool ok = func->invoke(2, arg, &rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }); - return true; - } - JS_ReportError(cx, "Invalid number of arguments"); - return false; -} - -static bool 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); - ui::CheckBox* cobj = (ui::CheckBox *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); - - if (argc == 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); - tmpObj->autorelease(); - - CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); - if (nullptr == comp) - { - comp = new CallbacksComponent(); - comp->autorelease(); - cobj->addComponent(comp); - } - cocos2d::__Dictionary* dict = comp->callbacks; - dict->setObject(tmpObj, "checkBoxEventListener"); - - tmpObj->setJSCallbackFunc(args.get(0)); - tmpObj->setJSCallbackThis(args.get(1)); - - cobj->addEventListenerCheckBox(tmpObj, checkboxselectedeventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); - - return true; - } - else if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); - cobj->addEventListener([=](Ref* widget, CheckBox::EventType type)->void{ - jsval arg[2]; - js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); - if(proxy) - arg[0] = OBJECT_TO_JSVAL(proxy->obj); - else - arg[0] = JSVAL_NULL; - arg[1] = int32_to_jsval(cx, (int32_t)type); - JS::RootedValue rval(cx); - - bool ok = func->invoke(2, arg, &rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }); - return true; - } - JS_ReportError(cx, "Invalid number of arguments"); - return false; -} - -static bool 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); - ui::Slider* cobj = (ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); - - if (argc == 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); - tmpObj->autorelease(); - - CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); - if (nullptr == comp) - { - comp = new CallbacksComponent(); - comp->autorelease(); - cobj->addComponent(comp); - } - cocos2d::__Dictionary* dict = comp->callbacks; - dict->setObject(tmpObj, "sliderEventListener"); - - tmpObj->setJSCallbackFunc(args.get(0)); - tmpObj->setJSCallbackThis(args.get(1)); - - cobj->addEventListenerSlider(tmpObj, sliderpercentchangedselector(JSStudioEventListenerWrapper::eventCallbackFunc)); - - return true; - } - else if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); - cobj->addEventListener([=](Ref* widget, Slider::EventType type)->void{ - jsval arg[2]; - js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); - if(proxy) - arg[0] = OBJECT_TO_JSVAL(proxy->obj); - else - arg[0] = JSVAL_NULL; - arg[1] = int32_to_jsval(cx, (int32_t)type); - JS::RootedValue rval(cx); - - bool ok = func->invoke(2, arg, &rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }); - return true; - } - JS_ReportError(cx, "Invalid number of arguments"); - return false; -} - -static bool 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); - ui::TextField* cobj = (ui::TextField *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); - - if (argc == 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); - tmpObj->autorelease(); - - CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); - if (nullptr == comp) - { - comp = new CallbacksComponent(); - comp->autorelease(); - cobj->addComponent(comp); - } - cocos2d::__Dictionary* dict = comp->callbacks; - dict->setObject(tmpObj, "textfieldEventListener"); - - tmpObj->setJSCallbackFunc(args.get(0)); - tmpObj->setJSCallbackThis(args.get(1)); - - cobj->addEventListenerTextField(tmpObj, textfieldeventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); - - return true; - } - else if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); - cobj->addEventListener([=](Ref* widget, TextField::EventType type)->void{ - jsval arg[2]; - js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); - if(proxy) - arg[0] = OBJECT_TO_JSVAL(proxy->obj); - else - arg[0] = JSVAL_NULL; - arg[1] = int32_to_jsval(cx, (int32_t)type); - JS::RootedValue rval(cx); - - bool ok = func->invoke(2, arg, &rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }); - return true; - } - JS_ReportError(cx, "Invalid number of arguments"); - return false; -} - -static bool 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); - ui::PageView* cobj = (ui::PageView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); - - if (argc == 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); - tmpObj->autorelease(); - - CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); - if (nullptr == comp) - { - comp = new CallbacksComponent(); - comp->autorelease(); - cobj->addComponent(comp); - } - cocos2d::__Dictionary* dict = comp->callbacks; - dict->setObject(tmpObj, "pageViewEventListener"); - - tmpObj->setJSCallbackFunc(args.get(0)); - tmpObj->setJSCallbackThis(args.get(1)); - - cobj->addEventListenerPageView(tmpObj, pagevieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); - - return true; - } - else if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); - cobj->addEventListener([=](Ref* widget, PageView::EventType type)->void{ - jsval arg[2]; - js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); - if(proxy) - arg[0] = OBJECT_TO_JSVAL(proxy->obj); - else - arg[0] = JSVAL_NULL; - arg[1] = int32_to_jsval(cx, (int32_t)type); - JS::RootedValue rval(cx); - - bool ok = func->invoke(2, arg, &rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }); - return true; - } - JS_ReportError(cx, "Invalid number of arguments"); - return false; -} - -static bool js_cocos2dx_UIScrollView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - ui::ScrollView* cobj = (ui::ScrollView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); - - if (argc == 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); - tmpObj->autorelease(); - - CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); - if (nullptr == comp) - { - comp = new CallbacksComponent(); - comp->autorelease(); - cobj->addComponent(comp); - } - cocos2d::__Dictionary* dict = comp->callbacks; - dict->setObject(tmpObj, "scrollViewEventListener"); - - tmpObj->setJSCallbackFunc(args.get(0)); - tmpObj->setJSCallbackThis(args.get(1)); - - cobj->addEventListenerScrollView(tmpObj, scrollvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); - - return true; - }else if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); - cobj->addEventListener([=](Ref* widget, ScrollView::EventType type)->void{ - jsval arg[2]; - js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); - if(proxy) - arg[0] = OBJECT_TO_JSVAL(proxy->obj); - else - arg[0] = JSVAL_NULL; - arg[1] = int32_to_jsval(cx, (int32_t)type); - JS::RootedValue rval(cx); - - bool ok = func->invoke(2, arg, &rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }); - return true; - } - JS_ReportError(cx, "Invalid number of arguments"); - return false; -} - -static bool 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); - ui::ListView* cobj = (ui::ListView *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); - - if (argc == 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); - tmpObj->autorelease(); - - CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); - if (nullptr == comp) - { - comp = new CallbacksComponent(); - comp->autorelease(); - cobj->addComponent(comp); - } - cocos2d::__Dictionary* dict = comp->callbacks; - dict->setObject(tmpObj, "listViewEventListener"); - - tmpObj->setJSCallbackFunc(args.get(0)); - tmpObj->setJSCallbackThis(args.get(1)); - - cobj->addEventListenerListView(tmpObj, listvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); - - return true; - } - else if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); - auto lambda = [=](Ref* widget, ListView::EventType type)->void{ - jsval arg[2]; - js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); - if(proxy) - arg[0] = OBJECT_TO_JSVAL(proxy->obj); - else - arg[0] = JSVAL_NULL; - arg[1] = int32_to_jsval(cx, (int32_t)type); - JS::RootedValue rval(cx); - - bool ok = func->invoke(2, arg, &rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - cocos2d::ui::ListView::ccListViewCallback cb = lambda; - cobj->addEventListener(cb); - return true; - } - JS_ReportError(cx, "Invalid number of arguments"); - return false; -} - static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -639,35 +212,12 @@ static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsva return false; } -extern JSObject* jsb_cocos2d_ui_Widget_prototype; -extern JSObject* jsb_cocos2d_ui_CheckBox_prototype; -extern JSObject* jsb_cocos2d_ui_Slider_prototype; -extern JSObject* jsb_cocos2d_ui_TextField_prototype; extern JSObject* jsb_cocos2d_ui_LayoutParameter_prototype; -extern JSObject* jsb_cocos2d_ui_PageView_prototype; -extern JSObject* jsb_cocos2d_ui_ScrollView_prototype; -extern JSObject* jsb_cocos2d_ui_ListView_prototype; extern JSObject* jsb_cocos2d_ui_EditBox_prototype; void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global) { - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), "addTouchEventListener", js_cocos2dx_UIWidget_addTouchEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_CheckBox_prototype), "addEventListener", js_cocos2dx_UICheckBox_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_Slider_prototype), "addEventListener", js_cocos2dx_UISlider_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_TextField_prototype), "addEventListener", js_cocos2dx_UITextField_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_PageView_prototype), "addEventListener", js_cocos2dx_UIPageView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_ScrollView_prototype), "addEventListener", js_cocos2dx_UIScrollView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_ListView_prototype), "addEventListener", js_cocos2dx_UIListView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_EditBox_prototype), "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); } diff --git a/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js b/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js index 4842c14cdb..3e88a1419b 100644 --- a/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js +++ b/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js @@ -507,3 +507,33 @@ if (ccui.VideoPlayer) ccui.Widget.prototype.addNode = ccui.Widget.prototype.addChild; ccui.Widget.prototype.getSize = ccui.Widget.prototype.getContentSize; ccui.Widget.prototype.setSize = ccui.Widget.prototype.setContentSize; + +/* + * UIWidget's event listeners wrapper + */ +ccui.Widget.prototype._addTouchEventListener = ccui.Widget.prototype.addTouchEventListener; +ccui.Widget.prototype.addTouchEventListener = function (selector, target) { + if (target === undefined) + this._addTouchEventListener(selector); + else + this._addTouchEventListener(selector.bind(target)); +}; + +function _ui_addEventListener(selector, target) { + if (target === undefined) + this._addTouchEventListener(selector); + else + this._addTouchEventListener(selector.bind(target)); +} +function _ui_applyEventListener(ctor) { + var proto = ctor.prototype; + proto._addEventListener = proto.addEventListener; + proto.addEventListener = _ui_addEventListener; +} + +_ui_applyEventListener(ccui.CheckBox); +_ui_applyEventListener(ccui.Slider); +_ui_applyEventListener(ccui.TextField); +_ui_applyEventListener(ccui.PageView); +_ui_applyEventListener(ccui.ScrollView); +_ui_applyEventListener(ccui.ListView); diff --git a/tools/bindings-generator b/tools/bindings-generator index 2318a1593d..4ecd2f4536 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 2318a1593d2d490a3860179acaf81a1bf867a36b +Subproject commit 4ecd2f4536bd57d42b4b370a6a4fc7c7420f5404 diff --git a/tools/tojs/cocos2dx_ui.ini b/tools/tojs/cocos2dx_ui.ini index 2b7a69bc6e..7fbfc2b67d 100644 --- a/tools/tojs/cocos2dx_ui.ini +++ b/tools/tojs/cocos2dx_ui.ini @@ -41,7 +41,7 @@ classes_need_extend = Layout Widget Button CheckBox ImageView Text TextAtlas Tex # 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 ccTouch.* addEventListener addTouchEventListener], +skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener ccTouch.*], Widget::[(s|g)etUserObject], Layer::[getInputManager], LayoutParameter::[(s|g)etMargin], From 759c0bbf31b49b3ab54be22aed44461b5ca5a850 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 25 Nov 2015 14:24:27 +0800 Subject: [PATCH 127/192] rename CCStencilBitsManager to StencilStateManager --- build/cocos2d_libs.xcodeproj/project.pbxproj | 28 +++++++++---------- cocos/2d/CCClippingNode.cpp | 2 +- cocos/2d/libcocos2d.vcxproj | 4 +-- cocos/2d/libcocos2d.vcxproj.filters | 4 +-- .../libcocos2d_8_1.Shared.vcxitems | 4 +-- .../libcocos2d_8_1.Shared.vcxitems.filters | 4 +-- cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 4 +-- .../libcocos2d.vcxproj.filters | 4 +-- cocos/Android.mk | 2 +- ...sManager.cpp => CCStencilStateManager.cpp} | 2 +- ...sManager.hpp => CCStencilStateManager.hpp} | 6 ++-- cocos/base/CMakeLists.txt | 2 +- cocos/ui/UILayout.cpp | 4 +-- 13 files changed, 34 insertions(+), 36 deletions(-) rename cocos/base/{CCStencilBitsManager.cpp => CCStencilStateManager.cpp} (99%) rename cocos/base/{CCStencilBitsManager.hpp => CCStencilStateManager.hpp} (96%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 7357b4b972..027713d954 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1234,11 +1234,11 @@ 2980F02B1BA9A5550059E678 /* UITextView+CCUITextInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 2980F0201BA9A5550059E678 /* UITextView+CCUITextInput.h */; }; 2980F02C1BA9A5550059E678 /* UITextView+CCUITextInput.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */; }; 2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; }; - 298C75D51C0465D0006BAE63 /* CCStencilBitsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */; }; - 298C75D61C0465D1006BAE63 /* CCStencilBitsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */; }; - 298C75D71C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */; }; - 298C75D81C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */; }; - 298C75D91C04681F006BAE63 /* CCStencilBitsManager.hpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */; }; + 298C75D51C0465D0006BAE63 /* CCStencilStateManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */; }; + 298C75D61C0465D1006BAE63 /* CCStencilStateManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */; }; + 298C75D71C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */; }; + 298C75D81C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */; }; + 298C75D91C04681F006BAE63 /* CCStencilStateManager.hpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */; }; 299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; 299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; @@ -4149,8 +4149,8 @@ 2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UITextView+CCUITextInput.mm"; sourceTree = ""; }; 2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = ""; }; 2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = ""; }; - 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCStencilBitsManager.cpp; path = ../base/CCStencilBitsManager.cpp; sourceTree = ""; }; - 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CCStencilBitsManager.hpp; path = ../base/CCStencilBitsManager.hpp; sourceTree = ""; }; + 298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCStencilStateManager.cpp; path = ../base/CCStencilStateManager.cpp; sourceTree = ""; }; + 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CCStencilStateManager.hpp; path = ../base/CCStencilStateManager.hpp; sourceTree = ""; }; 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = ""; }; 299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = ""; }; 299CF1F919A434BC00C378C1 /* ccRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ccRandom.cpp; path = ../base/ccRandom.cpp; sourceTree = ""; }; @@ -6044,8 +6044,8 @@ 50ABBE1C1925AB6F00A911A9 /* utlist.h */, 50ABBE1D1925AB6F00A911A9 /* ZipUtils.cpp */, 50ABBE1E1925AB6F00A911A9 /* ZipUtils.h */, - 298C75D31C0465D0006BAE63 /* CCStencilBitsManager.cpp */, - 298C75D41C0465D0006BAE63 /* CCStencilBitsManager.hpp */, + 298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */, + 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */, ); name = base; path = ../cocos/2d; @@ -9238,7 +9238,7 @@ 15AE182A19AAD2F700C27E9E /* CCMeshSkin.h in Headers */, B276EF5F1988D1D500CD400F /* CCVertexIndexData.h in Headers */, 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, - 298C75D71C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */, + 298C75D71C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */, B6DD2FDB1B04825B00E47F5F /* DetourLocalBoundary.h in Headers */, B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */, B677B0DB1B18492D006762CB /* CCNavMeshUtils.h in Headers */, @@ -10679,7 +10679,7 @@ 85505F051B60E3B2003F2CD4 /* CCBoneNode.h in Headers */, B665E2491AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffectorTranslator.h in Headers */, B6CAB4461AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */, - 298C75D81C0465D1006BAE63 /* CCStencilBitsManager.hpp in Headers */, + 298C75D81C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */, 15AE18D119AAD33D00C27E9E /* CCNodeLoaderLibrary.h in Headers */, 15AE1AC319AAD40300C27E9E /* b2DistanceJoint.h in Headers */, B6CAB5261AF9AA1A00B9B856 /* btQuickprof.h in Headers */, @@ -11841,7 +11841,7 @@ B665E2EE1AA80A6500DDB1C5 /* CCPULineEmitter.cpp in Sources */, B6CAB2DD1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */, B665E4121AA80A6600DDB1C5 /* CCPUTextureAnimator.cpp in Sources */, - 298C75D51C0465D0006BAE63 /* CCStencilBitsManager.cpp in Sources */, + 298C75D51C0465D0006BAE63 /* CCStencilStateManager.cpp in Sources */, B665E3D21AA80A6600DDB1C5 /* CCPUScriptLexer.cpp in Sources */, B665E4021AA80A6600DDB1C5 /* CCPUSphereColliderTranslator.cpp in Sources */, 15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */, @@ -11976,7 +11976,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 298C75D91C04681F006BAE63 /* CCStencilBitsManager.hpp in Sources */, + 298C75D91C04681F006BAE63 /* CCStencilStateManager.hpp in Sources */, D0FD03541A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */, 15AE1B9819AADAA100C27E9E /* UIVideoPlayer-ios.mm in Sources */, B665E38F1AA80A6500DDB1C5 /* CCPUPlaneCollider.cpp in Sources */, @@ -12127,7 +12127,7 @@ 15AE193C19AAD35100C27E9E /* CCArmatureDefine.cpp in Sources */, B665E35F1AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.cpp in Sources */, B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */, - 298C75D61C0465D1006BAE63 /* CCStencilBitsManager.cpp in Sources */, + 298C75D61C0465D1006BAE63 /* CCStencilStateManager.cpp in Sources */, 15AE194B19AAD35100C27E9E /* CCComRender.cpp in Sources */, 382384451A25915C002C4610 /* SpriteReader.cpp in Sources */, B6CAB2321AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */, diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index e2490e14fd..1e6ccdcf01 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -32,7 +32,7 @@ #include "renderer/CCRenderer.h" #include "renderer/CCRenderState.h" #include "base/CCDirector.h" -#include "base/CCStencilBitsManager.hpp" +#include "base/CCStencilStateManager.hpp" #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) #define CC_CLIPPING_NODE_OPENGLES 0 diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 8752d8ba2f..16ff56024b 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -433,7 +433,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + @@ -1016,7 +1016,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 01067a13cf..b1e6cf118f 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1896,7 +1896,7 @@ base - + base @@ -3731,7 +3731,7 @@ base - + base diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 3ca9b6814f..31c39d506c 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -286,7 +286,7 @@ - + @@ -918,7 +918,7 @@ - + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 5cd31d8512..b82b2259d5 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1812,7 +1812,7 @@ base - + base @@ -3528,7 +3528,7 @@ base - + base diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index cd02a95bd9..43532a8b82 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -415,7 +415,7 @@ - + @@ -1014,7 +1014,7 @@ - + diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters index 67d153e5e9..4bfeeae4aa 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters @@ -1767,7 +1767,7 @@ base - + base @@ -3638,7 +3638,7 @@ base - + base diff --git a/cocos/Android.mk b/cocos/Android.mk index a6f789ce7b..70afa67aa7 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -107,7 +107,7 @@ math/Vec2.cpp \ math/Vec3.cpp \ math/Vec4.cpp \ base/CCNinePatchImageParser.cpp \ -base/CCStencilBitsManager.cpp \ +base/CCStencilStateManager.cpp \ base/CCAsyncTaskPool.cpp \ base/CCAutoreleasePool.cpp \ base/CCConfiguration.cpp \ diff --git a/cocos/base/CCStencilBitsManager.cpp b/cocos/base/CCStencilStateManager.cpp similarity index 99% rename from cocos/base/CCStencilBitsManager.cpp rename to cocos/base/CCStencilStateManager.cpp index e1c6835f50..3467b12c97 100644 --- a/cocos/base/CCStencilBitsManager.cpp +++ b/cocos/base/CCStencilStateManager.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "CCStencilBitsManager.hpp" +#include "CCStencilStateManager.hpp" #include "base/CCDirector.h" #include "renderer/CCGLProgramCache.h" #include "renderer/ccGLStateCache.h" diff --git a/cocos/base/CCStencilBitsManager.hpp b/cocos/base/CCStencilStateManager.hpp similarity index 96% rename from cocos/base/CCStencilBitsManager.hpp rename to cocos/base/CCStencilStateManager.hpp index be67f58c90..82e0c2ee0f 100644 --- a/cocos/base/CCStencilBitsManager.hpp +++ b/cocos/base/CCStencilStateManager.hpp @@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef StencilBitsManager_hpp -#define StencilBitsManager_hpp +#ifndef StencilStateManager_hpp +#define StencilStateManager_hpp #include "base/ccConfig.h" #include "platform/CCPlatformMacros.h" #include "platform/CCGL.h" @@ -76,4 +76,4 @@ private: NS_CC_END // end of base group /** @} */ -#endif /* StencilBitsManager_hpp */ +#endif /* StencilStateManager_hpp */ diff --git a/cocos/base/CMakeLists.txt b/cocos/base/CMakeLists.txt index 7f18a43b18..8e2881e7cc 100644 --- a/cocos/base/CMakeLists.txt +++ b/cocos/base/CMakeLists.txt @@ -45,7 +45,7 @@ set(COCOS_BASE_SRC base/CCUserDefault.cpp base/CCValue.cpp base/ObjectFactory.cpp - base/CCStencilBitsManager.cpp + base/CCStencilStateManager.cpp base/TGAlib.cpp base/ZipUtils.cpp base/allocator/CCAllocatorDiagnostics.cpp diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 17c441f887..f5b15bfad2 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -37,7 +37,7 @@ THE SOFTWARE. #include "2d/CCLayer.h" #include "2d/CCSprite.h" #include "base/CCEventFocus.h" -#include "base/CCStencilBitsManager.hpp" +#include "base/CCStencilStateManager.hpp" NS_CC_BEGIN @@ -45,8 +45,6 @@ namespace ui { static const int BACKGROUNDIMAGE_Z = (-1); static const int BCAKGROUNDCOLORRENDERER_Z = (-2); - -static GLint g_sStencilBits = -1; IMPLEMENT_CLASS_GUI_INFO(Layout) From 03046d6fbd9b9616d515e831bbd7a919b697c5a1 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 25 Nov 2015 14:31:32 +0800 Subject: [PATCH 128/192] change the default alphaThreshold --- cocos/2d/CCClippingNode.cpp | 4 ---- cocos/base/CCStencilStateManager.cpp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 1e6ccdcf01..ea80510b7b 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -109,10 +109,6 @@ bool ClippingNode::init(Node *stencil) CC_SAFE_RELEASE(_stencil); _stencil = stencil; CC_SAFE_RETAIN(_stencil); - - _stencilStateManager->setAlphaThreshold(1.0f); - _stencilStateManager->setInverted(false); - return true; } diff --git a/cocos/base/CCStencilStateManager.cpp b/cocos/base/CCStencilStateManager.cpp index 3467b12c97..0525054780 100644 --- a/cocos/base/CCStencilStateManager.cpp +++ b/cocos/base/CCStencilStateManager.cpp @@ -41,7 +41,7 @@ GLint StencilStateManager::s_layer = -1; static GLint g_sStencilBits = -1; StencilStateManager::StencilStateManager() -: _alphaThreshold(0.0f) +: _alphaThreshold(1.0f) , _inverted(false) , _currentStencilEnabled(GL_FALSE) , _currentStencilWriteMask(~0) From 69b2b5720b76dc0e6c7e49da348d3cb322aaba53 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 25 Nov 2015 14:32:19 +0800 Subject: [PATCH 129/192] Use JS::PersistentRooted instead of JS::Heap to prevent delegates and wrappers internal js object from GC More elegant and secured way, potential crashes exists in previous implementation --- .../manual/3d/jsb_cocos2dx_3d_manual.cpp | 17 +- .../js-bindings/manual/cocos2d_specifics.cpp | 7 +- .../js-bindings/manual/cocos2d_specifics.hpp | 6 +- .../jsb_cocos2dx_extension_manual.cpp | 156 +++++++----------- .../manual/js_manual_conversions.cpp | 14 +- .../manual/js_manual_conversions.h | 7 +- .../manual/network/XMLHTTPRequest.cpp | 65 ++++---- .../manual/network/XMLHTTPRequest.h | 18 +- .../manual/network/jsb_socketio.cpp | 20 ++- .../manual/network/jsb_websocket.cpp | 25 ++- .../jsb_cocos2dx_physics3d_manual.cpp | 2 +- .../manual/ui/jsb_cocos2dx_ui_manual.cpp | 42 ++--- 12 files changed, 166 insertions(+), 213 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp index 87e22e3f36..23375d23e8 100644 --- a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp @@ -32,20 +32,22 @@ using namespace cocos2d; class JSB_HeapValueWrapper{ public: - JSB_HeapValueWrapper(JSContext* cx, JS::HandleValue value):_cx(cx), _data(value){ - JS::AddValueRoot(_cx, &_data); + JSB_HeapValueWrapper(JSContext* cx, JS::HandleValue value) + :_cx(cx) + { + _data.construct(cx, value); } ~JSB_HeapValueWrapper(){ - JS::RemoveValueRoot(_cx, &_data); + _data.destroyIfConstructed(); } - JS::Value get(){ - return _data.get(); + JS::HandleValue get(){ + return _data.ref(); } private: JSContext* _cx; - JS::Heap _data; + mozilla::Maybe _data; }; static bool js_cocos2dx_Sprite3D_createAsync(JSContext *cx, uint32_t argc, jsval *vp) @@ -57,7 +59,8 @@ static bool js_cocos2dx_Sprite3D_createAsync(JSContext *cx, uint32_t argc, jsval jsval_to_std_string(cx, args.get(0), &modelPath); std::function callback; - std::shared_ptr func(new JSFunctionWrapper(cx, args.get(argc == 4 ? 2 : 3).toObjectOrNull(), args.get(argc == 4 ? 1 : 2))); + JS::RootedObject cb(cx, args.get(argc == 4 ? 2 : 3).toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, cb, args.get(argc == 4 ? 1 : 2))); auto lambda = [=](Sprite3D* larg0, void* larg1) -> void{ jsval largv[2]; diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index fcb1682745..11ce8a0368 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -37,8 +37,7 @@ schedTarget_proxy_t *_schedObj_target_ht = NULL; JSTouchDelegate::TouchDelegateMap JSTouchDelegate::sTouchDelegateMap; JSTouchDelegate::JSTouchDelegate() -: _needUnroot(false) -, _touchListenerAllAtOnce(nullptr) +: _touchListenerAllAtOnce(nullptr) , _touchListenerOneByOne(nullptr) { auto cx = ScriptingCore::getInstance()->getGlobalContext(); @@ -4837,7 +4836,7 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); std::function &)> arg3; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), args.get(3))); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(3))); auto lambda = [=](cocos2d::RenderTexture* larg0, const std::string& larg1) -> void { jsval largv[2]; do { @@ -4906,7 +4905,7 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1))); std::function &)> arg2; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), args.get(2))); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(2))); auto lambda = [=](cocos2d::RenderTexture* larg0, const std::string& larg1) -> void { jsval largv[2]; do { diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp index 3c28b5c1a6..8bd306404d 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp @@ -33,13 +33,13 @@ class JSScheduleWrapper; // To debug this, you could refer to JSScheduleWrapper::dump function. // It will prove that i'm right. :) typedef struct jsScheduleFunc_proxy { - JS::Heap jsfuncObj; + JSObject* jsfuncObj; cocos2d::__Array* targets; UT_hash_handle hh; } schedFunc_proxy_t; typedef struct jsScheduleTarget_proxy { - JS::Heap jsTargetObj; + JSObject* jsTargetObj; cocos2d::__Array* targets; UT_hash_handle hh; } schedTarget_proxy_t; @@ -221,7 +221,6 @@ private: typedef std::unordered_map TouchDelegateMap; typedef std::pair TouchDelegatePair; static TouchDelegateMap sTouchDelegateMap; - bool _needUnroot; cocos2d::EventListenerTouchOneByOne* _touchListenerOneByOne; cocos2d::EventListenerTouchAllAtOnce* _touchListenerAllAtOnce; }; @@ -252,7 +251,6 @@ public: private: cocos2d::SAXParser _parser; - JS::Heap _obj; std::string _result; bool _isStoringCharacters; std::string _currentValue; diff --git a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp index b44f1ad40e..3b2df42968 100644 --- a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp @@ -38,17 +38,14 @@ class JSB_ScrollViewDelegate { public: JSB_ScrollViewDelegate() - : _JSDelegate(NULL) - , _needUnroot(false) - {} + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _JSDelegate.construct(cx); + } virtual ~JSB_ScrollViewDelegate() { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RemoveObjectRoot(cx, &_JSDelegate); - } + _JSDelegate.destroyIfConstructed(); } virtual void scrollViewDidScroll(ScrollView* view) override @@ -57,7 +54,7 @@ public: if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidScroll", 1, &arg); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "scrollViewDidScroll", 1, &arg); } virtual void scrollViewDidZoom(ScrollView* view) override @@ -66,31 +63,21 @@ public: if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidZoom", 1, &arg); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "scrollViewDidZoom", 1, &arg); } - void setJSDelegate(JSObject* pJSDelegate) + void setJSDelegate(JS::HandleObject pJSDelegate) { - _JSDelegate = pJSDelegate; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); - } + _JSDelegate.ref() = pJSDelegate; } private: - JS::Heap _JSDelegate; - bool _needUnroot; + mozilla::Maybe _JSDelegate; }; static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -98,7 +85,7 @@ static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, j if (argc == 1) { // save the delegate - JSObject *jsDelegate = args.get(0).toObjectOrNull(); + JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull()); JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); nativeDelegate->setJSDelegate(jsDelegate); @@ -124,17 +111,14 @@ class JSB_TableViewDelegate { public: JSB_TableViewDelegate() - : _JSDelegate(NULL) - , _needUnroot(false) - {} + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _JSDelegate.construct(cx); + } virtual ~JSB_TableViewDelegate() { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RemoveObjectRoot(cx, &_JSDelegate); - } + _JSDelegate.destroyIfConstructed(); } virtual void scrollViewDidScroll(ScrollView* view) override @@ -167,21 +151,11 @@ public: callJSDelegate(table, cell, "tableCellWillRecycle"); } - void setJSDelegate(JSObject* pJSDelegate) + void setJSDelegate(JS::HandleObject pJSDelegate) { - _JSDelegate = pJSDelegate; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); - } + _JSDelegate.ref() = pJSDelegate; } - private: void callJSDelegate(ScrollView* view, std::string jsFunctionName) { @@ -189,7 +163,7 @@ private: if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 1, &arg); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), jsFunctionName.c_str(), 1, &arg); } void callJSDelegate(TableView* table, TableViewCell* cell, std::string jsFunctionName) @@ -204,17 +178,16 @@ private: args[0] = OBJECT_TO_JSVAL(p->obj); args[1] = OBJECT_TO_JSVAL(pCellProxy->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 2, args); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), jsFunctionName.c_str(), 2, args); } - JS::Heap _JSDelegate; - bool _needUnroot; + mozilla::Maybe _JSDelegate; }; static bool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -222,7 +195,7 @@ static bool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, js if (argc == 1) { // save the delegate - JSObject *jsDelegate = args.get(0).toObjectOrNull(); + JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull()); JSB_TableViewDelegate* nativeDelegate = new JSB_TableViewDelegate(); nativeDelegate->setJSDelegate(jsDelegate); @@ -253,17 +226,14 @@ class JSB_TableViewDataSource { public: JSB_TableViewDataSource() - : _JSTableViewDataSource(NULL) - , _needUnroot(false) - {} + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _JSTableViewDataSource.construct(cx); + } virtual ~JSB_TableViewDataSource() { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RemoveObjectRoot(cx, &_JSTableViewDataSource); - } + _JSTableViewDataSource.destroyIfConstructed(); } virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override @@ -321,19 +291,9 @@ public: return 0; } - - void setTableViewDataSource(JSObject* pJSSource) + void setTableViewDataSource(JS::HandleObject pJSSource) { - _JSTableViewDataSource = pJSSource; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSTableViewDataSource); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::AddNamedObjectRoot(cx, &_JSTableViewDataSource, "TableViewDataSource"); - } + _JSTableViewDataSource.ref() = pJSSource; } private: @@ -348,7 +308,7 @@ private: JS::RootedValue temp_retval(cx); jsval dataVal = OBJECT_TO_JSVAL(p->obj); - JS::RootedObject obj(cx, _JSTableViewDataSource); + JS::RootedObject obj(cx, _JSTableViewDataSource.ref()); JSAutoCompartment ac(cx, obj); if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) @@ -381,7 +341,7 @@ private: dataVal[0] = OBJECT_TO_JSVAL(p->obj); dataVal[1] = ssize_to_jsval(cx,idx); - JS::RootedObject obj(cx, _JSTableViewDataSource); + JS::RootedObject obj(cx, _JSTableViewDataSource.ref()); JSAutoCompartment ac(cx, obj); if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) @@ -404,21 +364,20 @@ private: } private: - JS::Heap _JSTableViewDataSource; - bool _needUnroot; + mozilla::Maybe _JSTableViewDataSource; }; static bool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 1) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(args.get(0).toObjectOrNull()); + pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull())); __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); if (NULL == userDict) @@ -450,7 +409,7 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval * { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(args.get(0).toObjectOrNull()); + pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull())); cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, args.get(1), &arg1); @@ -511,7 +470,7 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval * static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_dequeueCell : Invalid Native Object"); @@ -520,7 +479,7 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(args.get(0).toObjectOrNull()); + pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull())); cobj->setDataSource(pNativeSource); cocos2d::Size arg1; @@ -567,14 +526,17 @@ class JSB_ControlButtonTarget : public Ref public: JSB_ControlButtonTarget() : _callback(nullptr), - _jsFunc(nullptr), - _type(Control::EventType::TOUCH_DOWN), - _needUnroot(false) - {} + _type(Control::EventType::TOUCH_DOWN) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _jsFunc.construct(cx); + } virtual ~JSB_ControlButtonTarget() { CCLOGINFO("In the destruction of JSB_ControlButtonTarget ..."); + _jsFunc.destroyIfConstructed(); + if (_callback != nullptr) { CC_SAFE_DELETE(_callback); @@ -611,7 +573,7 @@ public: _callback->invoke(2, dataVal, &jsRet); } - void setJSCallback(jsval jsFunc, JSObject* jsTarget) + void setJSCallback(JS::HandleValue jsFunc, JS::HandleObject jsTarget) { if (_callback != nullptr) { @@ -619,7 +581,7 @@ public: } JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); _callback = new JSFunctionWrapper(cx, jsTarget, jsFunc); - _jsFunc = jsFunc.toObjectOrNull(); + _jsFunc.ref() = jsFunc.toObjectOrNull(); } void setEventType(Control::EventType type) @@ -631,9 +593,7 @@ public: static std::multimap _jsNativeTargetMap; JSFunctionWrapper *_callback; Control::EventType _type; - JSObject *_jsFunc; -private: - bool _needUnroot; + mozilla::Maybe _jsFunc; }; std::multimap JSB_ControlButtonTarget::_jsNativeTargetMap; @@ -641,7 +601,7 @@ std::multimap JSB_ControlButtonTarget::_jsN static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -659,7 +619,7 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(jsDelegate); for (auto it = range.first; it != range.second; ++it) { - if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) + if (it->second->_jsFunc.ref().get() == jsFunc && arg2 == it->second->_type) { // Return true directly. args.rval().setUndefined(); @@ -670,7 +630,7 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext // save the delegate JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget(); - nativeDelegate->setJSCallback(args.get(1), jsDelegate); + nativeDelegate->setJSCallback(args.get(1), JS::RootedObject(cx, jsDelegate)); nativeDelegate->setEventType(arg2); __Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject()); @@ -700,7 +660,7 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext static bool js_cocos2dx_CCControl_removeTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -720,7 +680,7 @@ static bool js_cocos2dx_CCControl_removeTargetWithActionForControlEvents(JSConte auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(obj); for (auto it = range.first; it != range.second; ++it) { - if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) + if (it->second->_jsFunc.ref().get() == jsFunc && arg2 == it->second->_type) { nativeTargetToRemoved = it->second; JSB_ControlButtonTarget::_jsNativeTargetMap.erase(it); @@ -868,10 +828,8 @@ __JSDownloaderDelegator::__JSDownloaderDelegator(JSContext *cx, JS::HandleObject : _cx(cx) , _url(url) { - _obj.construct(_cx); - _obj.ref().set(obj); - _jsCallback.construct(_cx); - _jsCallback.ref().set(callback); + _obj.construct(_cx, obj); + _jsCallback.construct(_cx, callback); } __JSDownloaderDelegator::~__JSDownloaderDelegator() @@ -1007,7 +965,7 @@ void __JSDownloaderDelegator::onSuccess(Texture2D *tex) bool js_load_remote_image(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); if (argc == 2) { std::string url; diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index 24097f76b9..a2645181c1 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -90,26 +90,24 @@ const char* JSStringWrapper::get() } // JSFunctionWrapper -JSFunctionWrapper::JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval) +JSFunctionWrapper::JSFunctionWrapper(JSContext* cx, JS::HandleObject jsthis, JS::HandleValue fval) : _cx(cx) -, _jsthis(jsthis) -, _fval(fval) { - JS::AddNamedValueRoot(cx, &this->_fval, "JSFunctionWrapper"); - JS::AddNamedObjectRoot(cx, &this->_jsthis, "JSFunctionWrapper"); + _jsthis.construct(cx, jsthis); + _fval.construct(cx, fval); } JSFunctionWrapper::~JSFunctionWrapper() { - JS::RemoveValueRoot(this->_cx, &this->_fval); - JS::RemoveObjectRoot(this->_cx, &this->_jsthis); + _jsthis.destroyIfConstructed(); + _fval.destroyIfConstructed(); } bool JSFunctionWrapper::invoke(unsigned int argc, jsval *argv, JS::MutableHandleValue rval) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - return JS_CallFunctionValue(this->_cx, JS::RootedObject(_cx, this->_jsthis.get()), JS::RootedValue(_cx, this->_fval.get()), JS::HandleValueArray::fromMarkedLocation(argc, argv), rval); + return JS_CallFunctionValue(this->_cx, _jsthis.ref(), _fval.ref(), JS::HandleValueArray::fromMarkedLocation(argc, argv), rval); } static Color3B getColorFromJSObject(JSContext *cx, JS::HandleObject colorObject) diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index ae99be38f3..646348ff85 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -31,6 +31,7 @@ #include "js_bindings_config.h" #include "cocos2d.h" #include "spidermonkey_specifics.h" +#include "mozilla/Maybe.h" #define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES @@ -58,14 +59,14 @@ private: class JSFunctionWrapper { public: - JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval); + JSFunctionWrapper(JSContext* cx, JS::HandleObject jsthis, JS::HandleValue fval); ~JSFunctionWrapper(); bool invoke(unsigned int argc, jsval *argv, JS::MutableHandleValue rval); private: JSContext *_cx; - JS::Heap _jsthis; - JS::Heap _fval; + mozilla::Maybe _jsthis; + mozilla::Maybe _fval; private: CC_DISALLOW_COPY_AND_ASSIGN(JSFunctionWrapper); }; diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp index 402a318874..29008bffe7 100644 --- a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp @@ -215,8 +215,8 @@ void MinXmlHttpRequest::handle_requestResponse(cocos2d::network::HttpClient *sen _errorFlag = true; _status = 0; _statusText.clear(); - _notify(_onerrorCallback); - _notify(_onloadendCallback); + _notify(_onerrorCallback.ref()); + _notify(_onloadendCallback.ref()); return; } } @@ -244,9 +244,9 @@ void MinXmlHttpRequest::handle_requestResponse(cocos2d::network::HttpClient *sen _data[_dataSize] = '\0'; memcpy((void*)_data, (const void*)buffer->data(), _dataSize); - _notify(_onreadystateCallback); - _notify(_onloadCallback); - _notify(_onloadendCallback); + _notify(_onreadystateCallback.ref()); + _notify(_onloadCallback.ref()); + _notify(_onloadendCallback.ref()); } /** * @brief Send out request and fire callback when done. @@ -270,13 +270,6 @@ MinXmlHttpRequest::MinXmlHttpRequest() , _type() , _data(nullptr) , _dataSize() -, _onreadystateCallback(nullptr) -, _onloadstartCallback(nullptr) -, _onabortCallback(nullptr) -, _onerrorCallback(nullptr) -, _onloadCallback(nullptr) -, _onloadendCallback(nullptr) -, _ontimeoutCallback(nullptr) , _readyState(UNSENT) , _status(0) , _statusText() @@ -294,6 +287,15 @@ MinXmlHttpRequest::MinXmlHttpRequest() { _scheduler = cocos2d::Director::getInstance()->getScheduler(); _scheduler->retain(); + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _onreadystateCallback.construct(cx); + _onloadstartCallback.construct(cx); + _onabortCallback.construct(cx); + _onerrorCallback.construct(cx); + _onloadCallback.construct(cx); + _onloadendCallback.construct(cx); + _ontimeoutCallback.construct(cx); } /** @@ -302,19 +304,13 @@ MinXmlHttpRequest::MinXmlHttpRequest() */ MinXmlHttpRequest::~MinXmlHttpRequest() { - -#define SAFE_REMOVE_OBJECT(callback) if (callback != NULL)\ - {\ - JS::RemoveObjectRoot(_cx, &callback);\ - } - - SAFE_REMOVE_OBJECT(_onreadystateCallback); - SAFE_REMOVE_OBJECT(_onloadstartCallback); - SAFE_REMOVE_OBJECT(_onloadendCallback); - SAFE_REMOVE_OBJECT(_onloadCallback); - SAFE_REMOVE_OBJECT(_onerrorCallback); - SAFE_REMOVE_OBJECT(_onabortCallback); - SAFE_REMOVE_OBJECT(_ontimeoutCallback); + _onreadystateCallback.destroyIfConstructed(); + _onloadstartCallback.destroyIfConstructed(); + _onloadendCallback.destroyIfConstructed(); + _onloadCallback.destroyIfConstructed(); + _onerrorCallback.destroyIfConstructed(); + _onabortCallback.destroyIfConstructed(); + _ontimeoutCallback.destroyIfConstructed(); if (_httpRequest) { @@ -367,9 +363,9 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) */ #define GETTER_SETTER_FOR_CALLBACK_PROP(x,y) JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, x)\ {\ - if (y)\ + if (y.ref())\ {\ - jsval out = OBJECT_TO_JSVAL(y);\ + JS::RootedValue out(cx, OBJECT_TO_JSVAL(y.ref()));\ args.rval().set(out);\ }\ else\ @@ -380,11 +376,10 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) }\ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, x)\ {\ - jsval callback = args.get(0);\ - if (callback != JSVAL_NULL)\ + JS::RootedValue callback(cx, args.get(0));\ + if (!callback.isNullOrUndefined())\ {\ - y = callback.toObjectOrNull();\ - JS::AddNamedObjectRoot(cx, &y, #y);\ + y.ref() = callback.toObjectOrNull();\ }\ return true;\ } @@ -759,7 +754,7 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send) _setHttpRequestHeader(); _sendRequest(cx); - _notify(_onloadstartCallback); + _notify(_onloadstartCallback.ref()); //begin schedule for timeout if(_timeout > 0) @@ -775,7 +770,7 @@ void MinXmlHttpRequest::update(float dt) _elapsedTime += dt; if(_elapsedTime * 1000 >= _timeout) { - _notify(_ontimeoutCallback); + _notify(_ontimeoutCallback.ref()); _elapsedTime = 0; _readyState = UNSENT; _scheduler->unscheduleAllForTarget(this); @@ -797,7 +792,7 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, abort) //3.Change the state to UNSENT. _readyState = UNSENT; - _notify(_onabortCallback); + _notify(_onabortCallback.ref()); return true; } @@ -922,7 +917,7 @@ static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) CCLOG("basic_object_finalize %p ...", obj); } -void MinXmlHttpRequest::_notify(JSObject * callback) +void MinXmlHttpRequest::_notify(JS::HandleObject callback) { js_proxy_t * p; void* ptr = (void*)this; diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.h b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.h index dc255c9ec4..9f7319e159 100644 --- a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.h +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.h @@ -94,7 +94,7 @@ private: void _setHttpRequestHeader(); void _setHttpRequestData(const char *data, size_t len); void _sendRequest(JSContext *cx); - void _notify(JSObject * callback); + void _notify(JS::HandleObject callback); std::string _url; JSContext* _cx; @@ -102,15 +102,15 @@ private: std::string _type; char* _data; uint32_t _dataSize; - JS::Heap _onloadstartCallback; - JS::Heap _onabortCallback; - JS::Heap _onerrorCallback; - JS::Heap _onloadCallback; - JS::Heap _onloadendCallback; - JS::Heap _ontimeoutCallback; - JS::Heap _onreadystateCallback; + mozilla::Maybe _onloadstartCallback; + mozilla::Maybe _onabortCallback; + mozilla::Maybe _onerrorCallback; + mozilla::Maybe _onloadCallback; + mozilla::Maybe _onloadendCallback; + mozilla::Maybe _ontimeoutCallback; + mozilla::Maybe _onreadystateCallback; int _readyState; - int _status; + long _status; std::string _statusText; ResponseType _responseType; unsigned long long _timeout; diff --git a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp index fdcad28553..b2874ae641 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp @@ -43,6 +43,13 @@ public: { std::string s = "default"; _eventRegistry[s] = nullptr; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _JSDelegate.construct(cx); + } + + ~JSB_SocketIODelegate() + { + _JSDelegate.destroyIfConstructed(); } virtual void onConnect(SIOClient* client) @@ -86,8 +93,6 @@ public: { args = std_string_to_jsval(cx, data); } - - //ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), eventName.c_str(), 1, &args); JSB_SIOCallbackRegistry::iterator it = _eventRegistry.find(eventName); @@ -103,9 +108,9 @@ public: } - void setJSDelegate(JSObject* pJSDelegate) + void setJSDelegate(JS::HandleObject pJSDelegate) { - _JSDelegate = pJSDelegate; + _JSDelegate.ref() = pJSDelegate; } void addEvent(const std::string& eventName, std::shared_ptr callback) @@ -114,7 +119,7 @@ public: } private: - JS::Heap _JSDelegate; + mozilla::Maybe _JSDelegate; JSB_SIOCallbackRegistry _eventRegistry; }; @@ -166,8 +171,7 @@ bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp) //previous connection not found, create a new one JSObject *obj = JS_NewObject(cx, js_cocos2dx_socketio_class, JS::RootedObject(cx, js_cocos2dx_socketio_prototype), JS::NullPtr()); p = jsb_new_proxy(ret, obj); - JS::AddNamedObjectRoot(cx, &p->obj, "SocketIO"); - siodelegate->setJSDelegate(p->obj); + siodelegate->setJSDelegate(JS::RootedObject(cx, p->obj)); } jsret = OBJECT_TO_JSVAL(p->obj); } @@ -352,7 +356,7 @@ bool js_cocos2dx_SocketIO_on(JSContext* cx, uint32_t argc, jsval* vp) CCLOG("JSB SocketIO eventName to: '%s'", eventName.c_str()); - std::shared_ptr callback(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), args.get(1))); + std::shared_ptr callback(new JSFunctionWrapper(cx, obj, args.get(1))); ((JSB_SocketIODelegate *)cobj->getDelegate())->addEvent(eventName, callback); diff --git a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp index fdfb4993c2..d78b7cd105 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp @@ -60,6 +60,17 @@ class JSB_WebSocketDelegate : public WebSocket::Delegate { public: + JSB_WebSocketDelegate() + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _JSDelegate.construct(cx); + } + + ~JSB_WebSocketDelegate() + { + _JSDelegate.destroyIfConstructed(); + } + virtual void onOpen(WebSocket* ws) { js_proxy_t * p = jsb_get_native_proxy(ws); @@ -75,7 +86,7 @@ public: jsval args = OBJECT_TO_JSVAL(jsobj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onopen", 1, &args); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "onopen", 1, &args); } virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) @@ -109,7 +120,7 @@ public: JS_SetProperty(cx, jsobj, "data", dataVal); } - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onmessage", 1, &args); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "onmessage", 1, &args); } virtual void onClose(WebSocket* ws) @@ -126,7 +137,7 @@ public: JS_SetProperty(cx, jsobj, "type", vp); jsval args = OBJECT_TO_JSVAL(jsobj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onclose", 1, &args); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "onclose", 1, &args); js_proxy_t* jsproxy = jsb_get_js_proxy(p->obj); JS::RemoveObjectRoot(cx, &jsproxy->obj); @@ -149,15 +160,15 @@ public: jsval args = OBJECT_TO_JSVAL(jsobj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onerror", 1, &args); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "onerror", 1, &args); } - void setJSDelegate(JSObject* pJSDelegate) + void setJSDelegate(JS::HandleObject pJSDelegate) { - _JSDelegate = pJSDelegate; + _JSDelegate.ref() = pJSDelegate; } private: - JS::Heap _JSDelegate; + mozilla::Maybe _JSDelegate; }; JSClass *js_cocos2dx_websocket_class; diff --git a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp index 1f8e319a04..203e94c50b 100644 --- a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp +++ b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp @@ -265,7 +265,7 @@ bool jsb_cocos2d_Physics3DObject_setCollisionCallback(JSContext *cx, uint32_t ar JSB_PRECONDITION2( cobj, cx, false, "jsb_cocos2d_Physics3DObject_setCollisionCallback : Invalid Native Object"); std::function arg0; - std::shared_ptr func(new JSFunctionWrapper(cx, args.get(1).toObjectOrNull(), args.get(0))); + std::shared_ptr func(new JSFunctionWrapper(cx, JS::RootedObject(cx, args.get(1).toObjectOrNull()), args.get(0))); auto lambda = [=](const Physics3DCollisionInfo &ci) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET diff --git a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp index 2d8ff188b5..929d897453 100755 --- a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp @@ -114,17 +114,14 @@ class JSB_EditBoxDelegate { public: JSB_EditBoxDelegate() - : _JSDelegate(nullptr) - , _needUnroot(false) - {} + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + _JSDelegate.construct(cx, JS::NullHandleValue); + } virtual ~JSB_EditBoxDelegate() { - if (_needUnroot) - { - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RemoveObjectRoot(cx, &_JSDelegate); - } + _JSDelegate.destroyIfConstructed(); } virtual void editBoxEditingDidBegin(EditBox* editBox) override @@ -133,7 +130,7 @@ public: if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidBegin", 1, &arg); + ScriptingCore::getInstance()->executeFunctionWithOwner(_JSDelegate.ref().get(), "editBoxEditingDidBegin", 1, &arg); } virtual void editBoxEditingDidEnd(EditBox* editBox) override @@ -142,7 +139,7 @@ public: if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidEnd", 1, &arg); + ScriptingCore::getInstance()->executeFunctionWithOwner(_JSDelegate.ref().get(), "editBoxEditingDidEnd", 1, &arg); } virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) override @@ -155,7 +152,7 @@ public: std::string arg1 = text; dataVal[1] = std_string_to_jsval(ScriptingCore::getInstance()->getGlobalContext(), arg1); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxTextChanged", 2, dataVal); + ScriptingCore::getInstance()->executeFunctionWithOwner(_JSDelegate.ref().get(), "editBoxTextChanged", 2, dataVal); } virtual void editBoxReturn(EditBox* editBox) override @@ -164,31 +161,21 @@ public: if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxReturn", 1, &arg); + ScriptingCore::getInstance()->executeFunctionWithOwner(_JSDelegate.ref().get(), "editBoxReturn", 1, &arg); } - void setJSDelegate(JSObject* pJSDelegate) + void setJSDelegate(JS::HandleValue pJSDelegate) { - _JSDelegate = pJSDelegate; - - // Check whether the js delegate is a pure js object. - js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); - if (!p) - { - _needUnroot = true; - JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); - } + _JSDelegate.ref() = pJSDelegate; } private: - JS::Heap _JSDelegate; - bool _needUnroot; + mozilla::Maybe _JSDelegate; }; static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -196,9 +183,8 @@ static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsva if (argc == 1) { // save the delegate - JSObject *jsDelegate = args.get(0).toObjectOrNull(); JSB_EditBoxDelegate* nativeDelegate = new JSB_EditBoxDelegate(); - nativeDelegate->setJSDelegate(jsDelegate); + nativeDelegate->setJSDelegate(args.get(0)); cobj->setUserObject(nativeDelegate); cobj->setDelegate(nativeDelegate); From c202834312c3c9cf3c3c76d07a09c29c7b04a476 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 25 Nov 2015 14:33:43 +0800 Subject: [PATCH 130/192] Clean up manual bindings code, remove JS_THIS_OBJECT and JS_SET_RVAL --- .../js-bindings/manual/ScriptingCore.cpp | 4 - .../js_bindings_chipmunk_auto_classes.cpp | 669 ++++++++---------- .../chipmunk/js_bindings_chipmunk_manual.cpp | 145 ++-- .../js-bindings/manual/cocos2d_specifics.cpp | 96 ++- .../cocosbuilder/js_bindings_ccbreader.cpp | 15 +- .../cocostudio/jsb_cocos2dx_studio_manual.cpp | 21 +- ...jsb_cocos2dx_experimental_video_manual.cpp | 4 +- ...b_cocos2dx_experimental_webView_manual.cpp | 16 +- .../js-bindings/manual/js_bindings_opengl.cpp | 4 +- .../scripting/js-bindings/manual/jsb_helper.h | 7 +- .../navmesh/jsb_cocos2dx_navmesh_manual.cpp | 5 +- .../manual/network/jsb_socketio.cpp | 8 +- .../manual/network/jsb_websocket.cpp | 4 +- .../spine/jsb_cocos2dx_spine_manual.cpp | 16 +- .../manual/ui/jsb_cocos2dx_ui_manual.cpp | 23 +- 15 files changed, 446 insertions(+), 591 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 892931d1d8..c03e1751e5 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -1661,7 +1661,6 @@ bool JSBDebug_enterNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().set(UINT_TO_JSVAL(s_nestedLoopLevel)); -// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return true; } @@ -1672,11 +1671,9 @@ bool JSBDebug_exitNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) --s_nestedLoopLevel; } else { args.rval().set(UINT_TO_JSVAL(0)); -// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(0)); return true; } args.rval().setUndefined(); -// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return true; } @@ -1684,7 +1681,6 @@ bool JSBDebug_getEventLoopNestLevel(JSContext* cx, unsigned argc, jsval* vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().set(UINT_TO_JSVAL(s_nestedLoopLevel)); -// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return true; } diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp index 6d4813fa5a..45226a0201 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp @@ -51,7 +51,7 @@ void JSB_cpConstraint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpConstraint_activateBodies(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; @@ -65,7 +65,7 @@ bool JSB_cpConstraint_activateBodies(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; @@ -79,7 +79,7 @@ bool JSB_cpConstraint_destroy(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_getA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpBody* ret_val = nullptr; @@ -97,7 +97,7 @@ bool JSB_cpConstraint_getA(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_getB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpBody* ret_val = nullptr; @@ -115,7 +115,7 @@ bool JSB_cpConstraint_getB(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_getErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val = 0; @@ -130,7 +130,7 @@ bool JSB_cpConstraint_getErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_getImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val = 0; @@ -145,7 +145,7 @@ bool JSB_cpConstraint_getImpulse(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_getMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val = 0; @@ -160,7 +160,7 @@ bool JSB_cpConstraint_getMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_getMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val = 0; @@ -175,7 +175,7 @@ bool JSB_cpConstraint_getMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpConstraint_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpSpace* ret_val = nullptr; @@ -192,11 +192,10 @@ bool JSB_cpConstraint_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpConstraint_setErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1; @@ -212,11 +211,10 @@ bool JSB_cpConstraint_setErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpConstraint_setMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1; @@ -232,11 +230,10 @@ bool JSB_cpConstraint_setMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpConstraint_setMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1; @@ -342,7 +339,7 @@ void JSB_cpGrooveJoint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpGrooveJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; cpVect ret_val; @@ -360,7 +357,7 @@ bool JSB_cpGrooveJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpGrooveJoint_getGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; cpVect ret_val; @@ -378,7 +375,7 @@ bool JSB_cpGrooveJoint_getGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpGrooveJoint_getGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; cpVect ret_val; @@ -395,11 +392,10 @@ bool JSB_cpGrooveJoint_getGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpGrooveJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -415,11 +411,10 @@ bool JSB_cpGrooveJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpGrooveJoint_setGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -435,11 +430,10 @@ bool JSB_cpGrooveJoint_setGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpGrooveJoint_setGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -537,7 +531,7 @@ void JSB_cpSimpleMotor_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpSimpleMotor_getRate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSimpleMotor* arg0 = (cpSimpleMotor*) proxy->handle; cpFloat ret_val = 0; @@ -551,11 +545,10 @@ bool JSB_cpSimpleMotor_getRate(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSimpleMotor_setRate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSimpleMotor* arg0 = (cpSimpleMotor*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1; @@ -654,7 +647,7 @@ void JSB_cpPivotJoint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpPivotJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; cpVect ret_val; @@ -672,7 +665,7 @@ bool JSB_cpPivotJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpPivotJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; cpVect ret_val; @@ -689,11 +682,10 @@ bool JSB_cpPivotJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpPivotJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -709,11 +701,10 @@ bool JSB_cpPivotJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpPivotJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -810,7 +801,7 @@ void JSB_cpPinJoint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpPinJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; cpVect ret_val; @@ -828,7 +819,7 @@ bool JSB_cpPinJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpPinJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; cpVect ret_val; @@ -846,7 +837,7 @@ bool JSB_cpPinJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpPinJoint_getDist(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; cpFloat ret_val = 0; @@ -860,11 +851,10 @@ bool JSB_cpPinJoint_getDist(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpPinJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -880,11 +870,10 @@ bool JSB_cpPinJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpPinJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -900,11 +889,10 @@ bool JSB_cpPinJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpPinJoint_setDist(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1005,7 +993,7 @@ void JSB_cpSlideJoint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpSlideJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpVect ret_val; @@ -1023,7 +1011,7 @@ bool JSB_cpSlideJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSlideJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpVect ret_val; @@ -1041,7 +1029,7 @@ bool JSB_cpSlideJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSlideJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpFloat ret_val = 0; @@ -1056,7 +1044,7 @@ bool JSB_cpSlideJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSlideJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpFloat ret_val = 0; @@ -1070,11 +1058,10 @@ bool JSB_cpSlideJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSlideJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -1090,11 +1077,10 @@ bool JSB_cpSlideJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSlideJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -1110,11 +1096,10 @@ bool JSB_cpSlideJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSlideJoint_setMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1130,11 +1115,10 @@ bool JSB_cpSlideJoint_setMax(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSlideJoint_setMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1235,7 +1219,7 @@ void JSB_cpGearJoint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpGearJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; cpFloat ret_val = 0; @@ -1250,7 +1234,7 @@ bool JSB_cpGearJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpGearJoint_getRatio(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; cpFloat ret_val = 0; @@ -1264,11 +1248,10 @@ bool JSB_cpGearJoint_getRatio(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpGearJoint_setPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1284,11 +1267,10 @@ bool JSB_cpGearJoint_setPhase(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpGearJoint_setRatio(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1386,7 +1368,7 @@ void JSB_cpDampedRotarySpring_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpDampedRotarySpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; cpFloat ret_val = 0; @@ -1401,7 +1383,7 @@ bool JSB_cpDampedRotarySpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp bool JSB_cpDampedRotarySpring_getRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; cpFloat ret_val = 0; @@ -1416,7 +1398,7 @@ bool JSB_cpDampedRotarySpring_getRestAngle(JSContext *cx, uint32_t argc, jsval * bool JSB_cpDampedRotarySpring_getStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; cpFloat ret_val = 0; @@ -1430,11 +1412,10 @@ bool JSB_cpDampedRotarySpring_getStiffness(JSContext *cx, uint32_t argc, jsval * // Ret value: void bool JSB_cpDampedRotarySpring_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1450,11 +1431,10 @@ bool JSB_cpDampedRotarySpring_setDamping(JSContext *cx, uint32_t argc, jsval *vp // Ret value: void bool JSB_cpDampedRotarySpring_setRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1470,11 +1450,10 @@ bool JSB_cpDampedRotarySpring_setRestAngle(JSContext *cx, uint32_t argc, jsval * // Ret value: void bool JSB_cpDampedRotarySpring_setStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1576,7 +1555,7 @@ void JSB_cpDampedSpring_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpDampedSpring_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpVect ret_val; @@ -1594,7 +1573,7 @@ bool JSB_cpDampedSpring_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpDampedSpring_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpVect ret_val; @@ -1612,7 +1591,7 @@ bool JSB_cpDampedSpring_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpDampedSpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpFloat ret_val = 0; @@ -1627,7 +1606,7 @@ bool JSB_cpDampedSpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpDampedSpring_getRestLength(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpFloat ret_val = 0; @@ -1642,7 +1621,7 @@ bool JSB_cpDampedSpring_getRestLength(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpDampedSpring_getStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpFloat ret_val = 0; @@ -1656,11 +1635,10 @@ bool JSB_cpDampedSpring_getStiffness(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpDampedSpring_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -1676,11 +1654,10 @@ bool JSB_cpDampedSpring_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpDampedSpring_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -1696,11 +1673,10 @@ bool JSB_cpDampedSpring_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpDampedSpring_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1716,11 +1692,10 @@ bool JSB_cpDampedSpring_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpDampedSpring_setRestLength(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1736,11 +1711,10 @@ bool JSB_cpDampedSpring_setRestLength(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpDampedSpring_setStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1843,7 +1817,7 @@ void JSB_cpRatchetJoint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpRatchetJoint_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; cpFloat ret_val = 0; @@ -1858,7 +1832,7 @@ bool JSB_cpRatchetJoint_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpRatchetJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; cpFloat ret_val = 0; @@ -1873,7 +1847,7 @@ bool JSB_cpRatchetJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpRatchetJoint_getRatchet(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; cpFloat ret_val = 0; @@ -1887,11 +1861,10 @@ bool JSB_cpRatchetJoint_getRatchet(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpRatchetJoint_setAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1907,11 +1880,10 @@ bool JSB_cpRatchetJoint_setAngle(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpRatchetJoint_setPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -1927,11 +1899,10 @@ bool JSB_cpRatchetJoint_setPhase(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpRatchetJoint_setRatchet(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -2030,7 +2001,7 @@ void JSB_cpRotaryLimitJoint_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpRotaryLimitJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; cpFloat ret_val = 0; @@ -2045,7 +2016,7 @@ bool JSB_cpRotaryLimitJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpRotaryLimitJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; cpFloat ret_val = 0; @@ -2059,11 +2030,10 @@ bool JSB_cpRotaryLimitJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpRotaryLimitJoint_setMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -2079,11 +2049,10 @@ bool JSB_cpRotaryLimitJoint_setMax(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpRotaryLimitJoint_setMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -2166,7 +2135,7 @@ void JSB_cpArbiter_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpArbiter_getCount(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; int ret_val = 0; @@ -2180,11 +2149,10 @@ bool JSB_cpArbiter_getCount(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpFloat bool JSB_cpArbiter_getDepth(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int32_t arg1 = 0; @@ -2202,7 +2170,7 @@ bool JSB_cpArbiter_getDepth(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpArbiter_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpFloat ret_val = 0; @@ -2217,7 +2185,7 @@ bool JSB_cpArbiter_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpArbiter_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpFloat ret_val = 0; @@ -2231,11 +2199,10 @@ bool JSB_cpArbiter_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpVect bool JSB_cpArbiter_getNormal(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int32_t arg1 = 0; @@ -2255,11 +2222,10 @@ bool JSB_cpArbiter_getNormal(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpVect bool JSB_cpArbiter_getPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int32_t arg1 = 0; @@ -2280,7 +2246,7 @@ bool JSB_cpArbiter_getPoint(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpArbiter_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpVect ret_val; @@ -2298,7 +2264,7 @@ bool JSB_cpArbiter_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpArbiter_ignore(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; @@ -2312,7 +2278,7 @@ bool JSB_cpArbiter_ignore(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpArbiter_isFirstContact(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpBool ret_val; @@ -2326,11 +2292,10 @@ bool JSB_cpArbiter_isFirstContact(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpArbiter_setElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -2346,11 +2311,10 @@ bool JSB_cpArbiter_setElasticity(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpArbiter_setFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -2366,11 +2330,10 @@ bool JSB_cpArbiter_setFriction(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpArbiter_setSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -2387,7 +2350,7 @@ bool JSB_cpArbiter_setSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpArbiter_totalImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpVect ret_val; @@ -2405,7 +2368,7 @@ bool JSB_cpArbiter_totalImpulse(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpArbiter_totalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpVect ret_val; @@ -2423,7 +2386,7 @@ bool JSB_cpArbiter_totalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval bool JSB_cpArbiter_totalKE(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpFloat ret_val = 0; @@ -2556,7 +2519,6 @@ bool JSB_cpSpace_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - //JSObject* jsobj = JS_NewObjectForConstructor(cx, JSB_cpSpace_class, args); JSObject *jsobj = JS_NewObject(cx, JSB_cpSpace_class, JS::RootedObject(cx, JSB_cpSpace_object), JS::NullPtr()); void* ret_val = cpSpaceNew( ); @@ -2571,11 +2533,10 @@ bool JSB_cpSpace_constructor(JSContext *cx, uint32_t argc, jsval *vp) // Ret value: void bool JSB_cpSpace_activateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -2591,11 +2552,10 @@ bool JSB_cpSpace_activateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval // Ret value: cpBool bool JSB_cpSpace_containsBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg1 = nullptr; @@ -2612,11 +2572,10 @@ bool JSB_cpSpace_containsBody(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpBool bool JSB_cpSpace_containsConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpConstraint* arg1 = nullptr; @@ -2633,11 +2592,10 @@ bool JSB_cpSpace_containsConstraint(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpBool bool JSB_cpSpace_containsShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -2655,7 +2613,7 @@ bool JSB_cpSpace_containsShape(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; @@ -2669,7 +2627,7 @@ bool JSB_cpSpace_destroy(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_getCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val = 0; @@ -2684,7 +2642,7 @@ bool JSB_cpSpace_getCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_getCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpTimestamp ret_val = 0; @@ -2699,7 +2657,7 @@ bool JSB_cpSpace_getCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp bool JSB_cpSpace_getCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val = 0; @@ -2714,7 +2672,7 @@ bool JSB_cpSpace_getCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_getCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val = 0; @@ -2729,7 +2687,7 @@ bool JSB_cpSpace_getCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val = 0; @@ -2744,7 +2702,7 @@ bool JSB_cpSpace_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_getEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpBool ret_val; @@ -2759,7 +2717,7 @@ bool JSB_cpSpace_getEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpSpace_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpVect ret_val; @@ -2777,7 +2735,7 @@ bool JSB_cpSpace_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_getIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val = 0; @@ -2792,7 +2750,7 @@ bool JSB_cpSpace_getIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpSpace_getIterations(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; int ret_val = 0; @@ -2807,7 +2765,7 @@ bool JSB_cpSpace_getIterations(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_getSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val = 0; @@ -2822,7 +2780,7 @@ bool JSB_cpSpace_getSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpSpace_getStaticBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpBody* ret_val = nullptr; @@ -2840,7 +2798,7 @@ bool JSB_cpSpace_getStaticBody(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_init(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpSpace* ret_val = nullptr; @@ -2858,7 +2816,7 @@ bool JSB_cpSpace_init(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_isLocked(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpBool ret_val; @@ -2872,11 +2830,10 @@ bool JSB_cpSpace_isLocked(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpShape* bool JSB_cpSpace_pointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; uint32_t arg2 = 0; cpGroup arg3 = 0; @@ -2900,11 +2857,10 @@ bool JSB_cpSpace_pointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_reindexShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -2920,11 +2876,10 @@ bool JSB_cpSpace_reindexShape(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_reindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg1 = nullptr; @@ -2941,7 +2896,7 @@ bool JSB_cpSpace_reindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSpace_reindexStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; @@ -2954,11 +2909,10 @@ bool JSB_cpSpace_reindexStatic(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_setCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -2974,11 +2928,10 @@ bool JSB_cpSpace_setCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_setCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; uint32_t arg1 = 0; @@ -2994,11 +2947,10 @@ bool JSB_cpSpace_setCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp // Ret value: void bool JSB_cpSpace_setCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3014,11 +2966,10 @@ bool JSB_cpSpace_setCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3034,11 +2985,10 @@ bool JSB_cpSpace_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_setEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int32_t arg1 = 0; @@ -3054,11 +3004,10 @@ bool JSB_cpSpace_setEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) // Ret value: void bool JSB_cpSpace_setGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -3074,11 +3023,10 @@ bool JSB_cpSpace_setGravity(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_setIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3094,11 +3042,10 @@ bool JSB_cpSpace_setIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) // Ret value: void bool JSB_cpSpace_setIterations(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int32_t arg1 = 0; @@ -3114,11 +3061,10 @@ bool JSB_cpSpace_setIterations(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_setSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3134,11 +3080,10 @@ bool JSB_cpSpace_setSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) // Ret value: void bool JSB_cpSpace_step(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3154,11 +3099,10 @@ bool JSB_cpSpace_step(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_useSpatialHash(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; int32_t arg2 = 0; @@ -3279,7 +3223,7 @@ void JSB_cpBody_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpBody_activate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; @@ -3292,11 +3236,10 @@ bool JSB_cpBody_activate(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_activateStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -3312,11 +3255,10 @@ bool JSB_cpBody_activateStatic(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_applyForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; cpVect arg2; @@ -3333,11 +3275,10 @@ bool JSB_cpBody_applyForce(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_applyImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; cpVect arg2; @@ -3355,7 +3296,7 @@ bool JSB_cpBody_applyImpulse(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; @@ -3369,7 +3310,7 @@ bool JSB_cpBody_destroy(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getAngVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3384,7 +3325,7 @@ bool JSB_cpBody_getAngVel(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3399,7 +3340,7 @@ bool JSB_cpBody_getAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3414,7 +3355,7 @@ bool JSB_cpBody_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; @@ -3432,7 +3373,7 @@ bool JSB_cpBody_getForce(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getMass(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3447,7 +3388,7 @@ bool JSB_cpBody_getMass(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getMoment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3462,7 +3403,7 @@ bool JSB_cpBody_getMoment(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getPos(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; @@ -3480,7 +3421,7 @@ bool JSB_cpBody_getPos(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getRot(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; @@ -3498,7 +3439,7 @@ bool JSB_cpBody_getRot(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpSpace* ret_val = nullptr; @@ -3516,7 +3457,7 @@ bool JSB_cpBody_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getTorque(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3531,7 +3472,7 @@ bool JSB_cpBody_getTorque(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; @@ -3548,11 +3489,10 @@ bool JSB_cpBody_getVel(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpVect bool JSB_cpBody_getVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -3572,11 +3512,10 @@ bool JSB_cpBody_getVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpVect bool JSB_cpBody_getVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -3597,7 +3536,7 @@ bool JSB_cpBody_getVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_getVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3611,11 +3550,10 @@ bool JSB_cpBody_getVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpBody* bool JSB_cpBody_init(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; double arg2 = 0; @@ -3637,7 +3575,7 @@ bool JSB_cpBody_init(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_initStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBody* ret_val = nullptr; @@ -3655,7 +3593,7 @@ bool JSB_cpBody_initStatic(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_isRogue(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBool ret_val; @@ -3670,7 +3608,7 @@ bool JSB_cpBody_isRogue(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_isSleeping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBool ret_val; @@ -3685,7 +3623,7 @@ bool JSB_cpBody_isSleeping(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_isStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBool ret_val; @@ -3700,7 +3638,7 @@ bool JSB_cpBody_isStatic(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_kineticEnergy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val = 0; @@ -3714,11 +3652,10 @@ bool JSB_cpBody_kineticEnergy(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpVect bool JSB_cpBody_local2World(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -3739,7 +3676,7 @@ bool JSB_cpBody_local2World(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_resetForces(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; @@ -3752,11 +3689,10 @@ bool JSB_cpBody_resetForces(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setAngVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3772,11 +3708,10 @@ bool JSB_cpBody_setAngVel(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3792,11 +3727,10 @@ bool JSB_cpBody_setAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3812,11 +3746,10 @@ bool JSB_cpBody_setAngle(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -3832,11 +3765,10 @@ bool JSB_cpBody_setForce(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setMass(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3852,11 +3784,10 @@ bool JSB_cpBody_setMass(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setMoment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3872,11 +3803,10 @@ bool JSB_cpBody_setMoment(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setPos(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -3892,11 +3822,10 @@ bool JSB_cpBody_setPos(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setTorque(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3912,11 +3841,10 @@ bool JSB_cpBody_setTorque(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -3932,11 +3860,10 @@ bool JSB_cpBody_setVel(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_setVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -3953,7 +3880,7 @@ bool JSB_cpBody_setVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpBody_sleep(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; @@ -3966,11 +3893,10 @@ bool JSB_cpBody_sleep(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_sleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg1 = nullptr; @@ -3986,11 +3912,10 @@ bool JSB_cpBody_sleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_updatePosition(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -4006,11 +3931,10 @@ bool JSB_cpBody_updatePosition(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpBody_updateVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; double arg2 = 0; double arg3 = 0; @@ -4028,11 +3952,10 @@ bool JSB_cpBody_updateVelocity(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpVect bool JSB_cpBody_world2Local(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -4202,7 +4125,7 @@ void JSB_cpShape_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpShape_cacheBB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBB ret_val; @@ -4220,7 +4143,7 @@ bool JSB_cpShape_cacheBB(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; @@ -4234,7 +4157,7 @@ bool JSB_cpShape_destroy(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getBB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBB ret_val; @@ -4252,7 +4175,7 @@ bool JSB_cpShape_getBB(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBody* ret_val = nullptr; @@ -4270,14 +4193,14 @@ bool JSB_cpShape_getBody(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpCollisionType ret_val = 0; ret_val = cpShapeGetCollisionType((cpShape*)arg0 ); - jsval ret_jsval = uint32_to_jsval( cx, (cpCollisionType)ret_val ); + jsval ret_jsval = uint32_to_jsval( cx, (uint32_t)ret_val ); args.rval().set(ret_jsval); return true; @@ -4288,7 +4211,7 @@ bool JSB_cpShape_getCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpFloat ret_val = 0; @@ -4303,7 +4226,7 @@ bool JSB_cpShape_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpFloat ret_val = 0; @@ -4318,14 +4241,14 @@ bool JSB_cpShape_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpGroup ret_val = 0; ret_val = cpShapeGetGroup((cpShape*)arg0 ); - jsval ret_jsval = uint32_to_jsval( cx, (cpGroup)ret_val ); + jsval ret_jsval = uint32_to_jsval( cx, (uint32_t)ret_val ); args.rval().set(ret_jsval); return true; @@ -4336,7 +4259,7 @@ bool JSB_cpShape_getGroup(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getLayers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpLayers ret_val = 0; @@ -4351,7 +4274,7 @@ bool JSB_cpShape_getLayers(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getSensor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBool ret_val; @@ -4366,7 +4289,7 @@ bool JSB_cpShape_getSensor(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpSpace* ret_val = nullptr; @@ -4384,7 +4307,7 @@ bool JSB_cpShape_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpVect ret_val; @@ -4401,11 +4324,10 @@ bool JSB_cpShape_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpBool bool JSB_cpShape_pointQuery(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -4422,11 +4344,10 @@ bool JSB_cpShape_pointQuery(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg1 = nullptr; @@ -4442,11 +4363,10 @@ bool JSB_cpShape_setBody(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpCollisionType arg1 = 0; @@ -4462,11 +4382,10 @@ bool JSB_cpShape_setCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -4482,11 +4401,10 @@ bool JSB_cpShape_setElasticity(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double arg1 = 0; @@ -4502,11 +4420,10 @@ bool JSB_cpShape_setFriction(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpGroup arg1 = 0; @@ -4522,11 +4439,10 @@ bool JSB_cpShape_setGroup(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setLayers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; uint32_t arg1 = 0; @@ -4542,11 +4458,10 @@ bool JSB_cpShape_setLayers(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setSensor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int32_t arg1 = 0; @@ -4562,11 +4477,10 @@ bool JSB_cpShape_setSensor(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpShape_setSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; @@ -4582,11 +4496,10 @@ bool JSB_cpShape_setSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpBB bool JSB_cpShape_update(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; cpVect arg2; @@ -4608,7 +4521,7 @@ bool JSB_cpShape_update(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpShape_active(JSContext *cx, uint32_t argc, jsval *vp){ JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; @@ -4621,11 +4534,10 @@ bool JSB_cpShape_active(JSContext *cx, uint32_t argc, jsval *vp){ bool JSB_cpShape_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* shape = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cpVect p; bool ok = jsval_to_cpVect(cx, args.get(0), &p); @@ -4644,11 +4556,10 @@ bool JSB_cpShape_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpShape_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* shape = (cpShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cpVect a; cpVect b; @@ -4844,7 +4755,7 @@ void JSB_cpCircleShape_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpCircleShape_getOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpCircleShape* arg0 = (cpCircleShape*) proxy->handle; cpVect ret_val; @@ -4862,7 +4773,7 @@ bool JSB_cpCircleShape_getOffset(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpCircleShape_getRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpCircleShape* arg0 = (cpCircleShape*) proxy->handle; cpFloat ret_val = 0; @@ -4955,7 +4866,7 @@ void JSB_cpSegmentShape_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpSegmentShape_getA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpVect ret_val; @@ -4973,7 +4884,7 @@ bool JSB_cpSegmentShape_getA(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSegmentShape_getB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpVect ret_val; @@ -4991,7 +4902,7 @@ bool JSB_cpSegmentShape_getB(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSegmentShape_getNormal(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpVect ret_val; @@ -5009,7 +4920,7 @@ bool JSB_cpSegmentShape_getNormal(JSContext *cx, uint32_t argc, jsval *vp) { bool JSB_cpSegmentShape_getRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpFloat ret_val = 0; @@ -5023,11 +4934,10 @@ bool JSB_cpSegmentShape_getRadius(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSegmentShape_setNeighbors(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpVect arg1; cpVect arg2; @@ -5127,7 +5037,7 @@ void JSB_cpPolyShape_finalize(JSFreeOp *fop, JSObject *jsthis) bool JSB_cpPolyShape_getNumVerts(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPolyShape* arg0 = (cpPolyShape*) proxy->handle; int ret_val = 0; @@ -5141,11 +5051,10 @@ bool JSB_cpPolyShape_getNumVerts(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpVect bool JSB_cpPolyShape_getVert(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPolyShape* arg0 = (cpPolyShape*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int32_t arg1 = 0; @@ -5317,11 +5226,10 @@ void JSB_cpSplittingPlane_createClass(JSContext *cx, JS::HandleObject globalObj, bool JSB_cpSegmentQueryInfo_hitPoint(JSContext *cx, uint32_t argc, jsval *vp){ JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cpVect start; cpVect end; @@ -5339,11 +5247,10 @@ bool JSB_cpSegmentQueryInfo_hitPoint(JSContext *cx, uint32_t argc, jsval *vp){ bool JSB_cpSegmentQueryInfo_hitDist(JSContext *cx, uint32_t argc, jsval *vp){ JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cpVect start; cpVect end; diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp index 4da02c3e13..80bc51c49c 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -78,7 +78,7 @@ void JSPROXY_CCPhysicsSprite_finalize(JSFreeOp *fop, JSObject *obj) // Ret value: BOOL (b) bool JSPROXY_CCPhysicsSprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) @@ -94,7 +94,7 @@ bool JSPROXY_CCPhysicsSprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpBody* (N/A) bool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) @@ -111,7 +111,7 @@ bool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp) // Ret value: BOOL (b) bool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) @@ -126,15 +126,13 @@ bool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc, js // Arguments: cpBody* // Ret value: void (None) bool JSPROXY_CCPhysicsSprite_setCPBody_(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - cpBody* arg0 = nullptr; ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); @@ -148,13 +146,12 @@ bool JSPROXY_CCPhysicsSprite_setCPBody_(JSContext *cx, uint32_t argc, jsval *vp) // Arguments: BOOL // Ret value: void (None) bool JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool arg0 = JS::ToBoolean( args.get(0) ); real->setIgnoreBodyRotation((bool)arg0); @@ -219,14 +216,13 @@ bool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t // Arguments: cpSpace* // Ret value: void (None) bool JSB_CCPhysicsDebugNode_setSpace_(JSContext *cx, uint32_t argc, jsval *vp) { - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(jsthis); PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpSpace* arg0 = nullptr; @@ -242,15 +238,13 @@ bool JSB_CCPhysicsDebugNode_setSpace_(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpSpace* (N/A) bool JSB_CCPhysicsDebugNode_space(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(jsthis); PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); cpSpace* ret_val; - ret_val = real->getSpace(); - jsval ret_jsval = opaque_to_jsval( cx, ret_val ); args.rval().set(ret_jsval); @@ -956,10 +950,6 @@ bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, c ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeA ); ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeB ); - // this is no longer passed, so "this" is going to be "this". -// ok &= JS_ValueToObject(cx, *argvp++, &handler->jsthis ); - handler->jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - handler->begin = argvp->toObjectOrNull(); argvp++; handler->pre = argvp->toObjectOrNull(); @@ -1019,7 +1009,6 @@ bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==7, cx, false, "Invalid number of arguments"); - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); // args @@ -1035,9 +1024,9 @@ bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==6, cx, false, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); - JSB_PRECONDITION( jsthis, "Invalid jsthis object"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; @@ -1047,7 +1036,8 @@ bool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*) proxy->handle; @@ -1058,7 +1048,6 @@ bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval handler->typeB = 0; handler->jsthis = jsthis; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); handler->begin = args.get(0).toObjectOrNull(); handler->pre = args.get(1).toObjectOrNull(); handler->post = args.get(2).toObjectOrNull(); @@ -1177,7 +1166,7 @@ bool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==2, cx, false, "Invalid number of arguments"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); @@ -1192,11 +1181,10 @@ bool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) // Ret value: cpBody* bool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg1 = nullptr; @@ -1219,11 +1207,10 @@ bool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpConstraint* bool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpConstraint* arg1 = nullptr; @@ -1246,11 +1233,10 @@ bool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpShape* bool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -1273,11 +1259,10 @@ bool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: cpShape* bool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -1302,11 +1287,10 @@ bool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg1 = nullptr; @@ -1325,11 +1309,10 @@ bool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpConstraint* arg1 = nullptr; @@ -1348,11 +1331,10 @@ bool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -1371,11 +1353,10 @@ bool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp) { // Ret value: void bool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpShape* arg1 = nullptr; @@ -1393,10 +1374,10 @@ bool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { #pragma mark segmentQueryFirst function bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){ - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cpVect start; cpVect end; @@ -1430,10 +1411,10 @@ bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){ #pragma mark nearestPointQueryNearest function bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *vp){ - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*) proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cpVect point; double maxDistance = 0; @@ -1681,11 +1662,10 @@ void JSB_cpSpace_each_func(T* cpObject, void *data) bool JSB_cpSpace_eachShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*)proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); if (!data) @@ -1702,11 +1682,10 @@ bool JSB_cpSpace_eachShape(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpSpace_eachBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*)proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); if (!data) @@ -1723,11 +1702,10 @@ bool JSB_cpSpace_eachBody(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpSpace_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*)proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); if (!data) @@ -1802,11 +1780,10 @@ void JSB_cpBody_each_func(cpBody* body, T* cpObject, void* data) bool JSB_cpBody_eachShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* body = (cpBody*)proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); if (!data) @@ -1823,11 +1800,10 @@ bool JSB_cpBody_eachShape(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpBody_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* body = (cpBody*)proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); if (!data) @@ -1844,11 +1820,10 @@ bool JSB_cpBody_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpBody_eachArbiter(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* body = (cpBody*)proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); if (!data) @@ -1909,14 +1884,13 @@ bool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); - - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); JSB_PRECONDITION( proxy, "Invalid private object"); void *handle = proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); return __jsb_cpArbiter_getBodies(cx, args, (cpArbiter*)handle, 1); } @@ -1965,12 +1939,12 @@ bool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); return __jsb_cpArbiter_getShapes(cx, args, (cpArbiter*)handle, 1); } @@ -2038,12 +2012,12 @@ bool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); return __jsb_cpBody_getUserData(cx, args, (cpBody*)handle); } @@ -2081,12 +2055,12 @@ bool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); return __jsb_cpBody_setUserData(cx, vp, args.array(), (cpBody*)handle); } @@ -2205,11 +2179,11 @@ void JSB_cpBase_finalize(JSFreeOp *fop, JSObject *obj) bool JSB_cpBase_getHandle(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; @@ -2220,12 +2194,11 @@ bool JSB_cpBase_getHandle(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpBase_setHandle(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - void *handle = nullptr; bool ok = jsval_to_opaque(cx, args.get(0), &handle); JSB_PRECONDITION( ok, "Invalid parsing arguments"); diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 11ce8a0368..7269841548 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -213,7 +213,6 @@ bool js_cocos2dx_EventTouch_getTouches(JSContext *cx, uint32_t argc, jsval *vp) ++i; } -// JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsretArr)); args.rval().set(OBJECT_TO_JSVAL(jsretArr)); return true; } @@ -226,16 +225,14 @@ bool js_cocos2dx_EventTouch_getTouches(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_EventTouch_setTouches(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); -// jsval *argv = JS_ARGV(cx, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EventTouch* cobj = (cocos2d::EventTouch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventTouch_setTouches : Invalid Native Object"); if (argc == 1) { std::vector arg0; JS::RootedObject jsobj(cx, args.get(0).toObjectOrNull()); -// ok = argv->isObject() && JS_ValueToObject( cx, JS::RootedValue(cx, *argv), &jsobj ); JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); @@ -256,7 +253,6 @@ bool js_cocos2dx_EventTouch_setTouches(JSContext *cx, uint32_t argc, jsval *vp) } } cobj->setTouches(arg0); -// args.rval().setUndefined(); args.rval().setUndefined(); return true; } @@ -750,12 +746,11 @@ static bool js_callFunc(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CallFunc_initWithFunction(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1 && argc <= 3) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); CallFuncN *action = (cocos2d::CallFuncN *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2(action, cx, false, "Invalid Native Object"); - - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); std::shared_ptr tmpCobj(new JSCallbackWrapper()); @@ -1564,7 +1559,7 @@ bool js_cocos2dx_CCNode_scheduleUpdate(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CCScheduler_unscheduleAllSelectorsForTarget(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) @@ -1603,8 +1598,7 @@ bool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval if (argc >= 1) { bool ok = true; JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); @@ -1681,7 +1675,7 @@ bool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval bool js_CCScheduler_unscheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) @@ -1896,7 +1890,7 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp) bool js_CCScheduler_unscheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) @@ -1962,7 +1956,7 @@ bool js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority(JSContext *cx { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -1984,7 +1978,7 @@ bool js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority(JSContext *cx bool js_cocos2dx_CCScheduler_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); @@ -2010,7 +2004,7 @@ bool js_cocos2dx_CCScheduler_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_CCScheduler_resumeTarget(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); @@ -2036,7 +2030,7 @@ bool js_cocos2dx_CCScheduler_resumeTarget(JSContext *cx, uint32_t argc, jsval *v bool js_cocos2dx_CCScheduler_isTargetPaused(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -2054,7 +2048,6 @@ bool js_cocos2dx_CCScheduler_isTargetPaused(JSContext *cx, uint32_t argc, jsval } } } while (0); -// JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); args.rval().set(BOOLEAN_TO_JSVAL(ret)); return true; } @@ -2168,7 +2161,7 @@ bool js_cocos2dx_Node_cleanup(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CCNode_setPosition(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); bool ok = true; js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); @@ -2200,7 +2193,7 @@ bool js_cocos2dx_CCNode_setPosition(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CCNode_setContentSize(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); bool ok = true; js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); @@ -2232,7 +2225,7 @@ bool js_cocos2dx_CCNode_setContentSize(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CCNode_setAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); bool ok = true; js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); @@ -2265,7 +2258,7 @@ bool js_cocos2dx_CCNode_setColor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_setColor : Invalid Native Object"); @@ -2769,7 +2762,7 @@ bool js_BezierActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); T* cobj = (T *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Bezier_initWithDuration : Invalid Native Object"); @@ -2902,7 +2895,7 @@ template bool js_CatmullRomActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); T* cobj = (T *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CatmullRom_initWithDuration : Invalid Native Object"); @@ -2918,7 +2911,6 @@ bool js_CatmullRomActions_initWithDuration(JSContext *cx, uint32_t argc, jsval * for( int i=0; i < num;i++) { arg1->addControlPoint(arr[i]); } - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CatmullRom_initWithDuration : Error processing arguments"); bool ret = cobj->initWithDuration(arg0, arg1); @@ -2964,7 +2956,7 @@ bool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc, { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CardinalSplineTo* cobj = (cocos2d::CardinalSplineTo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Invalid Native Object"); @@ -3925,15 +3917,13 @@ bool js_cocos2dx_CCLayer_init(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CCTMXLayer_getTileFlagsAt(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JSObject *obj; - TMXLayer* cobj; - obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (TMXLayer*)(proxy ? proxy->ptr : NULL); + TMXLayer* cobj = (TMXLayer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { + bool ok = true; TMXTileFlags flags; Point arg0; ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); @@ -3990,7 +3980,7 @@ bool js_cocos2dx_CCFileUtils_setSearchResolutionsOrder(JSContext *cx, uint32_t a { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4011,7 +4001,7 @@ bool js_cocos2dx_CCFileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4050,7 +4040,7 @@ bool js_cocos2dx_CCFileUtils_getDataFromFile(JSContext *cx, uint32_t argc, jsval { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4123,7 +4113,7 @@ bool js_cocos2dx_CCFileUtils_writeDataToFile(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_CCFileUtils_getSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4143,7 +4133,7 @@ static bool js_cocos2dx_FileUtils_createDictionaryWithContentsOfFile(JSContext * { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4166,7 +4156,7 @@ bool js_cocos2dx_CCGLProgram_setUniformLocationWith4f(JSContext *cx, uint32_t ar { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4211,7 +4201,7 @@ bool js_cocos2dx_CCGLProgram_setUniformLocationWithMatrixfvUnion(JSContext *cx, { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4328,7 +4318,7 @@ bool js_cocos2dx_CCGLProgram_createWithString(JSContext *cx, uint32_t argc, jsva bool js_cocos2dx_CCGLProgram_getProgram(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -4416,12 +4406,13 @@ bool js_cocos2dx_GLProgramState_setUniformVec4(JSContext *cx, uint32_t argc, jsv return false; } -#define js_cocos2dx_CCCamera_getXYZ(funcName) \ - bool ok = true; \ - JSObject *obj = JS_THIS_OBJECT(cx, vp); \ +#define js_cocos2dx_CCCamera_getXYZ(funcName) \ + bool ok = true; \ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); \ js_proxy_t *proxy = jsb_get_js_proxy(obj); \ - cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); \ - JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); \ + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); \ + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); \ if (argc == 0) { \ float x; \ float y; \ @@ -4438,13 +4429,13 @@ bool js_cocos2dx_GLProgramState_setUniformVec4(JSContext *cx, uint32_t argc, jsv JS_DefineProperty(cx, tmp, "z", DOUBLE_TO_JSVAL(z), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); \ \ if (ok) { \ - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); \ - return true; \ + args.rval().set(OBJECT_TO_JSVAL(tmp)); \ + return true; \ } \ } while (false); \ \ - JS_SET_RVAL(cx, vp, JSVAL_NULL); \ - return true; \ + args.rval().setUndefined(); \ + return true; \ } \ \ JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); \ @@ -4455,7 +4446,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec4(JSContext *cx, uint32_t argc, jsv bool js_cocos2dx_SpriteBatchNode_getDescendants(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_getDescendants : Invalid Native Object"); @@ -4483,7 +4474,7 @@ bool js_cocos2dx_NodeGrid_setGrid(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::NodeGrid* cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_NodeGrid_setGrid : Invalid Native Object"); @@ -4758,7 +4749,7 @@ bool js_cocos2dx_Label_setTTFConfig(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setTTFConfig : Invalid Native Object"); @@ -4784,9 +4775,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = NULL; cocos2d::RenderTexture* cobj = NULL; - obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_saveToFile : Invalid Native Object"); diff --git a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp index dd2bb40fc5..3f41693eb5 100644 --- a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp +++ b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp @@ -95,8 +95,7 @@ bool js_cocos2dx_CCBAnimationManager_animationCompleteCallback(JSContext *cx, ui { if (argc >= 1) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *p = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(p ? p->ptr : NULL); @@ -121,11 +120,9 @@ bool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, j { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj; - cocosbuilder::CCBReader* cobj; - obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *p = jsb_get_js_proxy(obj); - cobj = (cocosbuilder::CCBReader *)(p ? p->ptr : NULL); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(p ? p->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 2) { @@ -204,11 +201,9 @@ bool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint3 { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj; - cocosbuilder::CCBReader* cobj; - obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *p = jsb_get_js_proxy(obj); - cobj = (cocosbuilder::CCBReader *)(p ? p->ptr : NULL); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(p ? p->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 2) { diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp index 766dbd988f..20f7fc1822 100644 --- a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -102,14 +102,13 @@ void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *bone, const std::str static bool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc > 0) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - if (args.get(0).isNull()) { cobj->setMovementEventCallFunc(nullptr); @@ -149,14 +148,13 @@ static bool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx static bool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc > 0) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - if (args.get(0).isNull()) { cobj->setFrameEventCallFunc(nullptr); @@ -197,14 +195,13 @@ static bool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, u static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 3) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); @@ -249,7 +246,7 @@ static bool js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx(JSContext *c { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx : Invalid Native Object"); @@ -284,12 +281,12 @@ static bool js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx(JSContext *c bool js_cocos2dx_studio_ColliderBody_getCalculatedVertexList(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderBody* cobj = (cocostudio::ColliderBody *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 0) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); const std::vector& ret = cobj->getCalculatedVertexList(); JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); jsval jsret; diff --git a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp index 37e9cd355c..d46c0bc9a6 100644 --- a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp +++ b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp @@ -12,13 +12,13 @@ using namespace cocos2d; static bool jsb_cocos2dx_experimental_ui_VideoPlayer_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); experimental::ui::VideoPlayer* cobj = (experimental::ui::VideoPlayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); cobj->addEventListener([=](Ref* widget, experimental::ui::VideoPlayer::EventType type)->void{ jsval arg[2]; diff --git a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp index 5af9c87b7f..e58790c37a 100644 --- a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp +++ b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp @@ -11,13 +11,13 @@ using namespace cocos2d; static bool jsb_cocos2dx_experimental_webView_setOnShouldStartLoading(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); experimental::ui::WebView* cobj = (experimental::ui::WebView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); cobj->setOnShouldStartLoading([=](experimental::ui::WebView *sender, const std::string &url)->bool{ Director::getInstance()->getScheduler()->performFunctionInCocosThread([=] @@ -45,13 +45,13 @@ static bool jsb_cocos2dx_experimental_webView_setOnShouldStartLoading(JSContext static bool jsb_cocos2dx_experimental_webView_setOnDidFinishLoading(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); experimental::ui::WebView* cobj = (experimental::ui::WebView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); cobj->setOnDidFinishLoading([=](experimental::ui::WebView *sender, const std::string &url)->void{ Director::getInstance()->getScheduler()->performFunctionInCocosThread([=] @@ -78,13 +78,13 @@ static bool jsb_cocos2dx_experimental_webView_setOnDidFinishLoading(JSContext *c static bool jsb_cocos2dx_experimental_webView_setOnDidFailLoading(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); experimental::ui::WebView* cobj = (experimental::ui::WebView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); cobj->setOnDidFailLoading([=](experimental::ui::WebView *sender, const std::string &url)->void{ Director::getInstance()->getScheduler()->performFunctionInCocosThread([=] @@ -111,13 +111,13 @@ static bool jsb_cocos2dx_experimental_webView_setOnDidFailLoading(JSContext *cx, static bool jsb_cocos2dx_experimental_webView_setOnJSCallback(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); experimental::ui::WebView* cobj = (experimental::ui::WebView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if(argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); cobj->setOnJSCallback([=](experimental::ui::WebView *sender, const std::string &url)->void{ Director::getInstance()->getScheduler()->performFunctionInCocosThread([=] diff --git a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp index 0649aa9082..9b7a9663b0 100644 --- a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp +++ b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp @@ -104,12 +104,12 @@ void js_cocos2dx_GLNode_finalize(JSFreeOp *fop, JSObject *obj) { static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); cocos2d::GLNode *nobj = new cocos2d::GLNode(); js_proxy_t* p = jsb_new_proxy(nobj, obj); nobj->autorelease(); JS::AddNamedObjectRoot(cx, &p->obj, "GLNode"); - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().setUndefined(); return true; } diff --git a/cocos/scripting/js-bindings/manual/jsb_helper.h b/cocos/scripting/js-bindings/manual/jsb_helper.h index 72cc68f551..dfd6ef1448 100644 --- a/cocos/scripting/js-bindings/manual/jsb_helper.h +++ b/cocos/scripting/js-bindings/manual/jsb_helper.h @@ -54,7 +54,8 @@ bool klass::_js_constructor(JSContext *cx, unsigned argc, jsval *vp) #define JS_BINDED_FUNC_IMPL(klass, name) \ static bool klass##_func_##name(JSContext *cx, unsigned argc, jsval *vp) { \ -JSObject* thisObj = JS_THIS_OBJECT(cx, vp); \ +JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ +JS::RootedObject thisObj(cx, args.thisv().toObjectOrNull()); \ klass* obj = (klass*)JS_GetPrivate(thisObj); \ if (obj) { \ return obj->name(cx, argc, vp); \ @@ -82,7 +83,7 @@ bool _js_get_##propName(JSContext *cx, const JS::CallArgs& args) #define JS_BINDED_PROP_GET_IMPL(klass, propName) \ static bool _js_get_##klass##_##propName(JSContext *cx, unsigned argc, jsval *vp) { \ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ -JSObject* obj = args.thisv().toObjectOrNull(); \ +JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); \ klass* cobj = (klass*)JS_GetPrivate(obj); \ if (cobj) { \ return cobj->_js_get_##propName(cx, args); \ @@ -98,7 +99,7 @@ bool _js_set_##propName(JSContext *cx, const JS::CallArgs& args) #define JS_BINDED_PROP_SET_IMPL(klass, propName) \ static bool _js_set_##klass##_##propName(JSContext *cx, unsigned argc, jsval *vp) { \ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ -JSObject* obj = args.thisv().toObjectOrNull(); \ +JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); \ klass* cobj = (klass*)JS_GetPrivate(obj); \ if (cobj) { \ return cobj->_js_set_##propName(cx, args); \ diff --git a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp index 6a6539958f..313cee7be4 100644 --- a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp +++ b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp @@ -34,7 +34,8 @@ THE SOFTWARE. static bool jsb_cocos2dx_navmesh_NavMeshAgent_move(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, 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::NavMeshAgent* cobj = (cocos2d::NavMeshAgent *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2(cobj, cx, false, "Invalid Native Object"); @@ -42,7 +43,6 @@ static bool jsb_cocos2dx_navmesh_NavMeshAgent_move(JSContext *cx, uint32_t argc, bool ok = true; if (argc == 1){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cocos2d::Vec3 arg0; ok &= jsval_to_vector3(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "jsb_cocos2dx_navmesh_NavMeshAgent_move : Error processing arguments"); @@ -51,7 +51,6 @@ static bool jsb_cocos2dx_navmesh_NavMeshAgent_move(JSContext *cx, uint32_t argc, } if (argc == 2){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cocos2d::Vec3 arg0; ok &= jsval_to_vector3(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "jsb_cocos2dx_navmesh_NavMeshAgent_move : Error processing arguments"); diff --git a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp index b2874ae641..309f09b0ac 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp @@ -193,7 +193,7 @@ bool js_cocos2dx_SocketIO_send(JSContext* cx, uint32_t argc, jsval* vp) CCLOG("JSB SocketIO.send method called"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -223,7 +223,7 @@ bool js_cocos2dx_SocketIO_emit(JSContext* cx, uint32_t argc, jsval* vp) CCLOG("JSB SocketIO.emit method called"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -257,7 +257,7 @@ bool js_cocos2dx_SocketIO_disconnect(JSContext* cx, uint32_t argc, jsval* vp) CCLOG("JSB SocketIO.disconnect method called"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -340,7 +340,7 @@ bool js_cocos2dx_SocketIO_on(JSContext* cx, uint32_t argc, jsval* vp) CCLOG("JSB SocketIO.on method called"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); diff --git a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp index d78b7cd105..4e293e4da8 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp @@ -181,7 +181,7 @@ void js_cocos2dx_WebSocket_finalize(JSFreeOp *fop, JSObject *obj) { bool js_cocos2dx_extension_WebSocket_send(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -235,7 +235,7 @@ bool js_cocos2dx_extension_WebSocket_send(JSContext *cx, uint32_t argc, jsval *v bool js_cocos2dx_extension_WebSocket_close(JSContext *cx, uint32_t argc, jsval *vp){ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); diff --git a/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp index ec43c482e8..79147fce85 100644 --- a/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp +++ b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp @@ -292,7 +292,7 @@ bool jsb_cocos2dx_spine_findBone(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -321,7 +321,7 @@ bool jsb_cocos2dx_spine_findSlot(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -349,7 +349,7 @@ bool jsb_cocos2dx_spine_findSlot(JSContext *cx, uint32_t argc, jsval *vp) bool jsb_cocos2dx_spine_setDebugBones(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -368,7 +368,7 @@ bool jsb_cocos2dx_spine_setDebugBones(JSContext *cx, uint32_t argc, jsval *vp) bool jsb_cocos2dx_spine_setDebugSolots(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -388,7 +388,7 @@ bool jsb_cocos2dx_spine_getAttachment(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); SkeletonRenderer* cobj = (SkeletonRenderer*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -419,7 +419,7 @@ bool jsb_cocos2dx_spine_getCurrent(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -461,7 +461,7 @@ bool jsb_cocos2dx_spine_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -498,7 +498,7 @@ bool jsb_cocos2dx_spine_addAnimation(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); diff --git a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp index 929d897453..e63f5ba13d 100755 --- a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp @@ -31,19 +31,18 @@ using namespace cocos2d::ui; static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); ui::LayoutParameter* cobj = (ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 1) { - JS::CallArgs argv = CallArgsFromVp(argc, vp); - JS::RootedObject tmp(cx); JS::RootedValue jsleft(cx), jstop(cx),jsright(cx),jsbottom(cx); double left, top,right,bottom; - bool ok = argv[0].isObject() && - JS_ValueToObject(cx, argv[0], &tmp) && + bool ok = args[0].isObject() && + JS_ValueToObject(cx, args[0], &tmp) && JS_GetProperty(cx, tmp, "left", &jsleft) && JS_GetProperty(cx, tmp, "top", &jstop) && JS_GetProperty(cx, tmp, "right", &jsright) && @@ -60,13 +59,12 @@ static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, return true; } else if (argc == 4) { - JS::CallArgs argv = CallArgsFromVp(argc, vp); bool ok = true; double left, top,right,bottom; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &left); - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &top); - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &right); - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[3]), &bottom); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[0]), &left); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[1]), &top); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[2]), &right); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[3]), &bottom); JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); @@ -79,13 +77,13 @@ static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, static bool js_cocos2dx_LayoutParameter_getMargin(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); ui::LayoutParameter* cobj = (ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 0) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); if (!tmp) return false; ui::Margin margin = cobj->getMargin(); @@ -95,7 +93,6 @@ static bool js_cocos2dx_LayoutParameter_getMargin(JSContext *cx, uint32_t argc, JS_DefineProperty(cx, tmp, "bottom", margin.bottom, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { - //JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); args.rval().set(OBJECT_TO_JSVAL(tmp)); } else From 82feb314f61fb482e5d9f3b13d183a23c589e5ec Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 25 Nov 2015 09:21:44 +0000 Subject: [PATCH 131/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index c563e37b4c..9ecf2ac219 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -187,6 +187,7 @@ "cocos/2d/CCTweenFunction.cpp", "cocos/2d/CCTweenFunction.h", "cocos/2d/CMakeLists.txt", + "cocos/2d/CocosStudioExtension.h", "cocos/2d/cocos2d.def", "cocos/2d/cocos2d_headers.props", "cocos/2d/cocos2dx.props", From 06c7b9444081ef393c26e69aa432a85573f6b341 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 25 Nov 2015 09:28:43 +0000 Subject: [PATCH 132/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_ui_auto_api.js | 404 +++- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 852 +++++-- .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 46 +- .../auto/api/AbstractCheckButton.lua | 30 + .../lua-bindings/auto/api/Button.lua | 36 + .../lua-bindings/auto/api/ImageView.lua | 6 + .../lua-bindings/auto/api/Layout.lua | 6 + .../lua-bindings/auto/api/LoadingBar.lua | 6 + .../lua-bindings/auto/api/Scale9Sprite.lua | 6 + .../lua-bindings/auto/api/Slider.lua | 200 +- .../lua-bindings/auto/api/TextAtlas.lua | 6 + .../lua-bindings/auto/api/TextBMFont.lua | 24 +- .../auto/lua_cocos2dx_ui_auto.cpp | 2126 ++++++++++++----- .../auto/lua_cocos2dx_ui_auto.hpp | 22 + 14 files changed, 2812 insertions(+), 958 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index ef1bdc4d44..a1ac1bd1b4 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -1024,6 +1024,16 @@ getClippingType : function ( return 0; }, +/** + * @method getRenderFile + * @return {cc.ResouceData} + */ +getRenderFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method isLoopFocus * @return {bool} @@ -1348,6 +1358,14 @@ float { }, +/** + * @method resetPressedRender + */ +resetPressedRender : function ( +) +{ +}, + /** * @method setScale9Enabled * @param {bool} arg0 @@ -1358,6 +1376,14 @@ bool { }, +/** + * @method resetDisabledRender + */ +resetDisabledRender : function ( +) +{ +}, + /** * @method getTitleRenderer * @return {cc.Label} @@ -1378,6 +1404,16 @@ getRendererClicked : function ( return ccui.Scale9Sprite; }, +/** + * @method getDisabledFile + * @return {cc.ResouceData} + */ +getDisabledFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method getZoomScale * @return {float} @@ -1408,6 +1444,24 @@ color3b { }, +/** + * @method getNormalFile + * @return {cc.ResouceData} + */ +getNormalFile : function ( +) +{ + return cc.ResouceData; +}, + +/** + * @method resetNormalRender + */ +resetNormalRender : function ( +) +{ +}, + /** * @method getRendererDisabled * @return {ccui.Scale9Sprite} @@ -1590,6 +1644,16 @@ rect { }, +/** + * @method getPressedFile + * @return {cc.ResouceData} + */ +getPressedFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method getTitleFontSize * @return {float} @@ -1694,6 +1758,26 @@ Button : function ( */ ccui.AbstractCheckButton = { +/** + * @method getBackDisabledFile + * @return {cc.ResouceData} + */ +getBackDisabledFile : function ( +) +{ + return cc.ResouceData; +}, + +/** + * @method getCrossDisabeldFile + * @return {cc.ResouceData} + */ +getCrossDisabeldFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method loadTextureBackGroundSelected * @param {String} arg0 @@ -1718,6 +1802,16 @@ texturerestype { }, +/** + * @method getCrossNormalFile + * @return {cc.ResouceData} + */ +getCrossNormalFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method setSelected * @param {bool} arg0 @@ -1728,6 +1822,16 @@ bool { }, +/** + * @method getBackPressedFile + * @return {cc.ResouceData} + */ +getBackPressedFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method getRendererFrontCrossDisabled * @return {cc.Sprite} @@ -1802,6 +1906,16 @@ texturerestype return false; }, +/** + * @method getBackNormalFile + * @return {cc.ResouceData} + */ +getBackNormalFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method loadTextures * @param {String} arg0 @@ -2171,6 +2285,16 @@ rect { }, +/** + * @method getRenderFile + * @return {cc.ResouceData} + */ +getRenderFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method getCapInsets * @return {rect_object} @@ -2549,6 +2673,16 @@ str { }, +/** + * @method getRenderFile + * @return {cc.ResouceData} + */ +getRenderFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method setProperty * @param {String} arg0 @@ -2653,6 +2787,16 @@ direction { }, +/** + * @method getRenderFile + * @return {cc.ResouceData} + */ +getRenderFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method setScale9Enabled * @param {bool} arg0 @@ -3645,16 +3789,6 @@ ListView : function ( */ ccui.Slider = { -/** - * @method setMaxPercent - * @param {int} arg0 - */ -setMaxPercent : function ( -int -) -{ -}, - /** * @method setPercent * @param {int} arg0 @@ -3665,18 +3799,6 @@ int { }, -/** - * @method loadSlidBallTextureDisabled - * @param {String} arg0 - * @param {ccui.Widget::TextureResType} arg1 - */ -loadSlidBallTextureDisabled : function ( -str, -texturerestype -) -{ -}, - /** * @method getMaxPercent * @return {int} @@ -3699,18 +3821,6 @@ texturerestype { }, -/** - * @method loadBarTexture - * @param {String} arg0 - * @param {ccui.Widget::TextureResType} arg1 - */ -loadBarTexture : function ( -str, -texturerestype -) -{ -}, - /** * @method loadProgressBarTexture * @param {String} arg0 @@ -3724,39 +3834,13 @@ texturerestype }, /** - * @method loadSlidBallTextures - * @param {String} arg0 - * @param {String} arg1 - * @param {String} arg2 - * @param {ccui.Widget::TextureResType} arg3 + * @method getBallNormalFile + * @return {cc.ResouceData} */ -loadSlidBallTextures : function ( -str, -str, -str, -texturerestype -) -{ -}, - -/** - * @method setCapInsetProgressBarRebderer - * @param {rect_object} arg0 - */ -setCapInsetProgressBarRebderer : function ( -rect -) -{ -}, - -/** - * @method setCapInsetsBarRenderer - * @param {rect_object} arg0 - */ -setCapInsetsBarRenderer : function ( -rect +getBallNormalFile : function ( ) { + return cc.ResouceData; }, /** @@ -3780,23 +3864,13 @@ bool }, /** - * @method setZoomScale - * @param {float} arg0 + * @method getBallPressedFile + * @return {cc.ResouceData} */ -setZoomScale : function ( -float -) -{ -}, - -/** - * @method setCapInsets - * @param {rect_object} arg0 - */ -setCapInsets : function ( -rect +getBallPressedFile : function ( ) { + return cc.ResouceData; }, /** @@ -3809,6 +3883,64 @@ getZoomScale : function ( return 0; }, +/** + * @method loadSlidBallTextures + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {ccui.Widget::TextureResType} arg3 + */ +loadSlidBallTextures : function ( +str, +str, +str, +texturerestype +) +{ +}, + +/** + * @method setMaxPercent + * @param {int} arg0 + */ +setMaxPercent : function ( +int +) +{ +}, + +/** + * @method loadBarTexture + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadBarTexture : function ( +str, +texturerestype +) +{ +}, + +/** + * @method getProgressBarFile + * @return {cc.ResouceData} + */ +getProgressBarFile : function ( +) +{ + return cc.ResouceData; +}, + +/** + * @method getCapInsetsBarRenderer + * @return {rect_object} + */ +getCapInsetsBarRenderer : function ( +) +{ + return cc.Rect; +}, + /** * @method loadSlidBallTexturePressed * @param {String} arg0 @@ -3821,6 +3953,16 @@ texturerestype { }, +/** + * @method getBackFile + * @return {cc.ResouceData} + */ +getBackFile : function ( +) +{ + return cc.ResouceData; +}, + /** * @method isScale9Enabled * @return {bool} @@ -3832,13 +3974,33 @@ isScale9Enabled : function ( }, /** - * @method getCapInsetsBarRenderer - * @return {rect_object} + * @method setCapInsetProgressBarRebderer + * @param {rect_object} arg0 */ -getCapInsetsBarRenderer : function ( +setCapInsetProgressBarRebderer : function ( +rect ) { - return cc.Rect; +}, + +/** + * @method setCapInsetsBarRenderer + * @param {rect_object} arg0 + */ +setCapInsetsBarRenderer : function ( +rect +) +{ +}, + +/** + * @method getBallDisabeldFile + * @return {cc.ResouceData} + */ +getBallDisabeldFile : function ( +) +{ + return cc.ResouceData; }, /** @@ -3851,6 +4013,38 @@ getPercent : function ( return 0; }, +/** + * @method setCapInsets + * @param {rect_object} arg0 + */ +setCapInsets : function ( +rect +) +{ +}, + +/** + * @method loadSlidBallTextureDisabled + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadSlidBallTextureDisabled : function ( +str, +texturerestype +) +{ +}, + +/** + * @method setZoomScale + * @param {float} arg0 + */ +setZoomScale : function ( +float +) +{ +}, + /** * @method create * @param {String} str @@ -4625,16 +4819,6 @@ TextField : function ( */ ccui.TextBMFont = { -/** - * @method setFntFile - * @param {String} arg0 - */ -setFntFile : function ( -str -) -{ -}, - /** * @method getStringLength * @return {long} @@ -4645,6 +4829,16 @@ getStringLength : function ( return 0; }, +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + /** * @method setString * @param {String} arg0 @@ -4656,13 +4850,23 @@ str }, /** - * @method getString - * @return {String} + * @method getRenderFile + * @return {cc.ResouceData} */ -getString : function ( +getRenderFile : function ( +) +{ + return cc.ResouceData; +}, + +/** + * @method setFntFile + * @param {String} arg0 + */ +setFntFile : function ( +str ) { - return ; }, /** @@ -5682,6 +5886,14 @@ isScale9Enabled : function ( return false; }, +/** + * @method resetRender + */ +resetRender : function ( +) +{ +}, + /** * @method getRenderingType * @return {ccui.Scale9Sprite::RenderingType} diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 5806452cd8..1523739391 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -2516,6 +2516,24 @@ bool js_cocos2dx_ui_Layout_getClippingType(JSContext *cx, uint32_t argc, jsval * JS_ReportError(cx, "js_cocos2dx_ui_Layout_getClippingType : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Layout_getRenderFile(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::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getRenderFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getRenderFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getRenderFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Layout_isLoopFocus(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -3142,6 +3160,7 @@ void js_register_cocos2dx_ui_Layout(JSContext *cx, JS::HandleObject global) { JS_FN("setBackGroundImageColor", js_cocos2dx_ui_Layout_setBackGroundImageColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackGroundColorVector", js_cocos2dx_ui_Layout_getBackGroundColorVector, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getClippingType", js_cocos2dx_ui_Layout_getClippingType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderFile", js_cocos2dx_ui_Layout_getRenderFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isLoopFocus", js_cocos2dx_ui_Layout_isLoopFocus, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeBackGroundImage", js_cocos2dx_ui_Layout_removeBackGroundImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackGroundColorOpacity", js_cocos2dx_ui_Layout_getBackGroundColorOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -3266,6 +3285,22 @@ bool js_cocos2dx_ui_Button_setTitleFontSize(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_ui_Button_setTitleFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Button_resetPressedRender(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::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_resetPressedRender : Invalid Native Object"); + if (argc == 0) { + cobj->resetPressedRender(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_resetPressedRender : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Button_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -3286,6 +3321,22 @@ bool js_cocos2dx_ui_Button_setScale9Enabled(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_ui_Button_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Button_resetDisabledRender(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::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_resetDisabledRender : Invalid Native Object"); + if (argc == 0) { + cobj->resetDisabledRender(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_resetDisabledRender : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Button_getTitleRenderer(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -3336,6 +3387,24 @@ bool js_cocos2dx_ui_Button_getRendererClicked(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_ui_Button_getRendererClicked : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Button_getDisabledFile(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::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getDisabledFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getDisabledFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getDisabledFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Button_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -3392,6 +3461,40 @@ bool js_cocos2dx_ui_Button_setTitleColor(JSContext *cx, uint32_t argc, jsval *vp JS_ReportError(cx, "js_cocos2dx_ui_Button_setTitleColor : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Button_getNormalFile(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::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getNormalFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getNormalFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getNormalFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_resetNormalRender(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::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_resetNormalRender : Invalid Native Object"); + if (argc == 0) { + cobj->resetNormalRender(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_resetNormalRender : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Button_getRendererDisabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -3832,6 +3935,24 @@ bool js_cocos2dx_ui_Button_setCapInsetsPressedRenderer(JSContext *cx, uint32_t a JS_ReportError(cx, "js_cocos2dx_ui_Button_setCapInsetsPressedRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Button_getPressedFile(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::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getPressedFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getPressedFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getPressedFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Button_getTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4162,12 +4283,17 @@ void js_register_cocos2dx_ui_Button(JSContext *cx, JS::HandleObject global) { JS_FN("getNormalTextureSize", js_cocos2dx_ui_Button_getNormalTextureSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleText", js_cocos2dx_ui_Button_getTitleText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleFontSize", js_cocos2dx_ui_Button_setTitleFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetPressedRender", js_cocos2dx_ui_Button_resetPressedRender, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_ui_Button_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetDisabledRender", js_cocos2dx_ui_Button_resetDisabledRender, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleRenderer", js_cocos2dx_ui_Button_getTitleRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRendererClicked", js_cocos2dx_ui_Button_getRendererClicked, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisabledFile", js_cocos2dx_ui_Button_getDisabledFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_ui_Button_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsetsDisabledRenderer", js_cocos2dx_ui_Button_getCapInsetsDisabledRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleColor", js_cocos2dx_ui_Button_setTitleColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNormalFile", js_cocos2dx_ui_Button_getNormalFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetNormalRender", js_cocos2dx_ui_Button_resetNormalRender, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRendererDisabled", js_cocos2dx_ui_Button_getRendererDisabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetsDisabledRenderer", js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_ui_Button_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -4184,6 +4310,7 @@ void js_register_cocos2dx_ui_Button(JSContext *cx, JS::HandleObject global) { JS_FN("isScale9Enabled", js_cocos2dx_ui_Button_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureNormal", js_cocos2dx_ui_Button_loadTextureNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetsPressedRenderer", js_cocos2dx_ui_Button_setCapInsetsPressedRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPressedFile", js_cocos2dx_ui_Button_getPressedFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleFontSize", js_cocos2dx_ui_Button_getTitleFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRendererNormal", js_cocos2dx_ui_Button_getRendererNormal, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleFontName", js_cocos2dx_ui_Button_getTitleFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -4232,6 +4359,42 @@ void js_register_cocos2dx_ui_Button(JSContext *cx, JS::HandleObject global) { JSClass *jsb_cocos2d_ui_AbstractCheckButton_class; JSObject *jsb_cocos2d_ui_AbstractCheckButton_prototype; +bool js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile(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::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getBackDisabledFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile(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::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getCrossDisabeldFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4292,6 +4455,24 @@ bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled(JSContext JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile(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::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getCrossNormalFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_AbstractCheckButton_setSelected(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4312,6 +4493,24 @@ bool js_cocos2dx_ui_AbstractCheckButton_setSelected(JSContext *cx, uint32_t argc JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_setSelected : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile(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::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getBackPressedFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4485,6 +4684,24 @@ bool js_cocos2dx_ui_AbstractCheckButton_init(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_init : wrong number of arguments: %d, was expecting %d", argc, 5); return false; } +bool js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile(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::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getBackNormalFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_AbstractCheckButton_loadTextures(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4704,15 +4921,20 @@ void js_register_cocos2dx_ui_AbstractCheckButton(JSContext *cx, JS::HandleObject }; static JSFunctionSpec funcs[] = { + JS_FN("getBackDisabledFile", js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCrossDisabeldFile", js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureBackGroundSelected", js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureBackGroundDisabled", js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCrossNormalFile", js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelected", js_cocos2dx_ui_AbstractCheckButton_setSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackPressedFile", js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRendererFrontCrossDisabled", js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRendererBackground", js_cocos2dx_ui_AbstractCheckButton_getRendererBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureFrontCross", js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRendererBackgroundDisabled", js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSelected", js_cocos2dx_ui_AbstractCheckButton_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_ui_AbstractCheckButton_init, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackNormalFile", js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextures", js_cocos2dx_ui_AbstractCheckButton_loadTextures, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_ui_AbstractCheckButton_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRendererFrontCross", js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -5821,6 +6043,24 @@ bool js_cocos2dx_ui_ImageView_setCapInsets(JSContext *cx, uint32_t argc, jsval * JS_ReportError(cx, "js_cocos2dx_ui_ImageView_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_ImageView_getRenderFile(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::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_getRenderFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getRenderFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_getRenderFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_ImageView_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6017,6 +6257,7 @@ void js_register_cocos2dx_ui_ImageView(JSContext *cx, JS::HandleObject global) { JS_FN("setScale9Enabled", js_cocos2dx_ui_ImageView_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureRect", js_cocos2dx_ui_ImageView_setTextureRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_ui_ImageView_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderFile", js_cocos2dx_ui_ImageView_getRenderFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsets", js_cocos2dx_ui_ImageView_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isScale9Enabled", js_cocos2dx_ui_ImageView_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_ImageView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -6836,6 +7077,24 @@ bool js_cocos2dx_ui_TextAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_setString : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_TextAtlas_getRenderFile(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::ui::TextAtlas* cobj = (cocos2d::ui::TextAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextAtlas_getRenderFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getRenderFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_getRenderFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_TextAtlas_setProperty(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -7028,6 +7287,7 @@ void js_register_cocos2dx_ui_TextAtlas(JSContext *cx, JS::HandleObject global) { JS_FN("getStringLength", js_cocos2dx_ui_TextAtlas_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_ui_TextAtlas_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_ui_TextAtlas_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderFile", js_cocos2dx_ui_TextAtlas_getRenderFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProperty", js_cocos2dx_ui_TextAtlas_setProperty, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("adaptRenderers", js_cocos2dx_ui_TextAtlas_adaptRenderers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_TextAtlas_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -7142,6 +7402,24 @@ bool js_cocos2dx_ui_LoadingBar_setDirection(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_LoadingBar_getRenderFile(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::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_getRenderFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getRenderFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_getRenderFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_LoadingBar_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -7460,6 +7738,7 @@ void js_register_cocos2dx_ui_LoadingBar(JSContext *cx, JS::HandleObject global) JS_FN("setPercent", js_cocos2dx_ui_LoadingBar_setPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTexture", js_cocos2dx_ui_LoadingBar_loadTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDirection", js_cocos2dx_ui_LoadingBar_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderFile", js_cocos2dx_ui_LoadingBar_getRenderFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_ui_LoadingBar_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_ui_LoadingBar_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDirection", js_cocos2dx_ui_LoadingBar_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -9547,26 +9826,6 @@ void js_register_cocos2dx_ui_ListView(JSContext *cx, JS::HandleObject global) { JSClass *jsb_cocos2d_ui_Slider_class; JSObject *jsb_cocos2d_ui_Slider_prototype; -bool js_cocos2dx_ui_Slider_setMaxPercent(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setMaxPercent : Invalid Native Object"); - if (argc == 1) { - int arg0 = 0; - ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setMaxPercent : Error processing arguments"); - cobj->setMaxPercent(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_setMaxPercent : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_ui_Slider_setPercent(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9587,36 +9846,6 @@ bool js_cocos2dx_ui_Slider_setPercent(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Slider_setPercent : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : 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_ui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); - cobj->loadSlidBallTextureDisabled(arg0); - args.rval().setUndefined(); - return true; - } - if (argc == 2) { - std::string arg0; - cocos2d::ui::Widget::TextureResType arg1; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); - cobj->loadSlidBallTextureDisabled(arg0, arg1); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_ui_Slider_getMaxPercent(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9665,36 +9894,6 @@ bool js_cocos2dx_ui_Slider_loadSlidBallTextureNormal(JSContext *cx, uint32_t arg JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextureNormal : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_Slider_loadBarTexture(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadBarTexture : 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_ui_Slider_loadBarTexture : Error processing arguments"); - cobj->loadBarTexture(arg0); - args.rval().setUndefined(); - return true; - } - if (argc == 2) { - std::string arg0; - cocos2d::ui::Widget::TextureResType arg1; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadBarTexture : Error processing arguments"); - cobj->loadBarTexture(arg0, arg1); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadBarTexture : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_ui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9725,6 +9924,98 @@ bool js_cocos2dx_ui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadProgressBarTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Slider_getBallNormalFile(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getBallNormalFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getBallNormalFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getBallNormalFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRebderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_setScale9Enabled(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setScale9Enabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setScale9Enabled : Error processing arguments"); + cobj->setScale9Enabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_getBallPressedFile(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getBallPressedFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getBallPressedFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getBallPressedFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_getZoomScale(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getZoomScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getZoomScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9781,6 +10072,158 @@ bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextures : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Slider_setMaxPercent(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setMaxPercent : Invalid Native Object"); + if (argc == 1) { + int arg0 = 0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setMaxPercent : Error processing arguments"); + cobj->setMaxPercent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setMaxPercent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_loadBarTexture(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadBarTexture : 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_ui_Slider_loadBarTexture : Error processing arguments"); + cobj->loadBarTexture(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadBarTexture : Error processing arguments"); + cobj->loadBarTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadBarTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_getProgressBarFile(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getProgressBarFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getProgressBarFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getProgressBarFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_getCapInsetsBarRenderer(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsBarRenderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsBarRenderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : 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_ui_Slider_loadSlidBallTexturePressed : Error processing arguments"); + cobj->loadSlidBallTexturePressed(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : Error processing arguments"); + cobj->loadSlidBallTexturePressed(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_getBackFile(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getBackFile : Invalid Native Object"); + if (argc == 0) { + cocos2d::ResouceData ret = cobj->getBackFile(); + jsval jsret = JSVAL_NULL; + jsret = resoucedata_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getBackFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_isScale9Enabled(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_isScale9Enabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isScale9Enabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9821,62 +10264,40 @@ bool js_cocos2dx_ui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_ui_Slider_setCapInsetsBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Slider_getBallDisabeldFile(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getBallDisabeldFile : Invalid Native Object"); if (argc == 0) { - const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRebderer(); + cocos2d::ResouceData ret = cobj->getBallDisabeldFile(); jsval jsret = JSVAL_NULL; - jsret = ccrect_to_jsval(cx, ret); + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getBallDisabeldFile : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Slider_getPercent(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setScale9Enabled : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setScale9Enabled : Error processing arguments"); - cobj->setScale9Enabled(arg0); - args.rval().setUndefined(); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getPercent : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getPercent(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Slider_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_ui_Slider_setZoomScale(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setZoomScale : Invalid Native Object"); - if (argc == 1) { - double arg0 = 0; - ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setZoomScale : Error processing arguments"); - cobj->setZoomScale(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_setZoomScale : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getPercent : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_ui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) @@ -9899,37 +10320,19 @@ bool js_cocos2dx_ui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Slider_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_Slider_getZoomScale(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getZoomScale : Invalid Native Object"); - if (argc == 0) { - double ret = cobj->getZoomScale(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : 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_ui_Slider_loadSlidBallTexturePressed : Error processing arguments"); - cobj->loadSlidBallTexturePressed(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); + cobj->loadSlidBallTextureDisabled(arg0); args.rval().setUndefined(); return true; } @@ -9938,67 +10341,33 @@ bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t ar cocos2d::ui::Widget::TextureResType arg1; ok &= jsval_to_std_string(cx, args.get(0), &arg0); ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : Error processing arguments"); - cobj->loadSlidBallTexturePressed(arg0, arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); + cobj->loadSlidBallTextureDisabled(arg0, arg1); args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_Slider_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Slider_setZoomScale(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_isScale9Enabled : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isScale9Enabled(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setZoomScale : Invalid Native Object"); + if (argc == 1) { + double arg0 = 0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setZoomScale : Error processing arguments"); + cobj->setZoomScale(arg0); + args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Slider_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_Slider_getCapInsetsBarRenderer(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsBarRenderer : Invalid Native Object"); - if (argc == 0) { - const cocos2d::Rect& ret = cobj->getCapInsetsBarRenderer(); - jsval jsret = JSVAL_NULL; - jsret = ccrect_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ui_Slider_getPercent(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getPercent : Invalid Native Object"); - if (argc == 0) { - int ret = cobj->getPercent(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_getPercent : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setZoomScale : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_ui_Slider_create(JSContext *cx, uint32_t argc, jsval *vp) @@ -10162,25 +10531,30 @@ void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { - JS_FN("setMaxPercent", js_cocos2dx_ui_Slider_setMaxPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPercent", js_cocos2dx_ui_Slider_setPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadSlidBallTextureDisabled", js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxPercent", js_cocos2dx_ui_Slider_getMaxPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTextureNormal", js_cocos2dx_ui_Slider_loadSlidBallTextureNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadBarTexture", js_cocos2dx_ui_Slider_loadBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadProgressBarTexture", js_cocos2dx_ui_Slider_loadProgressBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadSlidBallTextures", js_cocos2dx_ui_Slider_loadSlidBallTextures, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCapInsetProgressBarRebderer", js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCapInsetsBarRenderer", js_cocos2dx_ui_Slider_setCapInsetsBarRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBallNormalFile", js_cocos2dx_ui_Slider_getBallNormalFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsetsProgressBarRebderer", js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_ui_Slider_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setZoomScale", js_cocos2dx_ui_Slider_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCapInsets", js_cocos2dx_ui_Slider_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBallPressedFile", js_cocos2dx_ui_Slider_getBallPressedFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_ui_Slider_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadSlidBallTexturePressed", js_cocos2dx_ui_Slider_loadSlidBallTexturePressed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isScale9Enabled", js_cocos2dx_ui_Slider_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadSlidBallTextures", js_cocos2dx_ui_Slider_loadSlidBallTextures, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxPercent", js_cocos2dx_ui_Slider_setMaxPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadBarTexture", js_cocos2dx_ui_Slider_loadBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProgressBarFile", js_cocos2dx_ui_Slider_getProgressBarFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsetsBarRenderer", js_cocos2dx_ui_Slider_getCapInsetsBarRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadSlidBallTexturePressed", js_cocos2dx_ui_Slider_loadSlidBallTexturePressed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackFile", js_cocos2dx_ui_Slider_getBackFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScale9Enabled", js_cocos2dx_ui_Slider_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetProgressBarRebderer", js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetsBarRenderer", js_cocos2dx_ui_Slider_setCapInsetsBarRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBallDisabeldFile", js_cocos2dx_ui_Slider_getBallDisabeldFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPercent", js_cocos2dx_ui_Slider_getPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsets", js_cocos2dx_ui_Slider_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadSlidBallTextureDisabled", js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZoomScale", js_cocos2dx_ui_Slider_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_Slider_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -11881,26 +12255,6 @@ void js_register_cocos2dx_ui_TextField(JSContext *cx, JS::HandleObject global) { JSClass *jsb_cocos2d_ui_TextBMFont_class; JSObject *jsb_cocos2d_ui_TextBMFont_prototype; -bool js_cocos2dx_ui_TextBMFont_setFntFile(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::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_setFntFile : 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_ui_TextBMFont_setFntFile : Error processing arguments"); - cobj->setFntFile(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_setFntFile : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_ui_TextBMFont_getStringLength(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -11919,6 +12273,24 @@ bool js_cocos2dx_ui_TextBMFont_getStringLength(JSContext *cx, uint32_t argc, jsv JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_getStringLength : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_TextBMFont_getString(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::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_TextBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -11939,22 +12311,42 @@ bool js_cocos2dx_ui_TextBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_setString : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_TextBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_TextBMFont_getRenderFile(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::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_getString : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_getRenderFile : Invalid Native Object"); if (argc == 0) { - const std::string& ret = cobj->getString(); + cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = std_string_to_jsval(cx, ret); + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_getRenderFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextBMFont_setFntFile(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::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_setFntFile : 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_ui_TextBMFont_setFntFile : Error processing arguments"); + cobj->setFntFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_setFntFile : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_ui_TextBMFont_create(JSContext *cx, uint32_t argc, jsval *vp) @@ -12093,10 +12485,11 @@ void js_register_cocos2dx_ui_TextBMFont(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { - JS_FN("setFntFile", js_cocos2dx_ui_TextBMFont_setFntFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringLength", js_cocos2dx_ui_TextBMFont_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setString", js_cocos2dx_ui_TextBMFont_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_ui_TextBMFont_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_ui_TextBMFont_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderFile", js_cocos2dx_ui_TextBMFont_getRenderFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFntFile", js_cocos2dx_ui_TextBMFont_setFntFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_TextBMFont_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -15071,6 +15464,22 @@ bool js_cocos2dx_ui_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, j JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Scale9Sprite_resetRender(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::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_resetRender : Invalid Native Object"); + if (argc == 0) { + cobj->resetRender(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_resetRender : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Scale9Sprite_getRenderingType(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -15736,6 +16145,7 @@ void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JS::HandleObject global JS_FN("getInsetBottom", js_cocos2dx_ui_Scale9Sprite_getInsetBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsets", js_cocos2dx_ui_Scale9Sprite_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isScale9Enabled", js_cocos2dx_ui_Scale9Sprite_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetRender", js_cocos2dx_ui_Scale9Sprite_resetRender, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRenderingType", js_cocos2dx_ui_Scale9Sprite_getRenderingType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInsetRight", js_cocos2dx_ui_Scale9Sprite_getInsetRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOriginalSize", js_cocos2dx_ui_Scale9Sprite_getOriginalSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index e90d2a5ace..5ff1f071f9 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -141,6 +141,7 @@ bool js_cocos2dx_ui_Layout_setLoopFocus(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_ui_Layout_setBackGroundImageColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Layout_getBackGroundColorVector(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Layout_getClippingType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Layout_isLoopFocus(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Layout_removeBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Layout_getBackGroundColorOpacity(JSContext *cx, uint32_t argc, jsval *vp); @@ -181,12 +182,17 @@ void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_ui_Button_getNormalTextureSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getTitleText(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_setTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_resetPressedRender(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_resetDisabledRender(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getTitleRenderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getRendererClicked(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getDisabledFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_setTitleColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getNormalFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_resetNormalRender(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getRendererDisabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); @@ -203,6 +209,7 @@ bool js_cocos2dx_ui_Button_loadTextures(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_ui_Button_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_loadTextureNormal(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_setCapInsetsPressedRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getPressedFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getRendererNormal(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Button_getTitleFontName(JSContext *cx, uint32_t argc, jsval *vp); @@ -220,15 +227,20 @@ bool js_cocos2dx_ui_AbstractCheckButton_constructor(JSContext *cx, uint32_t argc void js_cocos2dx_ui_AbstractCheckButton_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_AbstractCheckButton(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_setSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackground(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_isSelected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextures(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross(JSContext *cx, uint32_t argc, jsval *vp); @@ -291,6 +303,7 @@ bool js_cocos2dx_ui_ImageView_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ImageView_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ImageView_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ImageView_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ImageView_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ImageView_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ImageView_create(JSContext *cx, uint32_t argc, jsval *vp); @@ -342,6 +355,7 @@ void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_ui_TextAtlas_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextAtlas_getString(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextAtlas_setProperty(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextAtlas_adaptRenderers(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); @@ -358,6 +372,7 @@ void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_ui_LoadingBar_setPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_LoadingBar_loadTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_LoadingBar_setDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_LoadingBar_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_LoadingBar_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_LoadingBar_getDirection(JSContext *cx, uint32_t argc, jsval *vp); @@ -476,25 +491,30 @@ bool js_cocos2dx_ui_Slider_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ui_Slider_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_ui_Slider_setMaxPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setPercent(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getMaxPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadSlidBallTextureNormal(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getBallNormalFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setMaxPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getBackFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getBallDisabeldFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_createInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_Slider(JSContext *cx, uint32_t argc, jsval *vp); @@ -592,10 +612,11 @@ bool js_cocos2dx_ui_TextBMFont_constructor(JSContext *cx, uint32_t argc, jsval * void js_cocos2dx_ui_TextBMFont_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_TextBMFont(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_ui_TextBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextBMFont_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_TextBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextBMFont_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextBMFont_createInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextBMFont_TextBMFont(JSContext *cx, uint32_t argc, jsval *vp); @@ -766,6 +787,7 @@ bool js_cocos2dx_ui_Scale9Sprite_getBlendFunc(JSContext *cx, uint32_t argc, jsva bool js_cocos2dx_ui_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_resetRender(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getRenderingType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua b/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua index de1000aee4..be87a3aeea 100644 --- a/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua +++ b/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua @@ -4,6 +4,18 @@ -- @extend Widget -- @parent_module ccui +-------------------------------- +-- +-- @function [parent=#AbstractCheckButton] getBackDisabledFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + +-------------------------------- +-- +-- @function [parent=#AbstractCheckButton] getCrossDisabeldFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- Load background selected state texture for check button.
-- param backGroundSelected The background selected state image name.
@@ -24,6 +36,12 @@ -- @param #int texType -- @return AbstractCheckButton#AbstractCheckButton self (return value: ccui.AbstractCheckButton) +-------------------------------- +-- +-- @function [parent=#AbstractCheckButton] getCrossNormalFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- Change CheckBox state.
-- Set to true will cause the CheckBox's state to "selected", false otherwise.
@@ -33,6 +51,12 @@ -- @param #bool selected -- @return AbstractCheckButton#AbstractCheckButton self (return value: ccui.AbstractCheckButton) +-------------------------------- +-- +-- @function [parent=#AbstractCheckButton] getBackPressedFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- brief Return the sprite instance of front cross when disabled
-- return the sprite instance of front cross when disabled @@ -83,6 +107,12 @@ -- @param #int texType -- @return bool#bool ret (return value: bool) +-------------------------------- +-- +-- @function [parent=#AbstractCheckButton] getBackNormalFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- Load all textures for initializing a check button.
-- param background The background image name.
diff --git a/cocos/scripting/lua-bindings/auto/api/Button.lua b/cocos/scripting/lua-bindings/auto/api/Button.lua index b5cff2b758..cfdcffc243 100644 --- a/cocos/scripting/lua-bindings/auto/api/Button.lua +++ b/cocos/scripting/lua-bindings/auto/api/Button.lua @@ -25,6 +25,12 @@ -- @param #float size -- @return Button#Button self (return value: ccui.Button) +-------------------------------- +-- +-- @function [parent=#Button] resetPressedRender +-- @param self +-- @return Button#Button self (return value: ccui.Button) + -------------------------------- -- Enable scale9 renderer.
-- param enable Set to true will use scale9 renderer, false otherwise. @@ -33,6 +39,12 @@ -- @param #bool enable -- @return Button#Button self (return value: ccui.Button) +-------------------------------- +-- +-- @function [parent=#Button] resetDisabledRender +-- @param self +-- @return Button#Button self (return value: ccui.Button) + -------------------------------- -- Return the inner title renderer of Button.
-- return The button title.
@@ -49,6 +61,12 @@ -- @param self -- @return Scale9Sprite#Scale9Sprite ret (return value: ccui.Scale9Sprite) +-------------------------------- +-- +-- @function [parent=#Button] getDisabledFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- brief Return a zoom scale
-- return the zoom scale in float
@@ -72,6 +90,18 @@ -- @param #color3b_table color -- @return Button#Button self (return value: ccui.Button) +-------------------------------- +-- +-- @function [parent=#Button] getNormalFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + +-------------------------------- +-- +-- @function [parent=#Button] resetNormalRender +-- @param self +-- @return Button#Button self (return value: ccui.Button) + -------------------------------- -- brief Return the nine-patch sprite of disabled state
-- return the nine-patch sprite of disabled state
@@ -213,6 +243,12 @@ -- @param #rect_table capInsets -- @return Button#Button self (return value: ccui.Button) +-------------------------------- +-- +-- @function [parent=#Button] getPressedFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- Query the font size of button title
-- return font size in float. diff --git a/cocos/scripting/lua-bindings/auto/api/ImageView.lua b/cocos/scripting/lua-bindings/auto/api/ImageView.lua index ce23c347e8..022c4fde48 100644 --- a/cocos/scripting/lua-bindings/auto/api/ImageView.lua +++ b/cocos/scripting/lua-bindings/auto/api/ImageView.lua @@ -47,6 +47,12 @@ -- @param #rect_table capInsets -- @return ImageView#ImageView self (return value: ccui.ImageView) +-------------------------------- +-- +-- @function [parent=#ImageView] getRenderFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- Get ImageView's capInsets size.
-- return Query capInsets size in Rect
diff --git a/cocos/scripting/lua-bindings/auto/api/Layout.lua b/cocos/scripting/lua-bindings/auto/api/Layout.lua index 9671f39ae0..e949770e9e 100644 --- a/cocos/scripting/lua-bindings/auto/api/Layout.lua +++ b/cocos/scripting/lua-bindings/auto/api/Layout.lua @@ -60,6 +60,12 @@ -- @param self -- @return int#int ret (return value: int) +-------------------------------- +-- +-- @function [parent=#Layout] getRenderFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- return If focus loop is enabled, then it will return true, otherwise it returns false. The default value is false. -- @function [parent=#Layout] isLoopFocus diff --git a/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua b/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua index 1e4ef4d088..a3c3dfbeeb 100644 --- a/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua +++ b/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua @@ -31,6 +31,12 @@ -- @param #int direction -- @return LoadingBar#LoadingBar self (return value: ccui.LoadingBar) +-------------------------------- +-- +-- @function [parent=#LoadingBar] getRenderFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- Enable scale9 renderer.
-- param enabled Set to true will use scale9 renderer, false otherwise. diff --git a/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua b/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua index 48de7efb06..fa10b5dc92 100644 --- a/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua +++ b/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua @@ -201,6 +201,12 @@ -- @param self -- @return bool#bool ret (return value: bool) +-------------------------------- +-- +-- @function [parent=#Scale9Sprite] resetRender +-- @param self +-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) + -------------------------------- -- Return the slice sprite rendering type. -- @function [parent=#Scale9Sprite] getRenderingType diff --git a/cocos/scripting/lua-bindings/auto/api/Slider.lua b/cocos/scripting/lua-bindings/auto/api/Slider.lua index 0690c50002..f7dc568e37 100644 --- a/cocos/scripting/lua-bindings/auto/api/Slider.lua +++ b/cocos/scripting/lua-bindings/auto/api/Slider.lua @@ -4,15 +4,6 @@ -- @extend Widget -- @parent_module ccui --------------------------------- --- Set a large value could give more control to the precision.
--- since v3.7
--- param percent The max percent of Slider. --- @function [parent=#Slider] setMaxPercent --- @param self --- @param #int percent --- @return Slider#Slider self (return value: ccui.Slider) - -------------------------------- -- Changes the progress direction of slider.
-- param percent Percent value from 1 to 100. @@ -21,16 +12,6 @@ -- @param #int percent -- @return Slider#Slider self (return value: ccui.Slider) --------------------------------- --- Load disabled state texture for slider ball.
--- param disabled Disabled state texture.
--- param resType @see TextureResType . --- @function [parent=#Slider] loadSlidBallTextureDisabled --- @param self --- @param #string disabled --- @param #int resType --- @return Slider#Slider self (return value: ccui.Slider) - -------------------------------- -- Query the maximum percent of Slider. The default value is 100.
-- since v3.7
@@ -49,16 +30,6 @@ -- @param #int resType -- @return Slider#Slider self (return value: ccui.Slider) --------------------------------- --- Load texture for slider bar.
--- param fileName File name of texture.
--- param resType @see TextureResType . --- @function [parent=#Slider] loadBarTexture --- @param self --- @param #string fileName --- @param #int resType --- @return Slider#Slider self (return value: ccui.Slider) - -------------------------------- -- Load dark state texture for slider progress bar.
-- param fileName File path of texture.
@@ -69,6 +40,41 @@ -- @param #int resType -- @return Slider#Slider self (return value: ccui.Slider) +-------------------------------- +-- +-- @function [parent=#Slider] getBallNormalFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + +-------------------------------- +-- Gets capinsets for progress bar slider, if slider is using scale9 renderer.
+-- return Capinsets for progress bar slider.
+-- js NA +-- @function [parent=#Slider] getCapInsetsProgressBarRebderer +-- @param self +-- @return rect_table#rect_table ret (return value: rect_table) + +-------------------------------- +-- Sets if slider is using scale9 renderer.
+-- param able True that using scale9 renderer, false otherwise. +-- @function [parent=#Slider] setScale9Enabled +-- @param self +-- @param #bool able +-- @return Slider#Slider self (return value: ccui.Slider) + +-------------------------------- +-- +-- @function [parent=#Slider] getBallPressedFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + +-------------------------------- +-- brief Return a zoom scale
+-- since v3.3 +-- @function [parent=#Slider] getZoomScale +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- Load textures for slider ball.
-- param normal Normal state texture.
@@ -83,6 +89,69 @@ -- @param #int texType -- @return Slider#Slider self (return value: ccui.Slider) +-------------------------------- +-- Add call back function called when slider's percent has changed to slider.
+-- param callback An given call back function called when slider's percent has changed to slider. +-- @function [parent=#Slider] addEventListener +-- @param self +-- @param #function callback +-- @return Slider#Slider self (return value: ccui.Slider) + +-------------------------------- +-- Set a large value could give more control to the precision.
+-- since v3.7
+-- param percent The max percent of Slider. +-- @function [parent=#Slider] setMaxPercent +-- @param self +-- @param #int percent +-- @return Slider#Slider self (return value: ccui.Slider) + +-------------------------------- +-- Load texture for slider bar.
+-- param fileName File name of texture.
+-- param resType @see TextureResType . +-- @function [parent=#Slider] loadBarTexture +-- @param self +-- @param #string fileName +-- @param #int resType +-- @return Slider#Slider self (return value: ccui.Slider) + +-------------------------------- +-- +-- @function [parent=#Slider] getProgressBarFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + +-------------------------------- +-- Gets capinsets for bar slider, if slider is using scale9 renderer.
+-- return capInsets Capinsets for bar slider. +-- @function [parent=#Slider] getCapInsetsBarRenderer +-- @param self +-- @return rect_table#rect_table ret (return value: rect_table) + +-------------------------------- +-- Load pressed state texture for slider ball.
+-- param pressed Pressed state texture.
+-- param resType @see TextureResType . +-- @function [parent=#Slider] loadSlidBallTexturePressed +-- @param self +-- @param #string pressed +-- @param #int resType +-- @return Slider#Slider self (return value: ccui.Slider) + +-------------------------------- +-- +-- @function [parent=#Slider] getBackFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + +-------------------------------- +-- Gets If slider is using scale9 renderer.
+-- return True that using scale9 renderer, false otherwise. +-- @function [parent=#Slider] isScale9Enabled +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- Sets capinsets for progress bar slider, if slider is using scale9 renderer.
-- param capInsets Capinsets for progress bar slider.
@@ -101,29 +170,17 @@ -- @return Slider#Slider self (return value: ccui.Slider) -------------------------------- --- Gets capinsets for progress bar slider, if slider is using scale9 renderer.
--- return Capinsets for progress bar slider.
--- js NA --- @function [parent=#Slider] getCapInsetsProgressBarRebderer +-- +-- @function [parent=#Slider] getBallDisabeldFile -- @param self --- @return rect_table#rect_table ret (return value: rect_table) +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) -------------------------------- --- Sets if slider is using scale9 renderer.
--- param able True that using scale9 renderer, false otherwise. --- @function [parent=#Slider] setScale9Enabled +-- Gets the progress direction of slider.
+-- return percent Percent value from 1 to 100. +-- @function [parent=#Slider] getPercent -- @param self --- @param #bool able --- @return Slider#Slider self (return value: ccui.Slider) - --------------------------------- --- When user pressed the button, the button will zoom to a scale.
--- The final scale of the button equals (button original scale + _zoomScale)
--- since v3.3 --- @function [parent=#Slider] setZoomScale --- @param self --- @param #float scale --- @return Slider#Slider self (return value: ccui.Slider) +-- @return int#int ret (return value: int) -------------------------------- -- Sets capinsets for slider, if slider is using scale9 renderer.
@@ -134,50 +191,23 @@ -- @return Slider#Slider self (return value: ccui.Slider) -------------------------------- --- brief Return a zoom scale
--- since v3.3 --- @function [parent=#Slider] getZoomScale --- @param self --- @return float#float ret (return value: float) - --------------------------------- --- Add call back function called when slider's percent has changed to slider.
--- param callback An given call back function called when slider's percent has changed to slider. --- @function [parent=#Slider] addEventListener --- @param self --- @param #function callback --- @return Slider#Slider self (return value: ccui.Slider) - --------------------------------- --- Load pressed state texture for slider ball.
--- param pressed Pressed state texture.
+-- Load disabled state texture for slider ball.
+-- param disabled Disabled state texture.
-- param resType @see TextureResType . --- @function [parent=#Slider] loadSlidBallTexturePressed +-- @function [parent=#Slider] loadSlidBallTextureDisabled -- @param self --- @param #string pressed +-- @param #string disabled -- @param #int resType -- @return Slider#Slider self (return value: ccui.Slider) -------------------------------- --- Gets If slider is using scale9 renderer.
--- return True that using scale9 renderer, false otherwise. --- @function [parent=#Slider] isScale9Enabled +-- When user pressed the button, the button will zoom to a scale.
+-- The final scale of the button equals (button original scale + _zoomScale)
+-- since v3.3 +-- @function [parent=#Slider] setZoomScale -- @param self --- @return bool#bool ret (return value: bool) - --------------------------------- --- Gets capinsets for bar slider, if slider is using scale9 renderer.
--- return capInsets Capinsets for bar slider. --- @function [parent=#Slider] getCapInsetsBarRenderer --- @param self --- @return rect_table#rect_table ret (return value: rect_table) - --------------------------------- --- Gets the progress direction of slider.
--- return percent Percent value from 1 to 100. --- @function [parent=#Slider] getPercent --- @param self --- @return int#int ret (return value: int) +-- @param #float scale +-- @return Slider#Slider self (return value: ccui.Slider) -------------------------------- -- @overload self, string, string, int diff --git a/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua b/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua index a1b2c1e83b..fd8cbf3523 100644 --- a/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua +++ b/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua @@ -26,6 +26,12 @@ -- @param #string value -- @return TextAtlas#TextAtlas self (return value: ccui.TextAtlas) +-------------------------------- +-- +-- @function [parent=#TextAtlas] getRenderFile +-- @param self +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + -------------------------------- -- Initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas.
-- param stringValue A given string needs to be displayed.
diff --git a/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua b/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua index 0d65d3eeb3..aa7b1e8157 100644 --- a/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua +++ b/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua @@ -4,13 +4,6 @@ -- @extend Widget -- @parent_module ccui --------------------------------- --- init a bitmap font atlas with an initial string and the FNT file --- @function [parent=#TextBMFont] setFntFile --- @param self --- @param #string fileName --- @return TextBMFont#TextBMFont self (return value: ccui.TextBMFont) - -------------------------------- -- Gets the string length of the label.
-- Note: This length will be larger than the raw string length,
@@ -20,6 +13,12 @@ -- @param self -- @return long#long ret (return value: long) +-------------------------------- +-- +-- @function [parent=#TextBMFont] getString +-- @param self +-- @return string#string ret (return value: string) + -------------------------------- -- -- @function [parent=#TextBMFont] setString @@ -29,9 +28,16 @@ -------------------------------- -- --- @function [parent=#TextBMFont] getString +-- @function [parent=#TextBMFont] getRenderFile -- @param self --- @return string#string ret (return value: string) +-- @return ResouceData#ResouceData ret (return value: cc.ResouceData) + +-------------------------------- +-- init a bitmap font atlas with an initial string and the FNT file +-- @function [parent=#TextBMFont] setFntFile +-- @param self +-- @param #string fileName +-- @return TextBMFont#TextBMFont self (return value: ccui.TextBMFont) -------------------------------- -- @overload self, string, string diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 1b18fe5da8..ca84a01a97 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -4617,6 +4617,53 @@ int lua_cocos2dx_ui_Layout_getClippingType(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Layout_getRenderFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Layout* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Layout*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Layout_getRenderFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Layout_getRenderFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getRenderFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Layout:getRenderFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Layout_getRenderFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Layout_isLoopFocus(lua_State* tolua_S) { int argc = 0; @@ -6017,6 +6064,7 @@ int lua_register_cocos2dx_ui_Layout(lua_State* tolua_S) tolua_function(tolua_S,"setBackGroundImageColor",lua_cocos2dx_ui_Layout_setBackGroundImageColor); tolua_function(tolua_S,"getBackGroundColorVector",lua_cocos2dx_ui_Layout_getBackGroundColorVector); tolua_function(tolua_S,"getClippingType",lua_cocos2dx_ui_Layout_getClippingType); + tolua_function(tolua_S,"getRenderFile",lua_cocos2dx_ui_Layout_getRenderFile); tolua_function(tolua_S,"isLoopFocus",lua_cocos2dx_ui_Layout_isLoopFocus); tolua_function(tolua_S,"removeBackGroundImage",lua_cocos2dx_ui_Layout_removeBackGroundImage); tolua_function(tolua_S,"getBackGroundColorOpacity",lua_cocos2dx_ui_Layout_getBackGroundColorOpacity); @@ -6196,6 +6244,53 @@ int lua_cocos2dx_ui_Button_setTitleFontSize(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Button_resetPressedRender(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_resetPressedRender'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Button_resetPressedRender'", nullptr); + return 0; + } + cobj->resetPressedRender(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:resetPressedRender",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_resetPressedRender'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Button_setScale9Enabled(lua_State* tolua_S) { int argc = 0; @@ -6246,6 +6341,53 @@ int lua_cocos2dx_ui_Button_setScale9Enabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Button_resetDisabledRender(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_resetDisabledRender'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Button_resetDisabledRender'", nullptr); + return 0; + } + cobj->resetDisabledRender(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:resetDisabledRender",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_resetDisabledRender'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Button_getTitleRenderer(lua_State* tolua_S) { int argc = 0; @@ -6340,6 +6482,53 @@ int lua_cocos2dx_ui_Button_getRendererClicked(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Button_getDisabledFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_getDisabledFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Button_getDisabledFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getDisabledFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:getDisabledFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_getDisabledFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Button_getZoomScale(lua_State* tolua_S) { int argc = 0; @@ -6484,6 +6673,100 @@ int lua_cocos2dx_ui_Button_setTitleColor(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Button_getNormalFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_getNormalFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Button_getNormalFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getNormalFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:getNormalFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_getNormalFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Button_resetNormalRender(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_resetNormalRender'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Button_resetNormalRender'", nullptr); + return 0; + } + cobj->resetNormalRender(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:resetNormalRender",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_resetNormalRender'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Button_getRendererDisabled(lua_State* tolua_S) { int argc = 0; @@ -7438,6 +7721,53 @@ int lua_cocos2dx_ui_Button_setCapInsetsPressedRenderer(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Button_getPressedFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_getPressedFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Button_getPressedFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getPressedFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:getPressedFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_getPressedFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Button_getTitleFontSize(lua_State* tolua_S) { int argc = 0; @@ -7915,12 +8245,17 @@ int lua_register_cocos2dx_ui_Button(lua_State* tolua_S) tolua_function(tolua_S,"getNormalTextureSize",lua_cocos2dx_ui_Button_getNormalTextureSize); tolua_function(tolua_S,"getTitleText",lua_cocos2dx_ui_Button_getTitleText); tolua_function(tolua_S,"setTitleFontSize",lua_cocos2dx_ui_Button_setTitleFontSize); + tolua_function(tolua_S,"resetPressedRender",lua_cocos2dx_ui_Button_resetPressedRender); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_Button_setScale9Enabled); + tolua_function(tolua_S,"resetDisabledRender",lua_cocos2dx_ui_Button_resetDisabledRender); tolua_function(tolua_S,"getTitleRenderer",lua_cocos2dx_ui_Button_getTitleRenderer); tolua_function(tolua_S,"getRendererClicked",lua_cocos2dx_ui_Button_getRendererClicked); + tolua_function(tolua_S,"getDisabledFile",lua_cocos2dx_ui_Button_getDisabledFile); tolua_function(tolua_S,"getZoomScale",lua_cocos2dx_ui_Button_getZoomScale); tolua_function(tolua_S,"getCapInsetsDisabledRenderer",lua_cocos2dx_ui_Button_getCapInsetsDisabledRenderer); tolua_function(tolua_S,"setTitleColor",lua_cocos2dx_ui_Button_setTitleColor); + tolua_function(tolua_S,"getNormalFile",lua_cocos2dx_ui_Button_getNormalFile); + tolua_function(tolua_S,"resetNormalRender",lua_cocos2dx_ui_Button_resetNormalRender); tolua_function(tolua_S,"getRendererDisabled",lua_cocos2dx_ui_Button_getRendererDisabled); tolua_function(tolua_S,"setCapInsetsDisabledRenderer",lua_cocos2dx_ui_Button_setCapInsetsDisabledRenderer); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_ui_Button_setCapInsets); @@ -7937,6 +8272,7 @@ int lua_register_cocos2dx_ui_Button(lua_State* tolua_S) tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_Button_isScale9Enabled); tolua_function(tolua_S,"loadTextureNormal",lua_cocos2dx_ui_Button_loadTextureNormal); tolua_function(tolua_S,"setCapInsetsPressedRenderer",lua_cocos2dx_ui_Button_setCapInsetsPressedRenderer); + tolua_function(tolua_S,"getPressedFile",lua_cocos2dx_ui_Button_getPressedFile); tolua_function(tolua_S,"getTitleFontSize",lua_cocos2dx_ui_Button_getTitleFontSize); tolua_function(tolua_S,"getRendererNormal",lua_cocos2dx_ui_Button_getRendererNormal); tolua_function(tolua_S,"getTitleFontName",lua_cocos2dx_ui_Button_getTitleFontName); @@ -7952,6 +8288,100 @@ int lua_register_cocos2dx_ui_Button(lua_State* tolua_S) return 1; } +int lua_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getBackDisabledFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getBackDisabledFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getCrossDisabeldFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getCrossDisabeldFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected(lua_State* tolua_S) { int argc = 0; @@ -8086,6 +8516,53 @@ int lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled(lua_State* return 0; } +int lua_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getCrossNormalFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getCrossNormalFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_AbstractCheckButton_setSelected(lua_State* tolua_S) { int argc = 0; @@ -8136,6 +8613,53 @@ int lua_cocos2dx_ui_AbstractCheckButton_setSelected(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_AbstractCheckButton_getBackPressedFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackPressedFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackPressedFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getBackPressedFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getBackPressedFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackPressedFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled(lua_State* tolua_S) { int argc = 0; @@ -8482,6 +9006,53 @@ int lua_cocos2dx_ui_AbstractCheckButton_init(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_AbstractCheckButton_getBackNormalFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackNormalFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackNormalFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getBackNormalFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getBackNormalFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getBackNormalFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_AbstractCheckButton_loadTextures(lua_State* tolua_S) { int argc = 0; @@ -8910,15 +9481,20 @@ int lua_register_cocos2dx_ui_AbstractCheckButton(lua_State* tolua_S) tolua_cclass(tolua_S,"AbstractCheckButton","ccui.AbstractCheckButton","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"AbstractCheckButton"); + tolua_function(tolua_S,"getBackDisabledFile",lua_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile); + tolua_function(tolua_S,"getCrossDisabeldFile",lua_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile); tolua_function(tolua_S,"loadTextureBackGroundSelected",lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected); tolua_function(tolua_S,"loadTextureBackGroundDisabled",lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled); + tolua_function(tolua_S,"getCrossNormalFile",lua_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile); tolua_function(tolua_S,"setSelected",lua_cocos2dx_ui_AbstractCheckButton_setSelected); + tolua_function(tolua_S,"getBackPressedFile",lua_cocos2dx_ui_AbstractCheckButton_getBackPressedFile); tolua_function(tolua_S,"getRendererFrontCrossDisabled",lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled); tolua_function(tolua_S,"getRendererBackground",lua_cocos2dx_ui_AbstractCheckButton_getRendererBackground); tolua_function(tolua_S,"loadTextureFrontCross",lua_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross); tolua_function(tolua_S,"getRendererBackgroundDisabled",lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled); tolua_function(tolua_S,"isSelected",lua_cocos2dx_ui_AbstractCheckButton_isSelected); tolua_function(tolua_S,"init",lua_cocos2dx_ui_AbstractCheckButton_init); + tolua_function(tolua_S,"getBackNormalFile",lua_cocos2dx_ui_AbstractCheckButton_getBackNormalFile); tolua_function(tolua_S,"loadTextures",lua_cocos2dx_ui_AbstractCheckButton_loadTextures); tolua_function(tolua_S,"getZoomScale",lua_cocos2dx_ui_AbstractCheckButton_getZoomScale); tolua_function(tolua_S,"getRendererFrontCross",lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross); @@ -10408,6 +10984,53 @@ int lua_cocos2dx_ui_ImageView_setCapInsets(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_ImageView_getRenderFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::ImageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.ImageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::ImageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_ImageView_getRenderFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_ImageView_getRenderFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getRenderFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.ImageView:getRenderFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_ImageView_getRenderFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_ImageView_getCapInsets(lua_State* tolua_S) { int argc = 0; @@ -10652,6 +11275,7 @@ int lua_register_cocos2dx_ui_ImageView(lua_State* tolua_S) tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_ImageView_setScale9Enabled); tolua_function(tolua_S,"setTextureRect",lua_cocos2dx_ui_ImageView_setTextureRect); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_ui_ImageView_setCapInsets); + tolua_function(tolua_S,"getRenderFile",lua_cocos2dx_ui_ImageView_getRenderFile); tolua_function(tolua_S,"getCapInsets",lua_cocos2dx_ui_ImageView_getCapInsets); tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_ImageView_isScale9Enabled); tolua_function(tolua_S,"create", lua_cocos2dx_ui_ImageView_create); @@ -12214,6 +12838,53 @@ int lua_cocos2dx_ui_TextAtlas_setString(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_TextAtlas_getRenderFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::TextAtlas* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.TextAtlas",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::TextAtlas*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_TextAtlas_getRenderFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_TextAtlas_getRenderFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getRenderFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.TextAtlas:getRenderFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_TextAtlas_getRenderFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_TextAtlas_setProperty(lua_State* tolua_S) { int argc = 0; @@ -12467,6 +13138,7 @@ int lua_register_cocos2dx_ui_TextAtlas(lua_State* tolua_S) tolua_function(tolua_S,"getStringLength",lua_cocos2dx_ui_TextAtlas_getStringLength); tolua_function(tolua_S,"getString",lua_cocos2dx_ui_TextAtlas_getString); tolua_function(tolua_S,"setString",lua_cocos2dx_ui_TextAtlas_setString); + tolua_function(tolua_S,"getRenderFile",lua_cocos2dx_ui_TextAtlas_getRenderFile); tolua_function(tolua_S,"setProperty",lua_cocos2dx_ui_TextAtlas_setProperty); tolua_function(tolua_S,"adaptRenderers",lua_cocos2dx_ui_TextAtlas_adaptRenderers); tolua_function(tolua_S,"create", lua_cocos2dx_ui_TextAtlas_create); @@ -12645,6 +13317,53 @@ int lua_cocos2dx_ui_LoadingBar_setDirection(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_LoadingBar_getRenderFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::LoadingBar* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::LoadingBar*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_LoadingBar_getRenderFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_LoadingBar_getRenderFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getRenderFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.LoadingBar:getRenderFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_LoadingBar_getRenderFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_LoadingBar_setScale9Enabled(lua_State* tolua_S) { int argc = 0; @@ -13116,6 +13835,7 @@ int lua_register_cocos2dx_ui_LoadingBar(lua_State* tolua_S) tolua_function(tolua_S,"setPercent",lua_cocos2dx_ui_LoadingBar_setPercent); tolua_function(tolua_S,"loadTexture",lua_cocos2dx_ui_LoadingBar_loadTexture); tolua_function(tolua_S,"setDirection",lua_cocos2dx_ui_LoadingBar_setDirection); + tolua_function(tolua_S,"getRenderFile",lua_cocos2dx_ui_LoadingBar_getRenderFile); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_LoadingBar_setScale9Enabled); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_ui_LoadingBar_setCapInsets); tolua_function(tolua_S,"getDirection",lua_cocos2dx_ui_LoadingBar_getDirection); @@ -17498,56 +18218,6 @@ int lua_register_cocos2dx_ui_ListView(lua_State* tolua_S) return 1; } -int lua_cocos2dx_ui_Slider_setMaxPercent(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setMaxPercent'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.Slider:setMaxPercent"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setMaxPercent'", nullptr); - return 0; - } - cobj->setMaxPercent(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setMaxPercent",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setMaxPercent'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Slider_setPercent(lua_State* tolua_S) { int argc = 0; @@ -17598,73 +18268,6 @@ int lua_cocos2dx_ui_Slider_setPercent(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTextureDisabled"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'", nullptr); - return 0; - } - cobj->loadSlidBallTextureDisabled(arg0); - lua_settop(tolua_S, 1); - return 1; - } - if (argc == 2) - { - std::string arg0; - cocos2d::ui::Widget::TextureResType arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTextureDisabled"); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.Slider:loadSlidBallTextureDisabled"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'", nullptr); - return 0; - } - cobj->loadSlidBallTextureDisabled(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:loadSlidBallTextureDisabled",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Slider_getMaxPercent(lua_State* tolua_S) { int argc = 0; @@ -17779,73 +18382,6 @@ int lua_cocos2dx_ui_Slider_loadSlidBallTextureNormal(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Slider_loadBarTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_loadBarTexture'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadBarTexture"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadBarTexture'", nullptr); - return 0; - } - cobj->loadBarTexture(arg0); - lua_settop(tolua_S, 1); - return 1; - } - if (argc == 2) - { - std::string arg0; - cocos2d::ui::Widget::TextureResType arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadBarTexture"); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.Slider:loadBarTexture"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadBarTexture'", nullptr); - return 0; - } - cobj->loadBarTexture(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:loadBarTexture",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_loadBarTexture'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Slider_loadProgressBarTexture(lua_State* tolua_S) { int argc = 0; @@ -17913,6 +18449,244 @@ int lua_cocos2dx_ui_Slider_loadProgressBarTexture(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Slider_getBallNormalFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getBallNormalFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getBallNormalFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getBallNormalFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getBallNormalFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getBallNormalFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'", nullptr); + return 0; + } + const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRebderer(); + rect_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getCapInsetsProgressBarRebderer",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_setScale9Enabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setScale9Enabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.Slider:setScale9Enabled"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setScale9Enabled'", nullptr); + return 0; + } + cobj->setScale9Enabled(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setScale9Enabled",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setScale9Enabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_getBallPressedFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getBallPressedFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getBallPressedFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getBallPressedFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getBallPressedFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getBallPressedFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_getZoomScale(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getZoomScale'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getZoomScale'", nullptr); + return 0; + } + double ret = cobj->getZoomScale(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getZoomScale",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getZoomScale'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Slider_loadSlidBallTextures(lua_State* tolua_S) { int argc = 0; @@ -18023,6 +18797,432 @@ int lua_cocos2dx_ui_Slider_loadSlidBallTextures(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Slider_addEventListener(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_addEventListener'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::function arg0; + + do { + // Lambda binding for lua is not supported. + assert(false); + } while(0) + ; + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_addEventListener'", nullptr); + return 0; + } + cobj->addEventListener(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:addEventListener",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_addEventListener'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_setMaxPercent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setMaxPercent'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.Slider:setMaxPercent"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setMaxPercent'", nullptr); + return 0; + } + cobj->setMaxPercent(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setMaxPercent",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setMaxPercent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_loadBarTexture(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_loadBarTexture'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadBarTexture"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadBarTexture'", nullptr); + return 0; + } + cobj->loadBarTexture(arg0); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 2) + { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadBarTexture"); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.Slider:loadBarTexture"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadBarTexture'", nullptr); + return 0; + } + cobj->loadBarTexture(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:loadBarTexture",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_loadBarTexture'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_getProgressBarFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getProgressBarFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getProgressBarFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getProgressBarFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getProgressBarFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getProgressBarFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer'", nullptr); + return 0; + } + const cocos2d::Rect& ret = cobj->getCapInsetsBarRenderer(); + rect_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getCapInsetsBarRenderer",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTexturePressed"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'", nullptr); + return 0; + } + cobj->loadSlidBallTexturePressed(arg0); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 2) + { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTexturePressed"); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.Slider:loadSlidBallTexturePressed"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'", nullptr); + return 0; + } + cobj->loadSlidBallTexturePressed(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:loadSlidBallTexturePressed",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_getBackFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getBackFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getBackFile'", nullptr); + return 0; + } + cocos2d::ResouceData ret = cobj->getBackFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getBackFile",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getBackFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Slider_isScale9Enabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_isScale9Enabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_isScale9Enabled'", nullptr); + return 0; + } + bool ret = cobj->isScale9Enabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:isScale9Enabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_isScale9Enabled'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(lua_State* tolua_S) { int argc = 0; @@ -18123,7 +19323,7 @@ int lua_cocos2dx_ui_Slider_setCapInsetsBarRenderer(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(lua_State* tolua_S) +int lua_cocos2dx_ui_Slider_getBallDisabeldFile(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Slider* cobj = nullptr; @@ -18143,7 +19343,7 @@ int lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getBallDisabeldFile'", nullptr); return 0; } #endif @@ -18153,24 +19353,24 @@ int lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getBallDisabeldFile'", nullptr); return 0; } - const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRebderer(); - rect_to_luaval(tolua_S, ret); + cocos2d::ResouceData ret = cobj->getBallDisabeldFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getCapInsetsProgressBarRebderer",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getBallDisabeldFile",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getBallDisabeldFile'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_ui_Slider_setScale9Enabled(lua_State* tolua_S) +int lua_cocos2dx_ui_Slider_getPercent(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Slider* cobj = nullptr; @@ -18190,82 +19390,29 @@ int lua_cocos2dx_ui_Slider_setScale9Enabled(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setScale9Enabled'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getPercent'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.Slider:setScale9Enabled"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setScale9Enabled'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getPercent'", nullptr); return 0; } - cobj->setScale9Enabled(arg0); - lua_settop(tolua_S, 1); + int ret = cobj->getPercent(); + tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setScale9Enabled",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getPercent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setScale9Enabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_Slider_setZoomScale(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setZoomScale'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.Slider:setZoomScale"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setZoomScale'", nullptr); - return 0; - } - cobj->setZoomScale(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setZoomScale",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setZoomScale'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getPercent'.",&tolua_err); #endif return 0; @@ -18320,7 +19467,7 @@ int lua_cocos2dx_ui_Slider_setCapInsets(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Slider_getZoomScale(lua_State* tolua_S) +int lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Slider* cobj = nullptr; @@ -18340,108 +19487,7 @@ int lua_cocos2dx_ui_Slider_getZoomScale(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getZoomScale'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getZoomScale'", nullptr); - return 0; - } - double ret = cobj->getZoomScale(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getZoomScale",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getZoomScale'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_Slider_addEventListener(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_addEventListener'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::function arg0; - - do { - // Lambda binding for lua is not supported. - assert(false); - } while(0) - ; - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_addEventListener'", nullptr); - return 0; - } - cobj->addEventListener(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:addEventListener",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_addEventListener'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'", nullptr); return 0; } #endif @@ -18451,13 +19497,13 @@ int lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed(lua_State* tolua_S) { std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTexturePressed"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTextureDisabled"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'", nullptr); return 0; } - cobj->loadSlidBallTexturePressed(arg0); + cobj->loadSlidBallTextureDisabled(arg0); lua_settop(tolua_S, 1); return 1; } @@ -18466,29 +19512,29 @@ int lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed(lua_State* tolua_S) std::string arg0; cocos2d::ui::Widget::TextureResType arg1; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTexturePressed"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.Slider:loadSlidBallTextureDisabled"); - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.Slider:loadSlidBallTexturePressed"); + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "ccui.Slider:loadSlidBallTextureDisabled"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'", nullptr); return 0; } - cobj->loadSlidBallTexturePressed(arg0, arg1); + cobj->loadSlidBallTextureDisabled(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:loadSlidBallTexturePressed",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:loadSlidBallTextureDisabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_ui_Slider_isScale9Enabled(lua_State* tolua_S) +int lua_cocos2dx_ui_Slider_setZoomScale(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Slider* cobj = nullptr; @@ -18508,123 +19554,32 @@ int lua_cocos2dx_ui_Slider_isScale9Enabled(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_isScale9Enabled'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setZoomScale'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 0) + if (argc == 1) { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.Slider:setZoomScale"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_isScale9Enabled'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setZoomScale'", nullptr); return 0; } - bool ret = cobj->isScale9Enabled(); - tolua_pushboolean(tolua_S,(bool)ret); + cobj->setZoomScale(arg0); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:isScale9Enabled",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setZoomScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_isScale9Enabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer'", nullptr); - return 0; - } - const cocos2d::Rect& ret = cobj->getCapInsetsBarRenderer(); - rect_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getCapInsetsBarRenderer",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_Slider_getPercent(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getPercent'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getPercent'", nullptr); - return 0; - } - int ret = cobj->getPercent(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getPercent",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getPercent'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setZoomScale'.",&tolua_err); #endif return 0; @@ -18780,26 +19735,31 @@ int lua_register_cocos2dx_ui_Slider(lua_State* tolua_S) tolua_beginmodule(tolua_S,"Slider"); tolua_function(tolua_S,"new",lua_cocos2dx_ui_Slider_constructor); - tolua_function(tolua_S,"setMaxPercent",lua_cocos2dx_ui_Slider_setMaxPercent); tolua_function(tolua_S,"setPercent",lua_cocos2dx_ui_Slider_setPercent); - tolua_function(tolua_S,"loadSlidBallTextureDisabled",lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled); tolua_function(tolua_S,"getMaxPercent",lua_cocos2dx_ui_Slider_getMaxPercent); tolua_function(tolua_S,"loadSlidBallTextureNormal",lua_cocos2dx_ui_Slider_loadSlidBallTextureNormal); - tolua_function(tolua_S,"loadBarTexture",lua_cocos2dx_ui_Slider_loadBarTexture); tolua_function(tolua_S,"loadProgressBarTexture",lua_cocos2dx_ui_Slider_loadProgressBarTexture); - tolua_function(tolua_S,"loadSlidBallTextures",lua_cocos2dx_ui_Slider_loadSlidBallTextures); - tolua_function(tolua_S,"setCapInsetProgressBarRebderer",lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer); - tolua_function(tolua_S,"setCapInsetsBarRenderer",lua_cocos2dx_ui_Slider_setCapInsetsBarRenderer); + tolua_function(tolua_S,"getBallNormalFile",lua_cocos2dx_ui_Slider_getBallNormalFile); tolua_function(tolua_S,"getCapInsetsProgressBarRebderer",lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_Slider_setScale9Enabled); - tolua_function(tolua_S,"setZoomScale",lua_cocos2dx_ui_Slider_setZoomScale); - tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_ui_Slider_setCapInsets); + tolua_function(tolua_S,"getBallPressedFile",lua_cocos2dx_ui_Slider_getBallPressedFile); tolua_function(tolua_S,"getZoomScale",lua_cocos2dx_ui_Slider_getZoomScale); + tolua_function(tolua_S,"loadSlidBallTextures",lua_cocos2dx_ui_Slider_loadSlidBallTextures); tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_Slider_addEventListener); - tolua_function(tolua_S,"loadSlidBallTexturePressed",lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed); - tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_Slider_isScale9Enabled); + tolua_function(tolua_S,"setMaxPercent",lua_cocos2dx_ui_Slider_setMaxPercent); + tolua_function(tolua_S,"loadBarTexture",lua_cocos2dx_ui_Slider_loadBarTexture); + tolua_function(tolua_S,"getProgressBarFile",lua_cocos2dx_ui_Slider_getProgressBarFile); tolua_function(tolua_S,"getCapInsetsBarRenderer",lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer); + tolua_function(tolua_S,"loadSlidBallTexturePressed",lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed); + tolua_function(tolua_S,"getBackFile",lua_cocos2dx_ui_Slider_getBackFile); + tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_Slider_isScale9Enabled); + tolua_function(tolua_S,"setCapInsetProgressBarRebderer",lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer); + tolua_function(tolua_S,"setCapInsetsBarRenderer",lua_cocos2dx_ui_Slider_setCapInsetsBarRenderer); + tolua_function(tolua_S,"getBallDisabeldFile",lua_cocos2dx_ui_Slider_getBallDisabeldFile); tolua_function(tolua_S,"getPercent",lua_cocos2dx_ui_Slider_getPercent); + tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_ui_Slider_setCapInsets); + tolua_function(tolua_S,"loadSlidBallTextureDisabled",lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled); + tolua_function(tolua_S,"setZoomScale",lua_cocos2dx_ui_Slider_setZoomScale); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Slider_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_Slider_createInstance); tolua_endmodule(tolua_S); @@ -20990,56 +21950,6 @@ int lua_register_cocos2dx_ui_TextField(lua_State* tolua_S) return 1; } -int lua_cocos2dx_ui_TextBMFont_setFntFile(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::TextBMFont* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.TextBMFont",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::TextBMFont*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_TextBMFont_setFntFile'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.TextBMFont:setFntFile"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_TextBMFont_setFntFile'", nullptr); - return 0; - } - cobj->setFntFile(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.TextBMFont:setFntFile",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_TextBMFont_setFntFile'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_TextBMFont_getStringLength(lua_State* tolua_S) { int argc = 0; @@ -21087,6 +21997,53 @@ int lua_cocos2dx_ui_TextBMFont_getStringLength(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_TextBMFont_getString(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::TextBMFont* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.TextBMFont",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::TextBMFont*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_TextBMFont_getString'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_TextBMFont_getString'", nullptr); + return 0; + } + const std::string& ret = cobj->getString(); + tolua_pushcppstring(tolua_S,ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.TextBMFont:getString",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_TextBMFont_getString'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_TextBMFont_setString(lua_State* tolua_S) { int argc = 0; @@ -21137,7 +22094,7 @@ int lua_cocos2dx_ui_TextBMFont_setString(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_TextBMFont_getString(lua_State* tolua_S) +int lua_cocos2dx_ui_TextBMFont_getRenderFile(lua_State* tolua_S) { int argc = 0; cocos2d::ui::TextBMFont* cobj = nullptr; @@ -21157,7 +22114,7 @@ int lua_cocos2dx_ui_TextBMFont_getString(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_TextBMFont_getString'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_TextBMFont_getRenderFile'", nullptr); return 0; } #endif @@ -21167,19 +22124,69 @@ int lua_cocos2dx_ui_TextBMFont_getString(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_TextBMFont_getString'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_TextBMFont_getRenderFile'", nullptr); return 0; } - const std::string& ret = cobj->getString(); - tolua_pushcppstring(tolua_S,ret); + cocos2d::ResouceData ret = cobj->getRenderFile(); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.TextBMFont:getString",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.TextBMFont:getRenderFile",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_TextBMFont_getString'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_TextBMFont_getRenderFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_TextBMFont_setFntFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::TextBMFont* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.TextBMFont",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::TextBMFont*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_TextBMFont_setFntFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.TextBMFont:setFntFile"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_TextBMFont_setFntFile'", nullptr); + return 0; + } + cobj->setFntFile(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.TextBMFont:setFntFile",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_TextBMFont_setFntFile'.",&tolua_err); #endif return 0; @@ -21316,10 +22323,11 @@ int lua_register_cocos2dx_ui_TextBMFont(lua_State* tolua_S) tolua_beginmodule(tolua_S,"TextBMFont"); tolua_function(tolua_S,"new",lua_cocos2dx_ui_TextBMFont_constructor); - tolua_function(tolua_S,"setFntFile",lua_cocos2dx_ui_TextBMFont_setFntFile); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_ui_TextBMFont_getStringLength); - tolua_function(tolua_S,"setString",lua_cocos2dx_ui_TextBMFont_setString); tolua_function(tolua_S,"getString",lua_cocos2dx_ui_TextBMFont_getString); + tolua_function(tolua_S,"setString",lua_cocos2dx_ui_TextBMFont_setString); + tolua_function(tolua_S,"getRenderFile",lua_cocos2dx_ui_TextBMFont_getRenderFile); + tolua_function(tolua_S,"setFntFile",lua_cocos2dx_ui_TextBMFont_setFntFile); tolua_function(tolua_S,"create", lua_cocos2dx_ui_TextBMFont_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_TextBMFont_createInstance); tolua_endmodule(tolua_S); @@ -25498,6 +26506,53 @@ int lua_cocos2dx_ui_Scale9Sprite_isScale9Enabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Scale9Sprite_resetRender(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Scale9Sprite* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Scale9Sprite_resetRender'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Scale9Sprite_resetRender'", nullptr); + return 0; + } + cobj->resetRender(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Scale9Sprite:resetRender",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Scale9Sprite_resetRender'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Scale9Sprite_getRenderingType(lua_State* tolua_S) { int argc = 0; @@ -26451,6 +27506,7 @@ int lua_register_cocos2dx_ui_Scale9Sprite(lua_State* tolua_S) tolua_function(tolua_S,"getInsetBottom",lua_cocos2dx_ui_Scale9Sprite_getInsetBottom); tolua_function(tolua_S,"getCapInsets",lua_cocos2dx_ui_Scale9Sprite_getCapInsets); tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_Scale9Sprite_isScale9Enabled); + tolua_function(tolua_S,"resetRender",lua_cocos2dx_ui_Scale9Sprite_resetRender); tolua_function(tolua_S,"getRenderingType",lua_cocos2dx_ui_Scale9Sprite_getRenderingType); tolua_function(tolua_S,"getInsetRight",lua_cocos2dx_ui_Scale9Sprite_getInsetRight); tolua_function(tolua_S,"getOriginalSize",lua_cocos2dx_ui_Scale9Sprite_getOriginalSize); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 8bafd19d26..53e67879ca 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -615,6 +615,28 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + From 584a5d7407f1dc74571f739d18a0dc71bb30d4a5 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 25 Nov 2015 18:27:38 +0800 Subject: [PATCH 133/192] fix alphaThreshold undefined issue --- cocos/2d/CCClippingNode.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index ea80510b7b..8557203765 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -215,7 +215,8 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 _beforeVisitCmd.func = CC_CALLBACK_0(StencilStateManager::onBeforeVisit, _stencilStateManager); renderer->addCommand(&_beforeVisitCmd); - if (_stencilStateManager->getAlphaThreshold() < 1) + auto alphaThreshold = this->getAlphaThreshold(); + if (alphaThreshold < 1) { #if CC_CLIPPING_NODE_OPENGLES // since glAlphaTest do not exists in OES, use a shader that writes @@ -224,7 +225,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set our alphaThreshold program->use(); - program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); + program->setUniformLocationWith1f(alphaValueLocation, alphaThreshold); // we need to recursively apply this shader to all the nodes in the stencil node // FIXME: we should have a way to apply shader to all nodes without having to do this setProgram(_stencil, program); From eb47d28266af3a7765a466e27d867c3087ed2618 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 20:07:50 +0800 Subject: [PATCH 134/192] Change component resource load logic, won't dependent on sprite edit in other studio combine PR --- cocos/ui/UIButton.cpp | 29 +++++++++++++++++++++++----- cocos/ui/UISlider.cpp | 45 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index afa194912f..25be951bec 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -233,8 +233,14 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) _normalFileName = normal; _normalTexType = texType; - switch (texType) + if (normal.empty()) { + _buttonNormalRenderer->init(); + } + else + { + switch (texType) + { case TextureResType::LOCAL: _buttonNormalRenderer->initWithFile(normal); break; @@ -243,9 +249,9 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) break; default: break; + } } this->setupNormalTexture(); - } void Button::setupNormalTexture() @@ -283,8 +289,14 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy _clickedFileName = selected; _pressedTexType = texType; - switch (texType) + if (selected.empty()) { + _buttonClickedRenderer->init(); + } + else + { + switch (texType) + { case TextureResType::LOCAL: _buttonClickedRenderer->initWithFile(selected); break; @@ -293,8 +305,8 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy break; default: break; + } } - this->setupPressedTexture(); } @@ -319,8 +331,14 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT _disabledFileName = disabled; _disabledTexType = texType; - switch (texType) + if (disabled.empty()) { + _buttonDisabledRenderer->init(); + } + else + { + switch (texType) + { case TextureResType::LOCAL: _buttonDisabledRenderer->initWithFile(disabled); break; @@ -329,6 +347,7 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT break; default: break; + } } this->setupDisabledTexture(); } diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index 15d6b594c8..62a291e06e 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -155,8 +155,14 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) { _textureFile = fileName; _barTexType = texType; - switch (_barTexType) + if (fileName.empty()) { + _barRenderer->init(); + } + else + { + switch (_barTexType) + { case TextureResType::LOCAL: _barRenderer->initWithFile(fileName); break; @@ -165,6 +171,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) break; default: break; + } } this->setupBarTexture(); } @@ -187,8 +194,14 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType { _progressBarTextureFile = fileName; _progressBarTexType = texType; - switch (_progressBarTexType) + if (fileName.empty()) { + _progressBarRenderer->init(); + } + else + { + switch (_progressBarTexType) + { case TextureResType::LOCAL: _progressBarRenderer->initWithFile(fileName); break; @@ -197,6 +210,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType break; default: break; + } } this->setupProgressBarTexture(); } @@ -307,8 +321,14 @@ void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType { _slidBallNormalTextureFile = normal; _ballNTexType = texType; - switch (_ballNTexType) + if (normal.empty()) { + _slidBallNormalRenderer->init(); + } + else + { + switch (_ballNTexType) + { case TextureResType::LOCAL: _slidBallNormalRenderer->setTexture(normal); break; @@ -317,6 +337,7 @@ void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType break; default: break; + } } this->updateChildrenDisplayedRGBA(); } @@ -331,8 +352,14 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp _slidBallPressedTextureFile = pressed; _isSliderBallPressedTextureLoaded = !pressed.empty(); _ballPTexType = texType; - switch (_ballPTexType) + if (pressed.empty()) { + _slidBallPressedRenderer->init(); + } + else + { + switch (_ballPTexType) + { case TextureResType::LOCAL: _slidBallPressedRenderer->setTexture(pressed); break; @@ -341,6 +368,7 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp break; default: break; + } } this->updateChildrenDisplayedRGBA(); } @@ -357,8 +385,14 @@ void Slider::loadSlidBallTextureDisabled(const std::string& disabled,TextureResT _slidBallDisabledTextureFile = disabled; _isSliderBallDisabledTexturedLoaded = !disabled.empty(); _ballDTexType = texType; - switch (_ballDTexType) + if (disabled.empty()) { + _slidBallDisabledRenderer->init(); + } + else + { + switch (_ballDTexType) + { case TextureResType::LOCAL: _slidBallDisabledRenderer->setTexture(disabled); break; @@ -367,6 +401,7 @@ void Slider::loadSlidBallTextureDisabled(const std::string& disabled,TextureResT break; default: break; + } } this->updateChildrenDisplayedRGBA(); } From 9811d6efcfa8f1d529172a36b6a572104e594e99 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 21:52:44 +0800 Subject: [PATCH 135/192] Combine studio change for LuaBinding, jsb and simulator --- .../js-bindings/manual/js-BindingsExport.h | 30 +++++++++++++++++ .../js-bindings/manual/js_module_register.cpp | 10 +++--- .../js-bindings/manual/js_module_register.h | 12 +++++++ .../proj.win32/libjscocos2d.vcxproj | 9 +++-- .../proj.win32/libjscocos2d.vcxproj.filters | 21 ++++++++---- .../lua-bindings/manual/Lua-BindingsExport.h | 33 +++++++++++++++++++ .../manual/lua_module_register.cpp | 8 ++--- .../lua-bindings/manual/lua_module_register.h | 10 ++++++ .../proj.win32/libluacocos2d.vcxproj | 9 +++-- .../proj.win32/libluacocos2d.vcxproj.filters | 9 +++++ .../Classes/ide-support/RuntimeJsImpl.cpp | 9 ++--- .../Classes/ide-support/RuntimeLuaImpl.cpp | 2 -- .../runtime-src/proj.win32/simulator.vcxproj | 12 +++---- tools/simulator/libsimulator/lib/AppEvent.h | 3 +- tools/simulator/libsimulator/lib/AppLang.h | 3 +- tools/simulator/libsimulator/lib/DeviceEx.h | 3 +- .../lib/PlayerMenuServiceProtocol.h | 3 +- .../libsimulator/lib/PlayerProtocol.h | 3 +- .../lib/ProjectConfig/ProjectConfig.h | 3 +- .../lib/ProjectConfig/SimulatorConfig.h | 3 +- .../libsimulator/lib/SimulatorExport.h | 30 +++++++++++++++++ .../lib/platform/win32/PlayerMenuServiceWin.h | 5 +-- .../lib/platform/win32/PlayerWin.h | 3 +- .../libsimulator/lib/runtime/ConfigParser.h | 4 ++- .../lib/runtime/ConsoleCommand.cpp | 6 ++-- .../libsimulator/lib/runtime/FileServer.cpp | 2 +- .../libsimulator/lib/runtime/FileServer.h | 3 +- .../libsimulator/lib/runtime/Runtime.cpp | 24 ++++++++++++-- .../libsimulator/lib/runtime/Runtime.h | 7 ++-- .../lib/runtime/RuntimeProtocol.h | 3 +- .../libsimulator/lib/runtime/Widget_mac.h | 12 +++++++ .../libsimulator/lib/runtime/Widget_mac.mm | 20 +++++++++++ .../proj.win32/libsimulator.vcxproj | 4 +-- 33 files changed, 261 insertions(+), 57 deletions(-) create mode 100644 cocos/scripting/js-bindings/manual/js-BindingsExport.h rename tools/simulator/frameworks/runtime-src/Classes/js_module_register.h => cocos/scripting/js-bindings/manual/js_module_register.cpp (94%) create mode 100644 cocos/scripting/js-bindings/manual/js_module_register.h create mode 100644 cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h rename tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h => cocos/scripting/lua-bindings/manual/lua_module_register.cpp (78%) mode change 100755 => 100644 create mode 100644 cocos/scripting/lua-bindings/manual/lua_module_register.h create mode 100644 tools/simulator/libsimulator/lib/SimulatorExport.h create mode 100644 tools/simulator/libsimulator/lib/runtime/Widget_mac.h create mode 100644 tools/simulator/libsimulator/lib/runtime/Widget_mac.mm diff --git a/cocos/scripting/js-bindings/manual/js-BindingsExport.h b/cocos/scripting/js-bindings/manual/js-BindingsExport.h new file mode 100644 index 0000000000..2d90b05f42 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js-BindingsExport.h @@ -0,0 +1,30 @@ +#pragma once + +#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) + #ifdef __MINGW32__ + #include + #endif + + #if defined(_USRJSSTATIC) + #define CC_JS_DLL + #else + #if defined(_USRJSDLL) + #define CC_JS_DLL __declspec(dllexport) + #else /* use a DLL library */ + #define CC_JS_DLL __declspec(dllimport) + #endif + #endif + + /* Define NULL pointer value */ + #ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + #endif +#elif defined(_SHARED_) + #define CC_JS_DLL __attribute__((visibility("default"))) +#else + #define CC_JS_DLL +#endif diff --git a/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h b/cocos/scripting/js-bindings/manual/js_module_register.cpp similarity index 94% rename from tools/simulator/frameworks/runtime-src/Classes/js_module_register.h rename to cocos/scripting/js-bindings/manual/js_module_register.cpp index 6222802506..c6739babf5 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h +++ b/cocos/scripting/js-bindings/manual/js_module_register.cpp @@ -1,7 +1,5 @@ -#ifndef __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ -#define __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ +#include "js_module_register.h" -#include "scripting/js-bindings/manual/ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_ui_auto.hpp" #include "jsb_cocos2dx_studio_auto.hpp" @@ -121,5 +119,7 @@ int js_module_register() return 1; } -#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ - +JSObject* get_jsb_cocos2d_FileUtils_prototype() +{ + return jsb_cocos2d_FileUtils_prototype; +} diff --git a/cocos/scripting/js-bindings/manual/js_module_register.h b/cocos/scripting/js-bindings/manual/js_module_register.h new file mode 100644 index 0000000000..aa06bd0cbe --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_module_register.h @@ -0,0 +1,12 @@ +#ifndef __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ +#define __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ + +#include "scripting/js-bindings/manual/ScriptingCore.h" +#include "js-BindingsExport.h" + +CC_JS_DLL int js_module_register(); + +CC_JS_DLL JSObject* get_jsb_cocos2d_FileUtils_prototype(); + +#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ + diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj index c342f62443..5f59970d93 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj @@ -40,6 +40,7 @@ + @@ -78,6 +79,7 @@ + @@ -87,6 +89,7 @@ + @@ -160,7 +163,7 @@ Level3 Disabled - WIN32;_WINDOWS;_DEBUG;_LIB;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) + WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_USRJSSTATIC;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\navmesh;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true @@ -186,7 +189,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" MinSpace 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) + 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;_USRJSSTATIC;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\navmesh;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true @@ -208,4 +211,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" - + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters index 84a0a0277f..056bf08ba1 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters @@ -113,9 +113,6 @@ manual\cocostudio - - manual\component - manual\extension @@ -167,6 +164,12 @@ manual\navmesh + + manual + + + manual + @@ -253,9 +256,6 @@ manual\cocostudio - - manual\component - manual\extension @@ -310,5 +310,14 @@ manual\navmesh + + auto + + + manual + + + manual + \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h b/cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h new file mode 100644 index 0000000000..1650c27b14 --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h @@ -0,0 +1,33 @@ +#ifndef __LUABINDINGEXPROT_H__ +#define __LUABINDINGEXPROT_H__ + +#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) + #ifdef __MINGW32__ + #include + #endif + + #if defined(_USRLUASTATIC) + #define CC_LUA_DLL + #else + #if defined(_USRLUADLL) + #define CC_LUA_DLL __declspec(dllexport) + #else /* use a DLL library */ + #define CC_LUA_DLL __declspec(dllimport) + #endif + #endif + + /* Define NULL pointer value */ + #ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + #endif +#elif defined(_SHARED_) + #define CC_LUA_DLL __attribute__((visibility("default"))) +#else + #define CC_LUA_DLL +#endif + +#endif /* __CCEXTENSIONEXPORT_H__*/ \ No newline at end of file diff --git a/tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h b/cocos/scripting/lua-bindings/manual/lua_module_register.cpp old mode 100755 new mode 100644 similarity index 78% rename from tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h rename to cocos/scripting/lua-bindings/manual/lua_module_register.cpp index 8b11795f75..05e14e2818 --- a/tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h +++ b/cocos/scripting/lua-bindings/manual/lua_module_register.cpp @@ -1,5 +1,4 @@ -#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ -#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ +#include "lua_module_register.h" #include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h" #include "network/lua_cocos2dx_network_manual.h" @@ -13,7 +12,8 @@ #include "physics3d/lua_cocos2dx_physics3d_manual.h" #include "navmesh/lua_cocos2dx_navmesh_manual.h" -static int lua_module_register(lua_State* L) + +int lua_module_register(lua_State* L) { //Dont' change the module register order unless you know what your are doing register_cocosdenshion_module(L); @@ -34,5 +34,3 @@ static int lua_module_register(lua_State* L) return 1; } -#endif // __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ - diff --git a/cocos/scripting/lua-bindings/manual/lua_module_register.h b/cocos/scripting/lua-bindings/manual/lua_module_register.h new file mode 100644 index 0000000000..97cbdacd6d --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/lua_module_register.h @@ -0,0 +1,10 @@ +#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ +#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ + +#include "lua.h" +#include "Lua-bindingsExport.h" + +CC_LUA_DLL int lua_module_register(lua_State* L); + +#endif // __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ + diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index ea9bda518b..8860c1f41d 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -70,6 +70,7 @@ + @@ -145,7 +146,9 @@ + + @@ -282,7 +285,7 @@ Disabled $(EngineRoot);$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\navmesh;$(EngineRoot)external;$(EngineRoot)external\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)cocos\scripting\lua-bindings\manual\navmesh;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_USRLUASTATIC;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL @@ -314,7 +317,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ MinSpace true $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)cocos\scripting\lua-bindings\manual\navmesh;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)external;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_USRLUASTATIC;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -344,4 +347,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ - + \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters index d8b6ddec28..508c67e4d2 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters @@ -297,6 +297,9 @@ manual\navmesh + + manual + @@ -521,6 +524,12 @@ manual\navmesh + + manual + + + manual + diff --git a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp index 5d9d636d29..02209c6511 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp +++ b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp @@ -15,6 +15,7 @@ #include "runtime/FileServer.h" // js +#include "scripting/js-bindings/manual/ScriptingCore.h" #include "js_module_register.h" @@ -146,10 +147,10 @@ void register_FileUtils(JSContext *cx, JS::HandleObject global) } else { ns.set(nsval.toObjectOrNull()); } - - JS::RootedObject proto(cx, jsb_cocos2d_FileUtils_prototype); - JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); - JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JSObject* fileUtils = get_jsb_cocos2d_FileUtils_prototype(); + JS::RootedObject proto(cx, fileUtils); + JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); } RuntimeJsImpl* RuntimeJsImpl::create() diff --git a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp index 0a43b2265e..0167380df4 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp +++ b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp @@ -20,8 +20,6 @@ #include "runtime/ConfigParser.h" #include "runtime/FileServer.h" -extern std::string g_projectPath; // Runtime.cpp - USING_NS_CC; using namespace std; diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj b/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj index 96b2231170..6afdd8a643 100644 --- a/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj +++ b/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj @@ -1,4 +1,4 @@ - + @@ -21,7 +21,7 @@ Unicode v110 v120 - v140 + v140 v140_xp @@ -30,7 +30,7 @@ Unicode v110 v120 - v140 + v140 v140_xp @@ -76,7 +76,7 @@ ProgramDatabase EnableFastChecks Disabled - WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRLUASTATIC;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) 4267;4251;4244;%(DisableSpecificWarnings) true $(IntDir)vc$(PlatformToolsetVersion).pdb @@ -141,7 +141,7 @@ xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32" MultiThreadedDLL Sync ProgramDatabase - COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions) + COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRLUASTATIC;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) 4267;4251;4244;%(DisableSpecificWarnings) true $(IntDir)vc$(PlatformToolsetVersion).pdb @@ -244,4 +244,4 @@ xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32" - + \ No newline at end of file diff --git a/tools/simulator/libsimulator/lib/AppEvent.h b/tools/simulator/libsimulator/lib/AppEvent.h index 0810ac5769..f284313ee8 100644 --- a/tools/simulator/libsimulator/lib/AppEvent.h +++ b/tools/simulator/libsimulator/lib/AppEvent.h @@ -15,6 +15,7 @@ #include "json/filestream.h" #include "json/stringbuffer.h" #include "json/writer.h" +#include "SimulatorExport.h" enum { @@ -25,7 +26,7 @@ enum #define kAppEventDropName "APP.EVENT.DROP" #define kAppEventName "APP.EVENT" -class AppEvent : public cocos2d::EventCustom +class CC_LIBSIM_DLL AppEvent : public cocos2d::EventCustom { public: /** Constructor */ diff --git a/tools/simulator/libsimulator/lib/AppLang.h b/tools/simulator/libsimulator/lib/AppLang.h index 8fc1c4f801..8884c9eaae 100644 --- a/tools/simulator/libsimulator/lib/AppLang.h +++ b/tools/simulator/libsimulator/lib/AppLang.h @@ -11,8 +11,9 @@ #include "json/document.h" #include "DeviceEx.h" +#include "SimulatorExport.h" -class AppLang +class CC_LIBSIM_DLL AppLang { public: static AppLang* getInstance(); diff --git a/tools/simulator/libsimulator/lib/DeviceEx.h b/tools/simulator/libsimulator/lib/DeviceEx.h index 7a168ef93f..d7a139bbb4 100644 --- a/tools/simulator/libsimulator/lib/DeviceEx.h +++ b/tools/simulator/libsimulator/lib/DeviceEx.h @@ -2,10 +2,11 @@ #include #include "PlayerMacros.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class DeviceEx +class CC_LIBSIM_DLL DeviceEx { public: static DeviceEx *getInstance(); diff --git a/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h b/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h index dae521824b..8f2e443427 100644 --- a/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h +++ b/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h @@ -7,6 +7,7 @@ #include "cocos2d.h" #include "PlayerMacros.h" #include "PlayerServiceProtocol.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN @@ -15,7 +16,7 @@ PLAYER_NS_BEGIN #define kPlayerCtrlModifyKey "ctrl" #define kPlayerAltModifyKey "alt" -class PlayerMenuItem : public cocos2d::Ref +class CC_LIBSIM_DLL PlayerMenuItem : public cocos2d::Ref { public: virtual ~PlayerMenuItem(); diff --git a/tools/simulator/libsimulator/lib/PlayerProtocol.h b/tools/simulator/libsimulator/lib/PlayerProtocol.h index 2c21eb6b37..e5a20c0b7e 100644 --- a/tools/simulator/libsimulator/lib/PlayerProtocol.h +++ b/tools/simulator/libsimulator/lib/PlayerProtocol.h @@ -12,10 +12,11 @@ #include "PlayerTaskServiceProtocol.h" #include "ProjectConfig/ProjectConfig.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class PlayerProtocol +class CC_LIBSIM_DLL PlayerProtocol { public: virtual ~PlayerProtocol(); diff --git a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h index 0f2d0a10b8..75244ab4cb 100644 --- a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h +++ b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h @@ -8,6 +8,7 @@ using namespace std; #include "cocos2d.h" +#include "SimulatorExport.h" #define kCCRuntimeDebuggerNone 0 #define kCCRuntimeDebuggerLDT 1 @@ -37,7 +38,7 @@ using namespace std; #define kProjectConfigUploadPort 6020 #define kProjectConfigDebugPort 5086 -class ProjectConfig +class CC_LIBSIM_DLL ProjectConfig { public: ProjectConfig(); diff --git a/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h b/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h index e8306272f4..d1d0343f09 100644 --- a/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h +++ b/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h @@ -8,6 +8,7 @@ using namespace std; #include "cocos2d.h" +#include "SimulatorExport.h" #if defined(_WINDOWS) #define DIRECTORY_SEPARATOR "\\" @@ -33,7 +34,7 @@ typedef struct _SimulatorScreenSize { typedef vector ScreenSizeArray; typedef ScreenSizeArray::iterator ScreenSizeArrayIterator; -class SimulatorConfig +class CC_LIBSIM_DLL SimulatorConfig { public: static SimulatorConfig *getInstance(); diff --git a/tools/simulator/libsimulator/lib/SimulatorExport.h b/tools/simulator/libsimulator/lib/SimulatorExport.h new file mode 100644 index 0000000000..d71d12d824 --- /dev/null +++ b/tools/simulator/libsimulator/lib/SimulatorExport.h @@ -0,0 +1,30 @@ +#pragma once + +#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) + #ifdef __MINGW32__ + #include + #endif + + #if defined(_USRLIBSIMSTATIC) + #define CC_LIBSIM_DLL + #else + #if defined(_USRLIBSIMDLL) + #define CC_LIBSIM_DLL __declspec(dllexport) + #else /* use a DLL library */ + #define CC_LIBSIM_DLL __declspec(dllimport) + #endif + #endif + + /* Define NULL pointer value */ + #ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + #endif +#elif defined(_SHARED_) + #define CC_LIBSIM_DLL __attribute__((visibility("default"))) +#else + #define CC_LIBSIM_DLL +#endif diff --git a/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h b/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h index 3d0c13a9ac..d50b8fbb81 100644 --- a/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h +++ b/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h @@ -8,10 +8,11 @@ #include "cocos2d.h" #include "stdafx.h" #include "PlayerMenuServiceProtocol.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class PlayerMenuItemWin : public PlayerMenuItem +class CC_LIBSIM_DLL PlayerMenuItemWin : public PlayerMenuItem { public: static PlayerMenuItemWin *create(const std::string &menuId, const std::string &title); @@ -34,7 +35,7 @@ protected: friend class PlayerMenuServiceWin; }; -class PlayerMenuServiceWin : public PlayerMenuServiceProtocol +class CC_LIBSIM_DLL PlayerMenuServiceWin : public PlayerMenuServiceProtocol { public: PlayerMenuServiceWin(HWND hwnd); diff --git a/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h b/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h index ab934147ba..58a06b9dd6 100644 --- a/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h +++ b/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h @@ -9,10 +9,11 @@ #include "PlayerFileDialogServiceWin.h" #include "PlayerEditBoxServiceWin.h" #include "PlayerTaskServiceWin.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class PlayerWin : public PlayerProtocol, public cocos2d::Ref +class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cocos2d::Ref { public: static PlayerWin *createWithHwnd(HWND hWnd); diff --git a/tools/simulator/libsimulator/lib/runtime/ConfigParser.h b/tools/simulator/libsimulator/lib/runtime/ConfigParser.h index 20ad87649f..cbddf3ac94 100644 --- a/tools/simulator/libsimulator/lib/runtime/ConfigParser.h +++ b/tools/simulator/libsimulator/lib/runtime/ConfigParser.h @@ -7,13 +7,15 @@ #include "json/document.h" #include "ProjectConfig/SimulatorConfig.h" #include "ProjectConfig/ProjectConfig.h" +#include "SimulatorExport.h" + using namespace std; USING_NS_CC; #define CONFIG_FILE "config.json" typedef vector ScreenSizeArray; -class ConfigParser +class CC_LIBSIM_DLL ConfigParser { public: static ConfigParser *getInstance(void); diff --git a/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp b/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp index 7ee8a1fde8..3798703eed 100644 --- a/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp +++ b/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp @@ -211,8 +211,10 @@ void ConsoleCommand::onSendCommand(int fd, const std::string &args) } else if(strcmp(strcmd.c_str(), "shutdownapp") == 0) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - extern void shutDownApp(); - shutDownApp(); +#include + auto glview = dynamic_cast (Director::getInstance()->getOpenGLView()); + HWND hWnd = glview->getWin32Window(); + ::SendMessage(hWnd, WM_CLOSE, NULL, NULL); #else exit(0); #endif diff --git a/tools/simulator/libsimulator/lib/runtime/FileServer.cpp b/tools/simulator/libsimulator/lib/runtime/FileServer.cpp index 0c037341b3..b450589d8b 100644 --- a/tools/simulator/libsimulator/lib/runtime/FileServer.cpp +++ b/tools/simulator/libsimulator/lib/runtime/FileServer.cpp @@ -257,7 +257,7 @@ _responseEndThread(false) _writePath = FileUtils::getInstance()->getWritablePath(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - std::string getCurAppName(void); +#include "Widget_mac.h" _writePath += getCurAppName(); _writePath += "/"; #endif diff --git a/tools/simulator/libsimulator/lib/runtime/FileServer.h b/tools/simulator/libsimulator/lib/runtime/FileServer.h index 026c068f8f..655c9b19b7 100644 --- a/tools/simulator/libsimulator/lib/runtime/FileServer.h +++ b/tools/simulator/libsimulator/lib/runtime/FileServer.h @@ -32,6 +32,7 @@ THE SOFTWARE. #include "json/writer.h" #include "Protos.pb.h" #include +#include "SimulatorExport.h" // header files for socket #ifdef _WIN32 @@ -53,7 +54,7 @@ THE SOFTWARE. #include #endif -class FileServer +class CC_LIBSIM_DLL FileServer { static FileServer *s_sharedFileServer; public: diff --git a/tools/simulator/libsimulator/lib/runtime/Runtime.cpp b/tools/simulator/libsimulator/lib/runtime/Runtime.cpp index bfff76b9f7..427e12bfdc 100644 --- a/tools/simulator/libsimulator/lib/runtime/Runtime.cpp +++ b/tools/simulator/libsimulator/lib/runtime/Runtime.cpp @@ -190,10 +190,28 @@ void RuntimeEngine::setProjectPath(const std::string &workPath) if (workPath.empty()) { - extern std::string getCurAppPath(); - std::string appPath = getCurAppPath(); + std::string appPath = std::string(""); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - appPath.append("/../../"); + TCHAR szAppDir[MAX_PATH] = { 0 }; + if (GetModuleFileName(NULL, szAppDir, MAX_PATH)) + { + int nEnd = 0; + for (int i = 0; szAppDir[i]; i++) + { + if (szAppDir[i] == '\\') + nEnd = i; + } + szAppDir[nEnd] = 0; + int iLen = 2 * wcslen(szAppDir); + char* chRtn = new char[iLen + 1]; + wcstombs(chRtn, szAppDir, iLen + 1); + std::string strPath = chRtn; + delete[] chRtn; + chRtn = NULL; + char fuldir[MAX_PATH] = { 0 }; + _fullpath(fuldir, strPath.c_str(), MAX_PATH); + appPath = fuldir; + } #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) appPath.append("/../../../"); #endif diff --git a/tools/simulator/libsimulator/lib/runtime/Runtime.h b/tools/simulator/libsimulator/lib/runtime/Runtime.h index d3e0a0822a..a2607fb1de 100644 --- a/tools/simulator/libsimulator/lib/runtime/Runtime.h +++ b/tools/simulator/libsimulator/lib/runtime/Runtime.h @@ -28,14 +28,17 @@ THE SOFTWARE. #include #include #include +#include "SimulatorExport.h" void recvBuf(int fd, char *pbuf, unsigned long bufsize); void sendBuf(int fd, const char *pbuf, unsigned long bufsize); -std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value); +CC_LIBSIM_DLL extern std::string g_projectPath; -std::string getIPAddress(); +CC_LIBSIM_DLL std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value); + +CC_LIBSIM_DLL std::string getIPAddress(); const char* getRuntimeVersion(); diff --git a/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h b/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h index fe5f1771ba..84b935591f 100644 --- a/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h +++ b/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h @@ -9,8 +9,9 @@ #include #include "json/document.h" +#include "SimulatorExport.h" -class RuntimeProtocol +class CC_LIBSIM_DLL RuntimeProtocol { public: virtual void end(); diff --git a/tools/simulator/libsimulator/lib/runtime/Widget_mac.h b/tools/simulator/libsimulator/lib/runtime/Widget_mac.h new file mode 100644 index 0000000000..79bd4e7542 --- /dev/null +++ b/tools/simulator/libsimulator/lib/runtime/Widget_mac.h @@ -0,0 +1,12 @@ +// +// Widget_mac.h +// Simulator +// +// + +#ifndef libsimulator_studio_Widget_mac_h +#define libsimulator_studio_Widget_mac_h + +std::string getCurAppName(void); + +#endif diff --git a/tools/simulator/libsimulator/lib/runtime/Widget_mac.mm b/tools/simulator/libsimulator/lib/runtime/Widget_mac.mm new file mode 100644 index 0000000000..49e73074fd --- /dev/null +++ b/tools/simulator/libsimulator/lib/runtime/Widget_mac.mm @@ -0,0 +1,20 @@ +// +// Widget_mac.cpp +// Simulator +// +// + +#include +#include "Widget_mac.h" + +using namespace std; + +std::string getCurAppName(void) +{ + string appName = [[[NSProcessInfo processInfo] processName] UTF8String]; + size_t found = appName.find(" "); + if (found!=std::string::npos) + appName = appName.substr(0,found); + + return appName; +} diff --git a/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj b/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj index fe88156831..2163b5ba7b 100644 --- a/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj +++ b/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj @@ -60,7 +60,7 @@ NotUsing Level3 Disabled - WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS + WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;_USRLIBSIMSTATIC $(ProjectDir);$(ProjectDir)..\lib\protobuf-lite;$(ProjectDir)..\lib;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) @@ -84,7 +84,7 @@ MinSpace true true - COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS + COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) true $(ProjectDir);$(ProjectDir)..\lib\protobuf-lite;$(ProjectDir)..\lib;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) CompileAsCpp From 145943068f7e59f798c2648704275e0fcebef403 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 22:35:02 +0800 Subject: [PATCH 136/192] Add missing function export --- cocos/scripting/js-bindings/manual/ScriptingCore.h | 3 ++- cocos/scripting/js-bindings/manual/js_manual_conversions.h | 7 ++++--- cocos/scripting/lua-bindings/manual/LuaBasicConversions.h | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 5f472a8f45..9219a0bc4e 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -35,6 +35,7 @@ #include "spidermonkey_specifics.h" #include "js_manual_conversions.h" #include "mozilla/Maybe.h" +#include "js-BindingsExport.h" #include #include @@ -75,7 +76,7 @@ public: * - Invoke garbage collection of JavaScript context * - etc... */ -class ScriptingCore : public cocos2d::ScriptEngineProtocol +class CC_JS_DLL ScriptingCore : public cocos2d::ScriptEngineProtocol { private: JSRuntime *_rt; diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index cd60c4d62c..29f38f393e 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -31,6 +31,7 @@ #include "js_bindings_config.h" #include "cocos2d.h" #include "spidermonkey_specifics.h" +#include "js-BindingsExport.h" #define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES @@ -98,7 +99,7 @@ bool jsval_to_uint16( JSContext *cx, JS::HandleValue vp, uint16_t *ret ); bool jsval_to_long( JSContext *cx, JS::HandleValue vp, long *out); bool jsval_to_ulong( JSContext *cx, JS::HandleValue vp, unsigned long *out); bool jsval_to_long_long(JSContext *cx, JS::HandleValue v, long long* ret); -bool jsval_to_std_string(JSContext *cx, JS::HandleValue v, std::string* ret); +CC_JS_DLL bool jsval_to_std_string(JSContext *cx, JS::HandleValue v, std::string* ret); bool jsval_to_ccpoint(JSContext *cx, JS::HandleValue v, cocos2d::Point* ret); bool jsval_to_ccrect(JSContext *cx, JS::HandleValue v, cocos2d::Rect* ret); bool jsval_to_ccsize(JSContext *cx, JS::HandleValue v, cocos2d::Size* ret); @@ -117,7 +118,7 @@ bool jsval_to_ray(JSContext *cx, JS::HandleValue vp, cocos2d::Ray* ret); bool jsval_to_resoucedata(JSContext *cx, JS::HandleValue v, cocos2d::ResouceData* ret); // forward declaration -js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); +CC_JS_DLL js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); template bool jsvals_variadic_to_ccvector( JSContext *cx, /*jsval *vp, int argc,*/const JS::CallArgs& args, cocos2d::Vector* ret) @@ -184,7 +185,7 @@ bool jsval_to_ccvaluemap(JSContext* cx, JS::HandleValue v, cocos2d::ValueMap* re bool jsval_to_ccvaluemapintkey(JSContext* cx, JS::HandleValue v, cocos2d::ValueMapIntKey* ret); bool jsval_to_ccvaluevector(JSContext* cx, JS::HandleValue v, cocos2d::ValueVector* ret); bool jsval_to_ssize( JSContext *cx, JS::HandleValue vp, ssize_t* ret); -bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector* ret); +CC_JS_DLL bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector* ret); bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector* ret); bool jsval_to_std_vector_float( JSContext *cx, JS::HandleValue vp, std::vector* ret); bool jsval_to_matrix(JSContext *cx, JS::HandleValue vp, cocos2d::Mat4* ret); diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h index cf46e70d6f..f9679d3a13 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -30,6 +30,7 @@ extern "C" { } #include "tolua_fix.h" #include "cocos2d.h" +#include "Lua-BindingsExport.h" using namespace cocos2d; @@ -145,7 +146,7 @@ extern bool luaval_to_uint16(lua_State* L,int lo,uint16_t* outValue, const char* * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given accpetable index of stack is a number or a string convertible to a number, otherwise return false. */ -extern bool luaval_to_boolean(lua_State* L,int lo,bool* outValue, const char* funcName = ""); +extern CC_LUA_DLL bool luaval_to_boolean(lua_State* L,int lo,bool* outValue, const char* funcName = ""); /** * Get a double value from the given accpetable index of stack. @@ -181,7 +182,7 @@ extern bool luaval_to_long_long(lua_State* L,int lo,long long* outValue, const c * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given acceptable index of stack is a string or a number convertible to a string, otherwise return false. */ -extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue, const char* funcName = ""); +extern CC_LUA_DLL bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue, const char* funcName = ""); /** * Get a long value from the given accpetable index of stack. @@ -569,7 +570,7 @@ bool luaval_to_ccvector(lua_State* L, int lo , cocos2d::Vector* ret, const ch * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given accpetable index of stack is a table, otherwise return false. */ -bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector* ret, const char* funcName = ""); +CC_LUA_DLL bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector* ret, const char* funcName = ""); /** * Get a pointer points to a std::vector from a Lua array table in the stack. From 928dc3ab1f0d893ab16ad063826af2c2ce7e32c9 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 23:03:25 +0800 Subject: [PATCH 137/192] Add lua value conversion function for cocos studio --- .../lua-bindings/manual/LuaBasicConversions.cpp | 10 ++++++++++ .../lua-bindings/manual/LuaBasicConversions.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp index c3b51ccaec..f8605d7f9f 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -3386,3 +3386,13 @@ bool luaval_to_std_map_string_string(lua_State* L, int lo, std::map(L, lo, type, node); +} + +void node_to_luaval(lua_State* L, const char* type, cocos2d::Node* node) +{ + object_to_luaval(L, type, node); +} diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h index f9679d3a13..9f624378bd 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -1294,6 +1294,10 @@ void std_vector_vec3_to_luaval(lua_State* L, const std::vector& i */ void std_map_string_string_to_luaval(lua_State* L, const std::map& inValue); +// Follow 2 function is added for Cocos Studio to make lua lib can be compile as dynamic library +CC_LUA_DLL extern bool luaval_to_node(lua_State* L, int lo, const char* type, cocos2d::Node** node); +CC_LUA_DLL extern void node_to_luaval(lua_State* L, const char* type, cocos2d::Node* node); + // end group /// @} #endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ From da9e8548a027323ba2026f5918aa04ceaf9f03ab Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 25 Nov 2015 17:29:11 +0000 Subject: [PATCH 138/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../api/jsb_cocos2dx_3d_extension_auto_api.js | 12 +++++ .../auto/jsb_cocos2dx_3d_extension_auto.cpp | 23 +++++++++ .../auto/jsb_cocos2dx_3d_extension_auto.hpp | 1 + .../auto/api/PUParticleSystem3D.lua | 7 +++ .../auto/lua_cocos2dx_extension_auto.cpp | 51 +++++++++++++++++++ .../auto/lua_cocos2dx_extension_auto.hpp | 1 + 6 files changed, 95 insertions(+) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js index 2a5567ec3b..a8e7c2e3d9 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js @@ -474,6 +474,18 @@ removeAllListener : function ( { }, +/** + * @method initSystem + * @param {String} arg0 + * @return {bool} + */ +initSystem : function ( +str +) +{ + return false; +}, + /** * @method setDefaultDepth * @param {float} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp index fe3e492a08..d87d9dc80b 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp @@ -1020,6 +1020,28 @@ bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener(JSContext *cx JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_3d_extension_PUParticleSystem3D_initSystem(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::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_initSystem : 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_3d_extension_PUParticleSystem3D_initSystem : Error processing arguments"); + bool ret = cobj->initSystem(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_initSystem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1191,6 +1213,7 @@ void js_register_cocos2dx_3d_extension_PUParticleSystem3D(JSContext *cx, JS::Han JS_FN("getDerivedScale", js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDefaultHeight", js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllListener", js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initSystem", js_cocos2dx_3d_extension_PUParticleSystem3D_initSystem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDefaultDepth", js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp index e71c2a6f30..a10e2073e3 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp @@ -67,6 +67,7 @@ bool js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity( bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_initSystem(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_PUParticleSystem3D_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_PUParticleSystem3D_PUParticleSystem3D(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/PUParticleSystem3D.lua b/cocos/scripting/lua-bindings/auto/api/PUParticleSystem3D.lua index fd0a4e634d..bb7a484be9 100644 --- a/cocos/scripting/lua-bindings/auto/api/PUParticleSystem3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/PUParticleSystem3D.lua @@ -247,6 +247,13 @@ -- @param self -- @return PUParticleSystem3D#PUParticleSystem3D self (return value: cc.PUParticleSystem3D) +-------------------------------- +-- +-- @function [parent=#PUParticleSystem3D] initSystem +-- @param self +-- @param #string filePath +-- @return bool#bool ret (return value: bool) + -------------------------------- -- -- @function [parent=#PUParticleSystem3D] makeParticleLocal diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp index 4b8b6b0660..895c676c35 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp @@ -15800,6 +15800,56 @@ int lua_cocos2dx_extension_PUParticleSystem3D_removeAllListener(lua_State* tolua return 0; } +int lua_cocos2dx_extension_PUParticleSystem3D_initSystem(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PUParticleSystem3D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PUParticleSystem3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PUParticleSystem3D*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_PUParticleSystem3D_initSystem'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.PUParticleSystem3D:initSystem"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_extension_PUParticleSystem3D_initSystem'", nullptr); + return 0; + } + bool ret = cobj->initSystem(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PUParticleSystem3D:initSystem",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_PUParticleSystem3D_initSystem'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_extension_PUParticleSystem3D_makeParticleLocal(lua_State* tolua_S) { int argc = 0; @@ -16146,6 +16196,7 @@ int lua_register_cocos2dx_extension_PUParticleSystem3D(lua_State* tolua_S) tolua_function(tolua_S,"getDerivedScale",lua_cocos2dx_extension_PUParticleSystem3D_getDerivedScale); tolua_function(tolua_S,"setDefaultHeight",lua_cocos2dx_extension_PUParticleSystem3D_setDefaultHeight); tolua_function(tolua_S,"removeAllListener",lua_cocos2dx_extension_PUParticleSystem3D_removeAllListener); + tolua_function(tolua_S,"initSystem",lua_cocos2dx_extension_PUParticleSystem3D_initSystem); tolua_function(tolua_S,"makeParticleLocal",lua_cocos2dx_extension_PUParticleSystem3D_makeParticleLocal); tolua_function(tolua_S,"removerAllObserver",lua_cocos2dx_extension_PUParticleSystem3D_removerAllObserver); tolua_function(tolua_S,"setDefaultDepth",lua_cocos2dx_extension_PUParticleSystem3D_setDefaultDepth); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp index f309a39591..c7a29df579 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp @@ -341,6 +341,7 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); + #endif // __cocos2dx_extension_h__ From b89700b7d61770603c3ccb785e21c4c2e397280a Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 26 Nov 2015 10:30:36 +0800 Subject: [PATCH 139/192] Update CHANGELOG --- CHANGELOG | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 11d90e6978..42a8140a40 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,24 @@ +cocos2d-x-3.10 December ? 2015 +[NEW] Core: Added Application::getVersion() to get the app version. + +[REFINE] UI: RichText support new line element. +[REFINE] UI: Set focus to Widget when touched. +[REFINE] UI: Change PageView to derived from ListView. +[REFINE] UI: Rewrite Scale9Sprite and improve the scale9sprite performance and reduce memory consumption. +[REFINE] 3D: Change char* to string in Terrain. +[REFINE] Editor: Merge Studio ActionTimeLine change back into engine. +[REFINe] Mac: Make engine compatible for 32bit Mac. + +[FIX] Core: Fix premultiplyAlpha for mipmaps and compressed textures. +[FIX] UI: Fix Scale9sprite rendering error when content size smaller than the sum of leftInset and rightInset. +[FIX] Win32: Fix EditBox crash when removing an EditBox in a scheduler. +[FIX] Android: Fix cannot add view to mFrameLayout when extends Cocos2dxActivity. +[FIX] 2D: Fixed actionNode position error bug. +[FIX] 3D: Fix the movement of PUParticle lags one frame. +[FIX] UI: Fix the wront argument of setPlaceholderFontName in EditBox. +[FIX] UI: Fix EditBox editBoxEditingDidEnd may use the original text after change the text of EditBox in user script. +[FIX] Audio: Fix `FinishCallback` never be called in Windows. + cocos2d-x-3.9 November.09 2015 [NEW] Label: Added line spacing/leading feature to Label. From 5221f8a6fc76bf6566f8424a15378848f2fbd761 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 26 Nov 2015 12:03:18 +0800 Subject: [PATCH 140/192] improve the code by code review suggestions. --- cocos/2d/CCFontAtlas.cpp | 3 +-- cocos/2d/CCLabel.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index 4dbb0f72d4..37c360294d 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -160,13 +160,12 @@ void FontAtlas::addLetterDefinition(char16_t utf16Char, const FontLetterDefiniti void FontAtlas::scaleFontLetterDefinition(float scaleFactor) { for (auto&& fontDefinition : _letterDefinitions) { - FontLetterDefinition letterDefinition = fontDefinition.second; + auto& letterDefinition = fontDefinition.second; letterDefinition.width *= scaleFactor; letterDefinition.height *= scaleFactor; letterDefinition.offsetX *= scaleFactor; letterDefinition.offsetY *= scaleFactor; letterDefinition.xAdvance *= scaleFactor; - _letterDefinitions[fontDefinition.first] = letterDefinition; } } diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index e9d3e93906..ede619ef3a 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -580,7 +580,7 @@ bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& ima } } - if(fontSize > 0){ + if(fontSize > 0.0f){ _bmFontSize = fontSize; } From d744c167b7d54ddec3ba312276eeeacbadd1914f Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 26 Nov 2015 13:49:32 +0800 Subject: [PATCH 141/192] Fix button texture loaded mark has set to wrong value bug --- cocos/ui/UIButton.cpp | 33 ++++++++++++++++++--------------- cocos/ui/UIButton.h | 6 +++--- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 25be951bec..bfdd983805 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -232,10 +232,11 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) { _normalFileName = normal; _normalTexType = texType; - + bool textureLoaded = true; if (normal.empty()) { _buttonNormalRenderer->init(); + textureLoaded = false; } else { @@ -251,10 +252,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) break; } } - this->setupNormalTexture(); + this->setupNormalTexture(textureLoaded); } -void Button::setupNormalTexture() +void Button::setupNormalTexture(bool textureLoaded) { _normalTextureSize = _buttonNormalRenderer->getContentSize(); // force update _customSize, fixed issue: @@ -274,24 +275,25 @@ void Button::setupNormalTexture() { updateContentSizeWithTextureSize(_normalTextureSize); } - _normalTextureLoaded = true; + _normalTextureLoaded = textureLoaded; _normalTextureAdaptDirty = true; } void Button::loadTextureNormal(SpriteFrame* normalSpriteFrame) { _buttonNormalRenderer->initWithSpriteFrame(normalSpriteFrame); - this->setupNormalTexture(); + this->setupNormalTexture(nullptr != normalSpriteFrame); } void Button::loadTexturePressed(const std::string& selected,TextureResType texType) { _clickedFileName = selected; _pressedTexType = texType; - + bool textureLoade = true; if (selected.empty()) { _buttonClickedRenderer->init(); + textureLoade = false; } else { @@ -307,33 +309,34 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy break; } } - this->setupPressedTexture(); + this->setupPressedTexture(textureLoade); } -void Button::setupPressedTexture() +void Button::setupPressedTexture(bool textureLoaded) { _pressedTextureSize = _buttonClickedRenderer->getContentSize(); this->updateChildrenDisplayedRGBA(); - _pressedTextureLoaded = true; + _pressedTextureLoaded = textureLoaded; _pressedTextureAdaptDirty = true; } void Button::loadTexturePressed(SpriteFrame* pressedSpriteFrame) { _buttonClickedRenderer->initWithSpriteFrame(pressedSpriteFrame); - this->setupPressedTexture(); + this->setupPressedTexture(nullptr != pressedSpriteFrame); } void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType) { _disabledFileName = disabled; _disabledTexType = texType; - + bool textureLoaded = true; if (disabled.empty()) { _buttonDisabledRenderer->init(); + textureLoaded = false; } else { @@ -349,23 +352,23 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT break; } } - this->setupDisabledTexture(); + this->setupDisabledTexture(textureLoaded); } -void Button::setupDisabledTexture() +void Button::setupDisabledTexture(bool textureLoaded) { _disabledTextureSize = _buttonDisabledRenderer->getContentSize(); this->updateChildrenDisplayedRGBA(); - _disabledTextureLoaded = true; + _disabledTextureLoaded = textureLoaded; _disabledTextureAdaptDirty = true; } void Button::loadTextureDisabled(SpriteFrame* disabledSpriteFrame) { _buttonDisabledRenderer->initWithSpriteFrame(disabledSpriteFrame); - this->setupDisabledTexture(); + this->setupDisabledTexture(nullptr != disabledSpriteFrame); } void Button::setCapInsets(const Rect &capInsets) diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index f216c907c3..1cb996f3ef 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -322,11 +322,11 @@ protected: virtual void onSizeChanged() override; void loadTextureNormal(SpriteFrame* normalSpriteFrame); - void setupNormalTexture(); + void setupNormalTexture(bool textureLoaded); void loadTexturePressed(SpriteFrame* pressedSpriteFrame); - void setupPressedTexture(); + void setupPressedTexture(bool textureLoaded); void loadTextureDisabled(SpriteFrame* disabledSpriteFrame); - void setupDisabledTexture(); + void setupDisabledTexture(bool textureLoaded); void normalTextureScaleChangedWithSize(); void pressedTextureScaleChangedWithSize(); From 3296476c43424abcb6288ab10ab7b7a33d44b5d5 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 26 Nov 2015 05:53:45 +0000 Subject: [PATCH 142/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 9ecf2ac219..4a42163666 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -402,6 +402,8 @@ "cocos/base/CCScheduler.h", "cocos/base/CCScriptSupport.cpp", "cocos/base/CCScriptSupport.h", + "cocos/base/CCStencilStateManager.cpp", + "cocos/base/CCStencilStateManager.hpp", "cocos/base/CCTouch.cpp", "cocos/base/CCTouch.h", "cocos/base/CCUserDefault-android.cpp", From 6321357c564e56e3143f7ae1c4dd4d077b7b292d Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 26 Nov 2015 13:54:34 +0800 Subject: [PATCH 143/192] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 42a8140a40..30f44ad00a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ cocos2d-x-3.10 December ? 2015 [FIX] UI: Fix the wront argument of setPlaceholderFontName in EditBox. [FIX] UI: Fix EditBox editBoxEditingDidEnd may use the original text after change the text of EditBox in user script. [FIX] Audio: Fix `FinishCallback` never be called in Windows. +[FIX] UI: Fix Layout stencil clipping nested with Clipping Node rendering issue. cocos2d-x-3.9 November.09 2015 From 390a37e1239691cfda430e59c379de3ee9b7fb5d Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 26 Nov 2015 05:56:34 +0000 Subject: [PATCH 144/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 9ecf2ac219..4a42163666 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -402,6 +402,8 @@ "cocos/base/CCScheduler.h", "cocos/base/CCScriptSupport.cpp", "cocos/base/CCScriptSupport.h", + "cocos/base/CCStencilStateManager.cpp", + "cocos/base/CCStencilStateManager.hpp", "cocos/base/CCTouch.cpp", "cocos/base/CCTouch.h", "cocos/base/CCUserDefault-android.cpp", From 58912c88b949fd17ac5a56f244bbfe1dc58e77ad Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 26 Nov 2015 06:00:46 +0000 Subject: [PATCH 145/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 1523739391..be7803f52b 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -2526,7 +2526,7 @@ bool js_cocos2dx_ui_Layout_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -3397,7 +3397,7 @@ bool js_cocos2dx_ui_Button_getDisabledFile(JSContext *cx, uint32_t argc, jsval * if (argc == 0) { cocos2d::ResouceData ret = cobj->getDisabledFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -3471,7 +3471,7 @@ bool js_cocos2dx_ui_Button_getNormalFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -3945,7 +3945,7 @@ bool js_cocos2dx_ui_Button_getPressedFile(JSContext *cx, uint32_t argc, jsval *v if (argc == 0) { cocos2d::ResouceData ret = cobj->getPressedFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4369,7 +4369,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile(JSContext *cx, uint3 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackDisabledFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4387,7 +4387,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile(JSContext *cx, uint if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossDisabeldFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4465,7 +4465,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4503,7 +4503,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackPressedFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4694,7 +4694,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile(JSContext *cx, uint32_ if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -6053,7 +6053,7 @@ bool js_cocos2dx_ui_ImageView_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -7087,7 +7087,7 @@ bool js_cocos2dx_ui_TextAtlas_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -7412,7 +7412,7 @@ bool js_cocos2dx_ui_LoadingBar_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -9934,7 +9934,7 @@ bool js_cocos2dx_ui_Slider_getBallNormalFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -9990,7 +9990,7 @@ bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallPressedFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -10132,7 +10132,7 @@ bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getProgressBarFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -10198,7 +10198,7 @@ bool js_cocos2dx_ui_Slider_getBackFile(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -10274,7 +10274,7 @@ bool js_cocos2dx_ui_Slider_getBallDisabeldFile(JSContext *cx, uint32_t argc, jsv if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallDisabeldFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -12321,7 +12321,7 @@ bool js_cocos2dx_ui_TextBMFont_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } From 51cfbca5231b426749524a76c09bc475f7c73e47 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 26 Nov 2015 06:02:24 +0000 Subject: [PATCH 146/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 1523739391..be7803f52b 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -2526,7 +2526,7 @@ bool js_cocos2dx_ui_Layout_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -3397,7 +3397,7 @@ bool js_cocos2dx_ui_Button_getDisabledFile(JSContext *cx, uint32_t argc, jsval * if (argc == 0) { cocos2d::ResouceData ret = cobj->getDisabledFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -3471,7 +3471,7 @@ bool js_cocos2dx_ui_Button_getNormalFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -3945,7 +3945,7 @@ bool js_cocos2dx_ui_Button_getPressedFile(JSContext *cx, uint32_t argc, jsval *v if (argc == 0) { cocos2d::ResouceData ret = cobj->getPressedFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4369,7 +4369,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile(JSContext *cx, uint3 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackDisabledFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4387,7 +4387,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile(JSContext *cx, uint if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossDisabeldFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4465,7 +4465,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4503,7 +4503,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackPressedFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -4694,7 +4694,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile(JSContext *cx, uint32_ if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -6053,7 +6053,7 @@ bool js_cocos2dx_ui_ImageView_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -7087,7 +7087,7 @@ bool js_cocos2dx_ui_TextAtlas_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -7412,7 +7412,7 @@ bool js_cocos2dx_ui_LoadingBar_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -9934,7 +9934,7 @@ bool js_cocos2dx_ui_Slider_getBallNormalFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallNormalFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -9990,7 +9990,7 @@ bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallPressedFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -10132,7 +10132,7 @@ bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getProgressBarFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -10198,7 +10198,7 @@ bool js_cocos2dx_ui_Slider_getBackFile(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -10274,7 +10274,7 @@ bool js_cocos2dx_ui_Slider_getBallDisabeldFile(JSContext *cx, uint32_t argc, jsv if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallDisabeldFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } @@ -12321,7 +12321,7 @@ bool js_cocos2dx_ui_TextBMFont_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - jsret = resoucedata_to_jsval(cx, ret); + #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; args.rval().set(jsret); return true; } From 108d145bf026f858325fe1f907a35ea7d9e7601d Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 26 Nov 2015 15:08:49 +0800 Subject: [PATCH 147/192] Add missing luaval and color3b conversion function export --- cocos/scripting/lua-bindings/manual/LuaBasicConversions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h index 9f624378bd..b724a37576 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -245,7 +245,7 @@ extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue, const char* funcN * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given accpetable index of stack is a table, otherwise return false. */ -extern bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue, const char* funcName = ""); +extern CC_LUA_DLL luaval_to_color3b(lua_State* L,int lo,Color3B* outValue, const char* funcName = ""); /** * Get a Color4B object value from the given accpetable index of stack. @@ -906,7 +906,7 @@ extern void rect_to_luaval(lua_State* L,const Rect& rt); * @param L the current lua_State. * @param cc a cocos2d::Color3B object. */ -extern void color3b_to_luaval(lua_State* L,const Color3B& cc); +extern CC_LUA_DLL void color3b_to_luaval(lua_State* L,const Color3B& cc); /** * Push a table converted from a cocos2d::Color4B object into the Lua stack. From 58dd27efd312e950ad59c03529cd17e8ba1499f1 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 26 Nov 2015 17:33:45 +0800 Subject: [PATCH 148/192] add missing return type --- cocos/scripting/lua-bindings/manual/LuaBasicConversions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h index b724a37576..2ef1bc8385 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -245,7 +245,7 @@ extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue, const char* funcN * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given accpetable index of stack is a table, otherwise return false. */ -extern CC_LUA_DLL luaval_to_color3b(lua_State* L,int lo,Color3B* outValue, const char* funcName = ""); +extern CC_LUA_DLL bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue, const char* funcName = ""); /** * Get a Color4B object value from the given accpetable index of stack. From 5a2a343152ca10b10f4d377c0e70f2a07d83118e Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 26 Nov 2015 17:38:32 +0800 Subject: [PATCH 149/192] update code as comment --- tools/simulator/libsimulator/lib/runtime/Widget_mac.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/simulator/libsimulator/lib/runtime/Widget_mac.h b/tools/simulator/libsimulator/lib/runtime/Widget_mac.h index 79bd4e7542..484d7c5b24 100644 --- a/tools/simulator/libsimulator/lib/runtime/Widget_mac.h +++ b/tools/simulator/libsimulator/lib/runtime/Widget_mac.h @@ -4,9 +4,8 @@ // // -#ifndef libsimulator_studio_Widget_mac_h -#define libsimulator_studio_Widget_mac_h +#pragma once -std::string getCurAppName(void); +std::string getCurAppName(); #endif From 24dc9f3392cca81159565f517d1decef8bdd742f Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 26 Nov 2015 17:39:57 +0800 Subject: [PATCH 150/192] update code as comment --- cocos/scripting/js-bindings/manual/js-BindingsExport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/manual/js-BindingsExport.h b/cocos/scripting/js-bindings/manual/js-BindingsExport.h index 2d90b05f42..fcbcc3ef9b 100644 --- a/cocos/scripting/js-bindings/manual/js-BindingsExport.h +++ b/cocos/scripting/js-bindings/manual/js-BindingsExport.h @@ -18,7 +18,7 @@ /* Define NULL pointer value */ #ifndef NULL #ifdef __cplusplus - #define NULL 0 + #define nullptr 0 #else #define NULL ((void *)0) #endif From ae2b75c8beb6cb1fa055361917a6b9f9162196a5 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 01:26:54 +0800 Subject: [PATCH 151/192] Fix issues causing by temporary RootedObject passed as function parameters --- .../manual/3d/jsb_cocos2dx_3d_manual.cpp | 20 +- .../js-bindings/manual/ScriptingCore.cpp | 56 +++-- .../js-bindings/manual/ScriptingCore.h | 29 ++- .../js_bindings_chipmunk_auto_classes.cpp | 225 +++++++++--------- .../chipmunk/js_bindings_chipmunk_manual.cpp | 200 +++++++++------- .../js-bindings/manual/cocos2d_specifics.cpp | 176 +++++++------- .../js-bindings/manual/cocos2d_specifics.hpp | 4 +- .../cocosbuilder/cocosbuilder_specifics.hpp | 4 +- .../cocosbuilder/js_bindings_ccbreader.cpp | 6 +- .../jsb_cocos2dx_studio_conversions.cpp | 3 +- .../cocostudio/jsb_cocos2dx_studio_manual.cpp | 36 +-- .../manual/component/CCComponentJS.cpp | 4 +- ...jsb_cocos2dx_experimental_video_manual.cpp | 3 +- ...b_cocos2dx_experimental_webView_manual.cpp | 9 +- .../jsb_cocos2dx_extension_manual.cpp | 29 ++- .../js-bindings/manual/js_bindings_opengl.cpp | 29 +-- .../manual/js_manual_conversions.cpp | 78 +++--- .../manual/js_manual_conversions.h | 3 +- .../js-bindings/manual/jsb_opengl_manual.cpp | 6 +- .../js_bindings_system_registration.cpp | 9 +- .../jsb_cocos2dx_navmesh_conversions.cpp | 6 +- .../navmesh/jsb_cocos2dx_navmesh_manual.cpp | 3 +- .../manual/network/XMLHTTPRequest.cpp | 9 +- .../manual/network/jsb_socketio.cpp | 6 +- .../manual/network/jsb_websocket.cpp | 10 +- .../jsb_cocos2dx_physics3d_manual.cpp | 42 ++-- .../platform/ios/JavaScriptObjCBridge.mm | 12 +- .../manual/spidermonkey_specifics.h | 5 +- .../spine/jsb_cocos2dx_spine_manual.cpp | 50 ++-- .../manual/ui/jsb_cocos2dx_ui_manual.cpp | 21 +- .../Classes/js_DrawNode3D_bindings.cpp | 26 +- .../project/Classes/js_Effect3D_bindings.cpp | 40 +--- tools/bindings-generator | 2 +- 33 files changed, 624 insertions(+), 537 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp index 23375d23e8..0929d7f396 100644 --- a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp @@ -350,22 +350,26 @@ void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global) get_or_create_js_obj(cx, global, "jsb", &ccObj); JS_GetProperty(cx, ccObj, "Sprite3D", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); + tmpObj.set(tmpVal.toObjectOrNull()); JS_DefineFunction(cx, tmpObj, "createAsync", js_cocos2dx_Sprite3D_createAsync, 4, JSPROP_READONLY | JSPROP_PERMANENT); JS_GetProperty(cx, ccObj, "Terrain", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); + tmpObj.set(tmpVal.toObjectOrNull()); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_Terrain_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_GetProperty(cx, ccObj, "Bundle3D", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); + tmpObj.set(tmpVal.toObjectOrNull()); JS_DefineFunction(cx, tmpObj, "getTrianglesList", js_cocos2dx_Bundle3D_getTrianglesList, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), "getAABB", js_cocos2dx_Sprite3D_getAABB, 0, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Sprite3D_prototype); + JS_DefineFunction(cx, tmpObj, "getAABB", js_cocos2dx_Sprite3D_getAABB, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Mesh_prototype); + JS_DefineFunction(cx, tmpObj, "getMeshVertexAttribute", js_cocos2dx_Mesh_getMeshVertexAttribute, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Mesh_prototype), "getMeshVertexAttribute", js_cocos2dx_Mesh_getMeshVertexAttribute, 1, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_TextureCube_prototype); + JS_DefineFunction(cx, tmpObj, "setTexParameters", js_cocos2dx_CCTextureCube_setTexParameters, 4, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_TextureCube_prototype), "setTexParameters", js_cocos2dx_CCTextureCube_setTexParameters, 4, JSPROP_READONLY | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Terrain_prototype), "getHeightData", js_cocos2dx_Terrain_getHeightData, 0, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Terrain_prototype); + JS_DefineFunction(cx, tmpObj, "getHeightData", js_cocos2dx_Terrain_getHeightData, 0, JSPROP_READONLY | JSPROP_PERMANENT); } diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index c03e1751e5..cf9a1c7728 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -101,8 +101,6 @@ static std::vector registrationList; static std::unordered_map filename_script; // port ~> socket map static std::unordered_map ports_sockets; -// name ~> globals -static std::unordered_map globals; static void cc_closesocket(int fd) { @@ -135,7 +133,8 @@ static void executeJSFunctionFromReservedSpot(JSContext *cx, JS::HandleObject ob JS_CallFunctionValue(cx, obj, func, dataVal, retval); } else { assert(!thisObj.isPrimitive()); - JS_CallFunctionValue(cx, JS::RootedObject(cx, thisObj.toObjectOrNull()), func, dataVal, retval); + JS::RootedObject jsthis(cx, thisObj.toObjectOrNull()); + JS_CallFunctionValue(cx, jsthis, func, dataVal, retval); } } @@ -251,7 +250,8 @@ void ScriptingCore::executeJSFunctionWithThisObj(JS::HandleValue thisObj, // So we have to check the availability of 'retVal'. // if (retVal) // { - JS_CallFunctionValue(_cx, JS::RootedObject(_cx, thisObj.toObjectOrNull()), callback, vp, retVal); + JS::RootedObject jsthis(_cx, thisObj.toObjectOrNull()); + JS_CallFunctionValue(_cx, jsthis, callback, vp, retVal); // } // else // { @@ -511,7 +511,8 @@ bool ScriptingCore::evalString(const char *string, jsval *outVal, const char *fi global = _global.ref().get(); JSAutoCompartment ac(cx, global); - return JS_EvaluateScript(cx, JS::RootedObject(cx, global), string, strlen(string), "ScriptingCore::evalString", 1); + JS::RootedObject jsglobal(cx, global); + return JS_EvaluateScript(cx, jsglobal, string, (unsigned)strlen(string), "ScriptingCore::evalString", 1); } void ScriptingCore::start() @@ -643,7 +644,7 @@ JSScript* ScriptingCore::getScript(const char *path) return NULL; } -void ScriptingCore::compileScript(const char *path, JSObject* global, JSContext* cx) +void ScriptingCore::compileScript(const char *path, JS::HandleObject global, JSContext* cx) { if (!path) { return; @@ -655,9 +656,6 @@ void ScriptingCore::compileScript(const char *path, JSObject* global, JSContext* cocos2d::FileUtils *futil = cocos2d::FileUtils::getInstance(); - if (global == NULL) { - global = _global.ref().get(); - } if (cx == NULL) { cx = _cx; } @@ -872,11 +870,15 @@ void ScriptingCore::removeScriptObjectByObject(Ref* pObj) js_proxy_t* jsproxy; void *ptr = (void*)pObj; nproxy = jsb_get_native_proxy(ptr); - if (nproxy) { + if (nproxy) + { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); jsproxy = jsb_get_js_proxy(nproxy->obj); - RemoveObjectRoot(cx, &jsproxy->obj); - jsb_remove_proxy(nproxy, jsproxy); + if (jsproxy) + { + RemoveObjectRoot(cx, &jsproxy->obj); + jsb_remove_proxy(nproxy, jsproxy); + } } } @@ -890,7 +892,8 @@ bool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc >= 1) { - JSString* str = JS::ToString(cx, JS::RootedValue(cx, args.get(0))); + JS::RootedValue jsstr(cx, args.get(0)); + JSString* str = JS::ToString(cx, jsstr); JSStringWrapper path(str); bool res = false; if (argc == 2 && args.get(1).isString()) { @@ -1043,7 +1046,8 @@ int ScriptingCore::handleActionEvent(void* data) if (eventType == kActionUpdate) { - if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "update", js_cocos2dx_Action_update)) + JS::RootedObject jstarget(_cx, p->obj); + if (isFunctionOverridedInJS(jstarget, "update", js_cocos2dx_Action_update)) { jsval dataVal = DOUBLE_TO_JSVAL(*((float *)actionObjectScriptData->param)); ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "update", 1, &dataVal, &retval); @@ -1070,10 +1074,12 @@ int ScriptingCore::handleNodeEvent(void* data) int ret = 0; JS::RootedValue retval(_cx); jsval dataVal = INT_TO_JSVAL(1); + + JS::RootedObject jstarget(_cx, p->obj); if (action == kNodeOnEnter) { - if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnter", js_cocos2dx_Node_onEnter)) + if (isFunctionOverridedInJS(jstarget, "onEnter", js_cocos2dx_Node_onEnter)) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnter", 1, &dataVal, &retval); } @@ -1081,7 +1087,7 @@ int ScriptingCore::handleNodeEvent(void* data) } else if (action == kNodeOnExit) { - if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onExit", js_cocos2dx_Node_onExit)) + if (isFunctionOverridedInJS(jstarget, "onExit", js_cocos2dx_Node_onExit)) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExit", 1, &dataVal, &retval); } @@ -1089,14 +1095,14 @@ int ScriptingCore::handleNodeEvent(void* data) } else if (action == kNodeOnEnterTransitionDidFinish) { - if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnterTransitionDidFinish", js_cocos2dx_Node_onEnterTransitionDidFinish)) + if (isFunctionOverridedInJS(jstarget, "onEnterTransitionDidFinish", js_cocos2dx_Node_onEnterTransitionDidFinish)) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnterTransitionDidFinish", 1, &dataVal, &retval); } } else if (action == kNodeOnExitTransitionDidStart) { - if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onExitTransitionDidStart", js_cocos2dx_Node_onExitTransitionDidStart)) + if (isFunctionOverridedInJS(jstarget, "onExitTransitionDidStart", js_cocos2dx_Node_onExitTransitionDidStart)) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExitTransitionDidStart", 1, &dataVal, &retval); } @@ -1104,7 +1110,7 @@ int ScriptingCore::handleNodeEvent(void* data) else if (action == kNodeOnCleanup) { cleanupSchedulesAndActions(p); - if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "cleanup", js_cocos2dx_Node_cleanup)) + if (isFunctionOverridedInJS(jstarget, "cleanup", js_cocos2dx_Node_cleanup)) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "cleanup", 1, &dataVal, &retval); } @@ -1361,7 +1367,8 @@ bool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, cons bool hasAction; JSContext* cx = this->_cx; JS::RootedValue temp_retval(cx); - JS::RootedObject obj(cx, JS::RootedValue(cx, owner).toObjectOrNull()); + JS::RootedValue ownerval(cx, owner); + JS::RootedObject obj(cx, ownerval.toObjectOrNull()); do { @@ -1612,7 +1619,8 @@ void ScriptingCore::debugProcessInput(const std::string& str) jsval argv = STRING_TO_JSVAL(jsstr); JS::RootedValue outval(_cx); - JS_CallFunctionName(_cx, JS::RootedObject(_cx, _debugGlobal.ref()), "processInput", JS::HandleValueArray::fromMarkedLocation(1, &argv), &outval); + JS::RootedObject debugGlobal(_cx, _debugGlobal.ref()); + JS_CallFunctionName(_cx, debugGlobal, "processInput", JS::HandleValueArray::fromMarkedLocation(1, &argv), &outval); } static bool NS_ProcessNextEvent() @@ -1857,14 +1865,14 @@ void ScriptingCore::enableDebugger(unsigned int port) } } -JSObject* NewGlobalObject(JSContext* cx, bool debug) +JS::HandleObject NewGlobalObject(JSContext* cx, bool debug) { JS::CompartmentOptions options; options.setVersion(JSVERSION_LATEST); JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, &shellTrustedPrincipals, JS::DontFireOnNewGlobalHook, options)); if (!glob) { - return NULL; + return JS::NullPtr(); } JSAutoCompartment ac(cx, glob); bool ok = true; @@ -1874,7 +1882,7 @@ JSObject* NewGlobalObject(JSContext* cx, bool debug) if (ok && debug) ok = JS_DefineDebuggerObject(cx, glob); if (!ok) - return NULL; + return JS::NullPtr(); JS_FireOnNewGlobalObject(cx, glob); diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 5f472a8f45..f31f425a49 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -248,7 +248,7 @@ public: * @param global @~english The js global object * @param cx @~english The js context */ - void compileScript(const char *path, JSObject* global = NULL, JSContext* cx = NULL); + void compileScript(const char *path, JS::HandleObject global, JSContext* cx = NULL); /**@~english * Run the specified js file @@ -502,11 +502,36 @@ public: void restartVM(); }; -JSObject* NewGlobalObject(JSContext* cx, bool debug = false); +JS::HandleObject NewGlobalObject(JSContext* cx, bool debug = false); bool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value); bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret); +template +js_type_class_t *jsb_register_class(JSContext *cx, JSClass *jsClass, JS::HandleObject proto, JS::HandleObject parentProto) +{ + TypeTest t; + js_type_class_t *p = nullptr; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsClass; + if (p->proto.empty()) + { + p->proto.construct(cx); + } + p->proto.ref() = proto; + if (p->parentProto.empty()) + { + p->parentProto.construct(cx); + } + p->parentProto.ref() = parentProto ; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } + return p; +} + js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj); js_proxy_t* jsb_get_native_proxy(void* nativeObj); js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp index 45226a0201..153ad73717 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp @@ -86,7 +86,8 @@ bool JSB_cpConstraint_getA(JSContext *cx, uint32_t argc, jsval *vp) { ret_val = cpConstraintGetA((cpConstraint*)arg0 ); - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" ); args.rval().set(ret_jsval); return true; @@ -103,8 +104,9 @@ bool JSB_cpConstraint_getB(JSContext *cx, uint32_t argc, jsval *vp) { cpBody* ret_val = nullptr; ret_val = cpConstraintGetB((cpConstraint*)arg0 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" ); args.rval().set(ret_jsval); return true; @@ -182,7 +184,8 @@ bool JSB_cpConstraint_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { ret_val = cpConstraintGetSpace((cpConstraint*)arg0 ); - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + JS::RootedObject spaceProto(cx, JSB_cpSpace_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" ); args.rval().set(ret_jsval); return true; @@ -281,9 +284,8 @@ void JSB_cpConstraint_createClass(JSContext *cx, JS::HandleObject globalObj, con JS_FS_END }; - JSB_cpConstraint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpConstraint_class, JSB_cpConstraint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + JS::RootedObject baseProto(cx, JSB_cpBase_object); + JSB_cpConstraint_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpConstraint_class, JSB_cpConstraint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -298,7 +300,8 @@ JSObject* JSB_cpGrooveJoint_object = NULL; bool JSB_cpGrooveJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpGrooveJoint_class, JS::RootedObject(cx, JSB_cpGrooveJoint_object), JS::NullPtr()); + JS::RootedObject grooveJointProto(cx, JSB_cpGrooveJoint_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpGrooveJoint_class, grooveJointProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; cpVect arg4; @@ -475,9 +478,8 @@ void JSB_cpGrooveJoint_createClass(JSContext *cx, JS::HandleObject globalObj, co JS_FS_END }; - JSB_cpGrooveJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpGrooveJoint_class, JSB_cpGrooveJoint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpGrooveJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpGrooveJoint_class, JSB_cpGrooveJoint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -492,7 +494,8 @@ JSObject* JSB_cpSimpleMotor_object = NULL; bool JSB_cpSimpleMotor_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpSimpleMotor_class, JS::RootedObject(cx, JSB_cpSimpleMotor_object), JS::NullPtr()); + JS::RootedObject simpleMotorProto(cx, JSB_cpSimpleMotor_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSimpleMotor_class, simpleMotorProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; @@ -586,9 +589,8 @@ void JSB_cpSimpleMotor_createClass(JSContext *cx, JS::HandleObject globalObj, co JS_FS_END }; - JSB_cpSimpleMotor_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpSimpleMotor_class, JSB_cpSimpleMotor_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpSimpleMotor_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpSimpleMotor_class, JSB_cpSimpleMotor_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -603,7 +605,8 @@ JSObject* JSB_cpPivotJoint_object = NULL; bool JSB_cpPivotJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4 || argc==3, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpPivotJoint_class, JS::RootedObject(cx, JSB_cpPivotJoint_object), JS::NullPtr()); + JS::RootedObject pivotJointProto(cx, JSB_cpPivotJoint_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpPivotJoint_class, pivotJointProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; void *ret_val = nullptr; @@ -743,10 +746,9 @@ void JSB_cpPivotJoint_createClass(JSContext *cx, JS::HandleObject globalObj, con static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpPivotJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpPivotJoint_class, JSB_cpPivotJoint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpPivotJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpPivotJoint_class, JSB_cpPivotJoint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -761,7 +763,8 @@ JSObject* JSB_cpPinJoint_object = NULL; bool JSB_cpPinJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpPinJoint_class, JS::RootedObject(cx, JSB_cpPinJoint_object), JS::NullPtr()); + JS::RootedObject pinJointProto(cx, JSB_cpPinJoint_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpPinJoint_class, pinJointProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; @@ -933,10 +936,9 @@ void JSB_cpPinJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpPinJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpPinJoint_class, JSB_cpPinJoint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpPinJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpPinJoint_class, JSB_cpPinJoint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -951,7 +953,8 @@ JSObject* JSB_cpSlideJoint_object = NULL; bool JSB_cpSlideJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==6, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpSlideJoint_class, JS::RootedObject(cx, JSB_cpSlideJoint_object), JS::NullPtr()); + JS::RootedObject slideJointProto(cx, JSB_cpSlideJoint_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSlideJoint_class, slideJointProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; double arg4 = 0; double arg5 = 0; @@ -1161,10 +1164,9 @@ void JSB_cpSlideJoint_createClass(JSContext *cx, JS::HandleObject globalObj, con static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpSlideJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpSlideJoint_class, JSB_cpSlideJoint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpSlideJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpSlideJoint_class, JSB_cpSlideJoint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -1179,7 +1181,8 @@ JSObject* JSB_cpGearJoint_object = NULL; bool JSB_cpGearJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpGearJoint_class, JS::RootedObject(cx, JSB_cpGearJoint_object), JS::NullPtr()); + JS::RootedObject gearJointProto(cx, JSB_cpGearJoint_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpGearJoint_class, gearJointProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0; @@ -1309,10 +1312,9 @@ void JSB_cpGearJoint_createClass(JSContext *cx, JS::HandleObject globalObj, cons static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpGearJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpGearJoint_class, JSB_cpGearJoint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpGearJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpGearJoint_class, JSB_cpGearJoint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -1327,7 +1329,8 @@ JSObject* JSB_cpDampedRotarySpring_object = NULL; bool JSB_cpDampedRotarySpring_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedRotarySpring_class, JS::RootedObject(cx, JSB_cpDampedRotarySpring_object), JS::NullPtr()); + JS::RootedObject dampedRotarySringProto(cx, JSB_cpDampedRotarySpring_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpDampedRotarySpring_class, dampedRotarySringProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0; double arg4 = 0; @@ -1494,10 +1497,9 @@ void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JS::HandleObject global static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpDampedRotarySpring_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpDampedRotarySpring_class, JSB_cpDampedRotarySpring_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpDampedRotarySpring_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpDampedRotarySpring_class, JSB_cpDampedRotarySpring_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -1512,7 +1514,8 @@ JSObject* JSB_cpDampedSpring_object = NULL; bool JSB_cpDampedSpring_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==7, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedSpring_class, JS::RootedObject(cx, JSB_cpDampedSpring_object), JS::NullPtr()); + JS::RootedObject dampedSpringProto(cx, JSB_cpDampedSpring_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpDampedSpring_class, dampedSpringProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; cpVect arg2; cpVect arg3; double arg4 = 0; double arg5 = 0; double arg6 = 0; @@ -1759,10 +1762,9 @@ void JSB_cpDampedSpring_createClass(JSContext *cx, JS::HandleObject globalObj, c static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpDampedSpring_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpDampedSpring_class, JSB_cpDampedSpring_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpDampedSpring_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpDampedSpring_class, JSB_cpDampedSpring_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -1777,7 +1779,8 @@ JSObject* JSB_cpRatchetJoint_object = NULL; bool JSB_cpRatchetJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpRatchetJoint_class, JS::RootedObject(cx, JSB_cpRatchetJoint_object), JS::NullPtr()); + JS::RootedObject ratchetJointProto(cx, JSB_cpRatchetJoint_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpRatchetJoint_class, ratchetJointProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0; @@ -1943,10 +1946,9 @@ void JSB_cpRatchetJoint_createClass(JSContext *cx, JS::HandleObject globalObj, c static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpRatchetJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpRatchetJoint_class, JSB_cpRatchetJoint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpRatchetJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpRatchetJoint_class, JSB_cpRatchetJoint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -1961,7 +1963,8 @@ JSObject* JSB_cpRotaryLimitJoint_object = NULL; bool JSB_cpRotaryLimitJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpRotaryLimitJoint_class, JS::RootedObject(cx, JSB_cpRotaryLimitJoint_object), JS::NullPtr()); + JS::RootedObject rotaryLimitJointProto(cx, JSB_cpRotaryLimitJoint_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpRotaryLimitJoint_class, rotaryLimitJointProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpBody* arg1 = nullptr; double arg2 = 0; double arg3 = 0; @@ -2091,10 +2094,9 @@ void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JS::HandleObject globalOb static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpRotaryLimitJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpRotaryLimitJoint_class, JSB_cpRotaryLimitJoint_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject constraintProto(cx, JSB_cpConstraint_object); + JSB_cpRotaryLimitJoint_object = JS_InitClass(cx, globalObj, constraintProto, JSB_cpRotaryLimitJoint_class, JSB_cpRotaryLimitJoint_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -2501,9 +2503,8 @@ void JSB_cpArbiter_createClass(JSContext *cx, JS::HandleObject globalObj, const JS_FS_END }; - JSB_cpArbiter_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpArbiter_class, JSB_cpArbiter_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + JS::RootedObject baseProto(cx, JSB_cpBase_object); + JSB_cpArbiter_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpArbiter_class, JSB_cpArbiter_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -2519,7 +2520,8 @@ bool JSB_cpSpace_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *jsobj = JS_NewObject(cx, JSB_cpSpace_class, JS::RootedObject(cx, JSB_cpSpace_object), JS::NullPtr()); + JS::RootedObject spaceProto(cx, JSB_cpSpace_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSpace_class, spaceProto, JS::NullPtr())); void* ret_val = cpSpaceNew( ); jsb_set_jsobject_for_proxy(jsobj, ret_val); @@ -2786,8 +2788,9 @@ bool JSB_cpSpace_getStaticBody(JSContext *cx, uint32_t argc, jsval *vp) { cpBody* ret_val = nullptr; ret_val = cpSpaceGetStaticBody((cpSpace*)arg0 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" ); args.rval().set(ret_jsval); return true; @@ -2804,8 +2807,9 @@ bool JSB_cpSpace_init(JSContext *cx, uint32_t argc, jsval *vp) { cpSpace* ret_val = nullptr; ret_val = cpSpaceInit((cpSpace*)arg0 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + + JS::RootedObject spaceProto(cx, JSB_cpSpace_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" ); args.rval().set(ret_jsval); return true; @@ -2846,7 +2850,8 @@ bool JSB_cpSpace_pointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) { ret_val = cpSpacePointQueryFirst((cpSpace*)arg0 , (cpVect)arg1 , (cpLayers)arg2 , (cpGroup)arg3 ); if(ret_val) { - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape" ); + JS::RootedObject shapeProto(cx, JSB_cpShape_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, shapeProto, JSB_cpShape_class, "cpShape" ); args.rval().set(ret_jsval); } else { args.rval().set(JSVAL_NULL); @@ -3188,10 +3193,9 @@ void JSB_cpSpace_createClass(JSContext *cx, JS::HandleObject globalObj, const ch static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpSpace_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpSpace_class, JSB_cpSpace_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject baseProto(cx, JSB_cpBase_object); + JSB_cpSpace_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpSpace_class, JSB_cpSpace_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -3445,8 +3449,9 @@ bool JSB_cpBody_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { cpSpace* ret_val = nullptr; ret_val = cpBodyGetSpace((cpBody*)arg0 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + + JS::RootedObject spaceProto(cx, JSB_cpSpace_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" ); args.rval().set(ret_jsval); return true; @@ -3563,8 +3568,9 @@ bool JSB_cpBody_init(JSContext *cx, uint32_t argc, jsval *vp) { cpBody* ret_val = nullptr; ret_val = cpBodyInit((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" ); args.rval().set(ret_jsval); return true; @@ -3581,8 +3587,9 @@ bool JSB_cpBody_initStatic(JSContext *cx, uint32_t argc, jsval *vp) { cpBody* ret_val = nullptr; ret_val = cpBodyInitStatic((cpBody*)arg0 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" ); args.rval().set(ret_jsval); return true; @@ -4081,10 +4088,9 @@ void JSB_cpBody_createClass(JSContext *cx, JS::HandleObject globalObj, const cha static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpBody_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpBody_class, JSB_cpBody_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject baseProto(cx, JSB_cpBase_object); + JSB_cpBody_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpBody_class, JSB_cpBody_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -4181,8 +4187,9 @@ bool JSB_cpShape_getBody(JSContext *cx, uint32_t argc, jsval *vp) { cpBody* ret_val = nullptr; ret_val = cpShapeGetBody((cpShape*)arg0 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" ); args.rval().set(ret_jsval); return true; @@ -4295,8 +4302,9 @@ bool JSB_cpShape_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { cpSpace* ret_val = nullptr; ret_val = cpShapeGetSpace((cpShape*)arg0 ); - - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + + JS::RootedObject spaceProto(cx, JSB_cpSpace_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, spaceProto, JSB_cpSpace_class, "cpSpace" ); args.rval().set(ret_jsval); return true; @@ -4545,7 +4553,8 @@ bool JSB_cpShape_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp) cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo(); cpShapeNearestPointQuery(shape, p, info); - JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, JS::RootedObject(cx, JSB_cpNearestPointQueryInfo_object), JS::NullPtr()); + JS::RootedObject nearestPointQueryInfoProto(cx, JSB_cpNearestPointQueryInfo_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, nearestPointQueryInfoProto, JS::NullPtr())); jsb_set_jsobject_for_proxy(jsobj, info); jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); args.rval().set(OBJECT_TO_JSVAL(jsobj)); @@ -4570,7 +4579,8 @@ bool JSB_cpShape_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp) cpSegmentQueryInfo* info = new cpSegmentQueryInfo(); if(cpShapeSegmentQuery(shape, a, b, info)) { - JSObject* jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, JS::RootedObject(cx, JSB_cpSegmentQueryInfo_object), JS::NullPtr()); + JS::RootedObject segmentQueryInfoProto(cx, JSB_cpSegmentQueryInfo_object); + JSObject* jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, segmentQueryInfoProto, JS::NullPtr()); jsb_set_jsobject_for_proxy(jsobj, info); jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); args.rval().set(OBJECT_TO_JSVAL(jsobj)); @@ -4698,10 +4708,9 @@ void JSB_cpShape_createClass(JSContext *cx, JS::HandleObject globalObj, const ch static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpShape_class, JSB_cpShape_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject baseProto(cx, JSB_cpBase_object); + JSB_cpShape_object = JS_InitClass(cx, globalObj, baseProto, JSB_cpShape_class, JSB_cpShape_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -4716,7 +4725,8 @@ JSObject* JSB_cpCircleShape_object = NULL; bool JSB_cpCircleShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpCircleShape_class, JS::RootedObject(cx, JSB_cpCircleShape_object), JS::NullPtr()); + JS::RootedObject circleShapeProto(cx, JSB_cpCircleShape_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpCircleShape_class, circleShapeProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; double arg1 = 0; cpVect arg2; @@ -4808,10 +4818,9 @@ void JSB_cpCircleShape_createClass(JSContext *cx, JS::HandleObject globalObj, co static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpCircleShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpCircleShape_class, JSB_cpCircleShape_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject shapeProto(cx, JSB_cpShape_object); + JSB_cpCircleShape_object = JS_InitClass(cx, globalObj, shapeProto, JSB_cpCircleShape_class, JSB_cpCircleShape_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -4826,7 +4835,8 @@ JSObject* JSB_cpSegmentShape_object = NULL; bool JSB_cpSegmentShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentShape_class, JS::RootedObject(cx, JSB_cpSegmentShape_object), JS::NullPtr()); + JS::RootedObject segmentShapeProto(cx, JSB_cpSegmentShape_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpSegmentShape_class, segmentShapeProto, JS::NullPtr())); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* arg0 = nullptr; cpVect arg1; cpVect arg2; double arg3 = 0; @@ -5002,10 +5012,9 @@ void JSB_cpSegmentShape_createClass(JSContext *cx, JS::HandleObject globalObj, c static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpSegmentShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpSegmentShape_class, JSB_cpSegmentShape_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject shapeProto(cx, JSB_cpShape_object); + JSB_cpSegmentShape_object = JS_InitClass(cx, globalObj, shapeProto, JSB_cpSegmentShape_class, JSB_cpSegmentShape_constructor,0,properties,funcs,NULL,st_funcs); } /* @@ -5109,10 +5118,11 @@ static bool js_get_cpPolyShape_planes(JSContext *cx, uint32_t argc, jsval *vp) cpSplittingPlane *plane = planes + i; JS::RootedValue elem(cx); - JSObject *jsobj = jsb_get_jsobject_for_proxy(plane); + JS::RootedObject jsobj(cx, jsb_get_jsobject_for_proxy(plane)); if(!jsobj) { - jsobj = JS_NewObject(cx, JSB_cpSplittingPlane_class, JS::RootedObject(cx, JSB_cpSplittingPlane_object), JS::NullPtr()); + JS::RootedObject splittingPlaneProto(cx, JSB_cpSplittingPlane_object); + jsobj = JS_NewObject(cx, JSB_cpSplittingPlane_class, splittingPlaneProto, JS::NullPtr()); jsb_set_jsobject_for_proxy(jsobj, plane); jsb_set_c_proxy_for_jsobject(jsobj, plane, JSB_C_FLAG_DO_NOT_CALL_FREE); } @@ -5152,10 +5162,9 @@ void JSB_cpPolyShape_createClass(JSContext *cx, JS::HandleObject globalObj, cons static JSFunctionSpec st_funcs[] = { JS_FS_END }; - - JSB_cpPolyShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpPolyShape_class, JSB_cpPolyShape_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + JS::RootedObject shapeProto(cx, JSB_cpShape_object); + JSB_cpPolyShape_object = JS_InitClass(cx, globalObj, shapeProto, JSB_cpPolyShape_class, JSB_cpPolyShape_constructor,0,properties,funcs,NULL,st_funcs); } // SplittingPlane @@ -5293,7 +5302,8 @@ bool js_get_cpSegmentQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp) cpShape* shape = info->shape; if(shape){ - JSObject *jsobj = JS_NewObject(cx, JSB_cpShape_class, JS::RootedObject(cx, JSB_cpShape_object), JS::NullPtr()); + JS::RootedObject shapeProto(cx, JSB_cpShape_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpShape_class, shapeProto, JS::NullPtr())); //jsb_set_jsobject_for_proxy(jsobj, shape); jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); args.rval().set(OBJECT_TO_JSVAL(jsobj)); @@ -5387,8 +5397,6 @@ void JSB_cpSegmentQueryInfo_createClass(JSContext *cx, JS::HandleObject globalOb }; JSB_cpSegmentQueryInfo_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpSegmentQueryInfo_class, NULL,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } bool js_get_cpNearestPointQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp) @@ -5399,7 +5407,8 @@ bool js_get_cpNearestPointQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *v cpShape* shape = info->shape; if(shape){ - JSObject *jsobj = JS_NewObject(cx, JSB_cpShape_class, JS::RootedObject(cx, JSB_cpShape_object), JS::NullPtr()); + JS::RootedObject shapeProto(cx, JSB_cpShape_object); + JS::RootedObject jsobj(cx, JS_NewObject(cx, JSB_cpShape_class, shapeProto, JS::NullPtr())); //jsb_set_jsobject_for_proxy(jsobj, shape); jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); args.rval().set(OBJECT_TO_JSVAL(jsobj)); diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp index 80bc51c49c..1780684783 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -48,7 +48,9 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { p = typeMapIter->second; CCASSERT(p, "The value is null."); - JSObject *_tmp = JS_NewObject(cx, p->jsclass, JS::RootedObject(cx, p->proto), JS::RootedObject(cx, p->parentProto)); + JS::RootedObject proto(cx, p->proto.ref()); + JS::RootedObject parentProto(cx, p->parentProto.ref()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, p->jsclass, proto, parentProto)); js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); JS::AddObjectRoot(cx, &pp->obj); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -101,7 +103,8 @@ bool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp) cpBody* ret_val = nullptr; ret_val = real->getCPBody(); - jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, bodyProto, JSB_cpBody_class, "cpBody" ); args.rval().set(ret_jsval); return true; @@ -200,7 +203,9 @@ bool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCDebugNode"); @@ -267,8 +272,9 @@ bool JSB_CCPhysicsDebugNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - //JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, typeClass->jsclass, args)); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto))); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -313,21 +319,12 @@ void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JS::HandleObject globalOb CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - - JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, typeClass->proto), JSB_CCPhysicsDebugNode_class, JSB_CCPhysicsDebugNode_constructor, 0,properties,funcs,NULL,st_funcs); - - TypeTest t; - js_type_class_t *p; - 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_CCPhysicsDebugNode_class; - p->proto = JSB_CCPhysicsDebugNode_object; - p->parentProto = typeClass->proto; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject parentProto(cx, typeClass->proto.ref()); + JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, parentProto, JSB_CCPhysicsDebugNode_class, JSB_CCPhysicsDebugNode_constructor, 0,properties,funcs,NULL,st_funcs); + + JS::RootedObject proto(cx, JSB_CCPhysicsDebugNode_object); + jsb_register_class(cx, JSB_CCPhysicsDebugNode_class, proto, parentProto); } // Arguments: NSString*, CGRect @@ -356,7 +353,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); @@ -384,7 +383,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); @@ -425,7 +426,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); @@ -459,7 +462,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, ui CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); @@ -490,8 +495,9 @@ bool JSPROXY_CCPhysicsSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - //JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, typeClass->jsclass, args)); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto))); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -558,20 +564,12 @@ void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JS::HandleObject globalO CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - - JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, typeClass->proto), JSPROXY_CCPhysicsSprite_class,/* dummy_constructor*/JSPROXY_CCPhysicsSprite_constructor, 0,properties,funcs,NULL,st_funcs); - - TypeTest t; - js_type_class_t *p; - 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 = JSPROXY_CCPhysicsSprite_class; - p->proto = JSPROXY_CCPhysicsSprite_object; - p->parentProto = typeClass->proto; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + + JS::RootedObject parentProto(cx, typeClass->proto.ref()); + JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, parentProto, JSPROXY_CCPhysicsSprite_class, JSPROXY_CCPhysicsSprite_constructor, 0,properties,funcs,NULL,st_funcs); + + JS::RootedObject proto(cx, JSPROXY_CCPhysicsSprite_object); + jsb_register_class(cx, JSPROXY_CCPhysicsSprite_class, proto, parentProto); anonEvaluate(cx, globalObj, "(function () { cc.PhysicsSprite.extend = cc.Class.extend; })()"); } @@ -592,7 +590,8 @@ void register_CCPhysicsDebugNode(JSContext *cx, JS::HandleObject obj) { bool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ) { JS::RootedObject jsobj(cx); - bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj ); + JS::RootedValue jsv(cx, vp); + bool ok = JS_ValueToObject(cx, jsv, &jsobj); JSB_PRECONDITION( ok, "Error converting value to object"); JSB_PRECONDITION( jsobj, "Not a valid JS object"); @@ -645,7 +644,8 @@ bool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numV { // Parsing sequence JS::RootedObject jsobj(cx); - bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj ); + JS::RootedValue jsv(cx, vp); + bool ok = JS_ValueToObject(cx, jsv, &jsobj); JSB_PRECONDITION( ok, "Error converting value to object"); JSB_PRECONDITION( jsobj && JS_IsArrayObject( cx, jsobj), "Object must be an array"); @@ -683,7 +683,8 @@ bool jsval_to_cpVect( JSContext *cx, jsval vp, cpVect *ret ) #ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES JS::RootedObject jsobj(cx); - if( ! JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj ) ) + JS::RootedValue jsv(cx, vp); + if( !JS_ValueToObject(cx, jsv, &jsobj) ) return false; JSB_PRECONDITION( jsobj, "Not a valid JS object"); @@ -797,8 +798,10 @@ static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data) jsval args[2]; if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object); + JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object); + args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); @@ -807,7 +810,9 @@ static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data) JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(handler->cx); - bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->begin)), JS::HandleValueArray::fromMarkedLocation(2, args), &rval); + JS::RootedObject jsthis(handler->cx, handler->jsthis); + JS::RootedValue jsbegin(handler->cx, OBJECT_TO_JSVAL(handler->begin)); + bool ok = JS_CallFunctionValue( handler->cx, jsthis, jsbegin, JS::HandleValueArray::fromMarkedLocation(2, args), &rval); JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin"); if( rval.isBoolean() ) { @@ -823,8 +828,10 @@ static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data) jsval args[2]; if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object); + JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object); + args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); @@ -833,7 +840,9 @@ static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data) JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(handler->cx); - bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->pre)), JS::HandleValueArray::fromMarkedLocation(2, args), &rval); + JS::RootedObject jsthis(handler->cx, handler->jsthis); + JS::RootedValue jspre(handler->cx, OBJECT_TO_JSVAL(handler->pre)); + bool ok = JS_CallFunctionValue( handler->cx, jsthis, jspre, JS::HandleValueArray::fromMarkedLocation(2, args), &rval); JSB_PRECONDITION2(ok, handler->cx, false, "Error calling collision callback: pre"); if( rval.isBoolean() ) { @@ -850,8 +859,10 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) jsval args[2]; if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object); + JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object); + args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); @@ -860,7 +871,9 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue ignore(handler->cx); - bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->post)), JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); + JS::RootedObject jsthis(handler->cx, handler->jsthis); + JS::RootedValue jspost(handler->cx, OBJECT_TO_JSVAL(handler->post)); + bool ok = JS_CallFunctionValue( handler->cx, jsthis, jspost, JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post"); } @@ -872,8 +885,10 @@ static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data) jsval args[2]; if( handler->is_oo ) { - args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); - args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + JS::RootedObject arbiterProto(handler->cx, JSB_cpArbiter_object); + JS::RootedObject spaceProto(handler->cx, JSB_cpSpace_object); + args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); @@ -882,7 +897,9 @@ static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data) JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue ignore(handler->cx); - bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->separate)), JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); + JS::RootedObject jsthis(handler->cx, handler->jsthis); + JS::RootedValue jssep(handler->cx, OBJECT_TO_JSVAL(handler->separate)); + bool ok = JS_CallFunctionValue( handler->cx, jsthis, jssep, JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");} #pragma mark - cpSpace @@ -947,8 +964,10 @@ bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, c bool ok = true; // args - ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeA ); - ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeB ); + JS::RootedValue jstypeA(cx, *argvp++); + JS::RootedValue jstypeB(cx, *argvp++); + ok &= jsval_to_int(cx, jstypeA, (int32_t*) &handler->typeA ); + ok &= jsval_to_int(cx, jstypeB, (int32_t*) &handler->typeB ); handler->begin = argvp->toObjectOrNull(); argvp++; @@ -1014,7 +1033,8 @@ bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) // args cpSpace *space = nullptr; jsval* argvp = args.array(); - bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**)&space); + JS::RootedValue jsarg(cx, *argvp++); + bool ok = jsval_to_opaque(cx, jsarg, (void**)&space); JSB_PRECONDITION(ok, "Error parsing arguments"); return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0); @@ -1115,8 +1135,10 @@ bool __jsb_cpSpace_removeCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp cpCollisionType typeA = 0; cpCollisionType typeB = 0; - ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &typeA ); - ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &typeB ); + JS::RootedValue jstypeA(cx, *argvp++); + JS::RootedValue jstypeB(cx, *argvp++); + ok &= jsval_to_int(cx, jstypeA, (int32_t*) &typeA); + ok &= jsval_to_int(cx, jstypeB, (int32_t*) &typeB); JSB_PRECONDITION(ok, "Error parsing arguments"); @@ -1154,7 +1176,8 @@ bool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) cpSpace* space = nullptr; jsval* argvp = args.array(); - bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**)&space); + JS::RootedValue jsarg(cx, *argvp++); + bool ok = jsval_to_opaque( cx, jsarg, (void**)&space); JSB_PRECONDITION(ok, "Error parsing arguments"); @@ -1395,7 +1418,8 @@ bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){ if(target) { - JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, JS::RootedObject(cx, JSB_cpSegmentQueryInfo_object), JS::NullPtr()); + JS::RootedObject segmentQueryInfoProto(cx, JSB_cpSegmentQueryInfo_object); + JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, segmentQueryInfoProto, JS::NullPtr()); jsb_set_jsobject_for_proxy(jsobj, out); jsb_set_c_proxy_for_jsobject(jsobj, out, JSB_C_FLAG_CALL_FREE); args.rval().set(OBJECT_TO_JSVAL(jsobj)); @@ -1432,7 +1456,8 @@ bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *v if(target) { - JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, JS::RootedObject(cx, JSB_cpNearestPointQueryInfo_object), JS::NullPtr()); + JS::RootedObject nearestPointQueryInfoProto(cx, JSB_cpNearestPointQueryInfo_object); + JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, nearestPointQueryInfoProto, JS::NullPtr()); jsb_set_jsobject_for_proxy(jsobj, info); jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); args.rval().set(OBJECT_TO_JSVAL(jsobj)); @@ -1457,12 +1482,12 @@ void JSB_cpSpace_pointQuery_func(cpShape *shape, void *data) if(jsCpObject) { JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; - jsval* func = ((JSB_cp_each_UserData*)data)->func; + JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func); JS::RootedValue rval(cx); jsval argv = OBJECT_TO_JSVAL(jsCpObject); JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval); + JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval); } } @@ -1506,7 +1531,7 @@ void JSB_cpSpace_nearestPointQuery_func(cpShape *shape, cpFloat distance, cpVect if(jsCpObject) { JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; - jsval* func = ((JSB_cp_each_UserData*)data)->func; + JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func); JS::RootedValue rval(cx); jsval argv[3]; argv[0] = OBJECT_TO_JSVAL(jsCpObject); @@ -1514,7 +1539,7 @@ void JSB_cpSpace_nearestPointQuery_func(cpShape *shape, cpFloat distance, cpVect argv[2] = cpVect_to_jsval(cx, point); JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(3, argv), &rval); + JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(3, argv), &rval); } } @@ -1559,7 +1584,7 @@ void JSB_cpSpace_segmentQuery_func(cpShape *shape, cpFloat t, cpVect n, void *da if(jsCpObject) { JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; - jsval* func = ((JSB_cp_each_UserData*)data)->func; + JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func); JS::RootedValue rval(cx); jsval argv[3]; argv[0] = OBJECT_TO_JSVAL(jsCpObject); @@ -1567,7 +1592,7 @@ void JSB_cpSpace_segmentQuery_func(cpShape *shape, cpFloat t, cpVect n, void *da argv[2] = cpVect_to_jsval(cx, n); JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(3, argv), &rval); + JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(3, argv), &rval); } } @@ -1577,7 +1602,7 @@ bool JSB_cpSpace_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION2(argc == 5, cx, false, "Invalid number of arguments"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsthis = args.thisv().toObjectOrNull(); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*) proxy->handle; @@ -1650,11 +1675,11 @@ void JSB_cpSpace_each_func(T* cpObject, void *data) if(jsCpObject) { JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; - jsval* func = ((JSB_cp_each_UserData*)data)->func; + JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func); JS::RootedValue rval(cx); jsval argv = OBJECT_TO_JSVAL(jsCpObject); - JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval); + JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval); } } @@ -1768,11 +1793,11 @@ void JSB_cpBody_each_func(cpBody* body, T* cpObject, void* data) if(jsCpObject) { JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; - jsval* func = ((JSB_cp_each_UserData*)data)->func; + JS::RootedValue func(cx, *((JSB_cp_each_UserData*)data)->func); JS::RootedValue rval(cx); jsval argv = OBJECT_TO_JSVAL(jsCpObject); - JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval); + JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::fromMarkedLocation(1, &argv), &rval); } } @@ -1850,8 +1875,9 @@ bool __jsb_cpArbiter_getBodies(JSContext *cx, const JS::CallArgs& args, cpArbite JS::RootedValue valA(cx); JS::RootedValue valB(cx); if( is_oo ) { - valA = c_class_to_jsval(cx, bodyA, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpArbiter"); - valB = c_class_to_jsval(cx, bodyB, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpArbiter"); + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + valA = c_class_to_jsval(cx, bodyA, bodyProto, JSB_cpBody_class, "cpArbiter"); + valB = c_class_to_jsval(cx, bodyB, bodyProto, JSB_cpBody_class, "cpArbiter"); } else { valA = opaque_to_jsval(cx, bodyA); valB = opaque_to_jsval(cx, bodyB); @@ -1905,8 +1931,9 @@ bool __jsb_cpArbiter_getShapes(JSContext *cx, const JS::CallArgs& args, cpArbite JS::RootedValue valA(cx); JS::RootedValue valB(cx); if( is_oo ) { - valA = c_class_to_jsval(cx, shapeA, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape"); - valB = c_class_to_jsval(cx, shapeB, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape"); + JS::RootedObject shapeProto(cx, JSB_cpShape_object); + valA = c_class_to_jsval(cx, shapeA, shapeProto, JSB_cpShape_class, "cpShape"); + valB = c_class_to_jsval(cx, shapeB, shapeProto, JSB_cpShape_class, "cpShape"); } else { valA = opaque_to_jsval(cx, shapeA); valB = opaque_to_jsval(cx, shapeB); @@ -1956,7 +1983,8 @@ bool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==2, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, JS::RootedObject(cx, JSB_cpBody_object), JS::NullPtr()); + JS::RootedObject bodyProto(cx, JSB_cpBody_object); + JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, bodyProto, JS::NullPtr()); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; double m = 0; double i = 0; @@ -2028,8 +2056,8 @@ static bool __jsb_cpBody_setUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) { JS::RootedObject jsobj(cx); - - bool ok = JS_ValueToObject(cx, JS::RootedValue(cx, *argvp), &jsobj); + JS::RootedValue jsv(cx, *argvp); + bool ok = JS_ValueToObject(cx, jsv, &jsobj); JSB_PRECONDITION(ok, "Error parsing arguments"); @@ -2046,7 +2074,8 @@ bool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); cpBody *body = nullptr; jsval* argvp = args.array(); - bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**) &body ); + JS::RootedValue jsarg(cx, *argvp++); + bool ok = jsval_to_opaque(cx, jsarg, (void**) &body); JSB_PRECONDITION(ok, "Error parsing arguments"); return __jsb_cpBody_setUserData(cx, vp, argvp, body); } @@ -2150,8 +2179,8 @@ JSObject* JSB_cpBase_object = NULL; bool JSB_cpBase_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc==1, cx, false, "Invalid arguments. Expecting 1"); - - JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, JS::RootedObject(cx, JSB_cpBase_object), JS::NullPtr()); + JS::RootedObject baseProto(cx, JSB_cpBase_object); + JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, baseProto, JS::NullPtr()); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; @@ -2238,8 +2267,6 @@ void JSB_cpBase_createClass(JSContext *cx, JS::HandleObject globalObj, const cha }; JSB_cpBase_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpBase_class, JSB_cpBase_constructor,0,properties,funcs,NULL,st_funcs); -// bool found; -// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } // Manual "methods" @@ -2247,7 +2274,8 @@ void JSB_cpBase_createClass(JSContext *cx, JS::HandleObject globalObj, const cha bool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); - JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, JS::RootedObject(cx, JSB_cpPolyShape_object), JS::NullPtr()); + JS::RootedObject polyShapeProto(cx, JSB_cpPolyShape_object); + JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, polyShapeProto, JS::NullPtr()); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; cpBody* body = nullptr; cpVect *verts = nullptr; cpVect offset; diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 7269841548..36e11f4378 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -334,7 +334,8 @@ bool js_cocos2dx_CCSequence_create(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc > 0) { Vector array; - if (argc == 1 && JS_IsArrayObject(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()))) { + JS::RootedObject actions(cx, args.get(0).toObjectOrNull()); + if (argc == 1 && JS_IsArrayObject(cx, actions)) { bool ok = true; ok &= jsval_to_ccvector(cx, args.get(0), &array); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); @@ -378,7 +379,8 @@ bool js_cocos2dx_CCSpawn_create(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc > 0) { Vector array; - if (argc == 1 && JS_IsArrayObject(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()))) { + JS::RootedObject actions(cx, args.get(0).toObjectOrNull()); + if (argc == 1 && JS_IsArrayObject(cx, actions)) { bool ok = true; ok &= jsval_to_ccvector(cx, args.get(0), &array); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); @@ -468,7 +470,8 @@ bool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) ok &= jsval_to_ccvector(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); } - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &arg1); + JS::RootedValue jsarg1(cx, args.get(1)); + ok &= JS::ToNumber(cx, jsarg1, &arg1); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1); } else if (argc == 3) { @@ -478,7 +481,8 @@ bool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); } unsigned int loops; - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &arg1); + JS::RootedValue jsarg1(cx, args.get(1)); + ok &= JS::ToNumber(cx, jsarg1, &arg1); ok &= jsval_to_uint32(cx, args.get(2), &loops); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); ret = cocos2d::Animation::create(arg0, arg1, loops); @@ -1248,7 +1252,8 @@ bool js_CCNode_scheduleOnce(JSContext *cx, uint32_t argc, jsval *vp) // double delay; if( argc >= 2 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &delay ); + JS::RootedValue jsdelay(cx, args.get(1)); + ok &= JS::ToNumber(cx, jsdelay, &delay); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); } @@ -1324,7 +1329,8 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp) double interval = 0.0; if( argc >= 2 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &interval ); + JS::RootedValue jsinterval(cx, args.get(1)); + ok &= JS::ToNumber(cx, jsinterval, &interval); } // @@ -1332,7 +1338,8 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp) // double repeat = 0.0; if( argc >= 3 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &repeat ); + JS::RootedValue jsrepeat(cx, args.get(2)); + ok &= JS::ToNumber(cx, jsrepeat, &repeat); } // @@ -1340,7 +1347,8 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp) // double delay = 0.0; if( argc >= 4 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &delay ); + JS::RootedValue jsdelay(cx, args.get(3)); + ok &= JS::ToNumber(cx, jsdelay, &delay); } JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); @@ -1629,7 +1637,8 @@ bool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval bool paused = false; if( argc >= 3 ) { - paused = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + JS::RootedValue jspaused(cx, args.get(2)); + paused = JS::ToBoolean(jspaused); } JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); @@ -1729,7 +1738,8 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva double interval = 0; if( argc >= 3 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &interval ); + JS::RootedValue jsinterval(cx, args.get(2)); + ok &= JS::ToNumber(cx, jsinterval, &interval); } // @@ -1737,7 +1747,8 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva // double repeat = kRepeatForever; if( argc >= 4 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &repeat ); + JS::RootedValue jsrepeat(cx, args.get(3)); + ok &= JS::ToNumber(cx, jsrepeat, &repeat); } // @@ -1745,13 +1756,15 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva // double delay = 0; if( argc >= 5 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(4)), &delay ); + JS::RootedValue jsdelay(cx, args.get(4)); + ok &= JS::ToNumber(cx, jsdelay, &delay); } bool paused = false; if( argc >= 6 ) { - paused = JS::ToBoolean(JS::RootedValue(cx, args.get(5))); + JS::RootedValue jspaused(cx, args.get(5)); + paused = JS::ToBoolean(jspaused); } JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); @@ -1841,7 +1854,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp) double interval = 0; if( argc >= 3 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &interval ); + JS::RootedValue jsinterval(cx, args.get(2)); + ok &= JS::ToNumber(cx, jsinterval, &interval); } // @@ -1849,7 +1863,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp) // double repeat = kRepeatForever; if( argc >= 4 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &repeat ); + JS::RootedValue jsrepeat(cx, args.get(3)); + ok &= JS::ToNumber(cx, jsrepeat, &repeat); } // @@ -1857,7 +1872,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp) // double delay = 0; if( argc >= 5 ) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(4)), &delay ); + JS::RootedValue jsdelay(cx, args.get(4)); + ok &= JS::ToNumber(cx, jsdelay, &delay); } // @@ -1865,7 +1881,8 @@ bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp) // bool paused = false; if( argc >= 6 ) { - paused = JS::ToBoolean(JS::RootedValue(cx, args.get(5))); + JS::RootedValue jspaused(cx, args.get(5)); + paused = JS::ToBoolean(jspaused); } // @@ -2177,9 +2194,11 @@ bool js_cocos2dx_CCNode_setPosition(JSContext *cx, uint32_t argc, jsval *vp) return true; } if (argc == 2) { double x; - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(0)), &x ); + JS::RootedValue jsx(cx, args.get(0)); + ok &= JS::ToNumber(cx, jsx, &x); double y; - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &y ); + JS::RootedValue jsy(cx, args.get(1)); + ok &= JS::ToNumber(cx, jsy, &y); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); cobj->setPosition(Point(x,y)); @@ -2209,9 +2228,11 @@ bool js_cocos2dx_CCNode_setContentSize(JSContext *cx, uint32_t argc, jsval *vp) return true; } if (argc == 2) { double width; - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(0)), &width ); + JS::RootedValue jsw(cx, args.get(0)); + ok &= JS::ToNumber(cx, jsw, &width); double height; - ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &height ); + JS::RootedValue jsh(cx, args.get(1)); + ok &= JS::ToNumber(cx, jsh, &height); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); cobj->setContentSize(Size(width,height)); @@ -2769,7 +2790,8 @@ bool js_BezierActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 2) { double arg0; cocos2d::_ccBezierConfig arg1; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0); + JS::RootedValue jsarg0(cx, args.get(0)); + ok &= JS::ToNumber( cx, jsarg0, &arg0); int num; cocos2d::Vec2 *arr; @@ -2901,7 +2923,8 @@ bool js_CatmullRomActions_initWithDuration(JSContext *cx, uint32_t argc, jsval * JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CatmullRom_initWithDuration : Invalid Native Object"); if (argc == 2) { double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0); + JS::RootedValue jsarg0(cx, args.get(0)); + ok &= JS::ToNumber(cx, jsarg0, &arg0); int num; Point *arr; @@ -2962,9 +2985,9 @@ bool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc, JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Invalid Native Object"); if (argc == 3) { double arg0; - double arg2; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0); + JS::RootedValue jsarg0(cx, args.get(0)); + ok &= JS::ToNumber(cx, jsarg0, &arg0); int num; Point *arr; @@ -2973,8 +2996,9 @@ bool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc, for( int i=0; i < num;i++) { arg1->addControlPoint(arr[i]); } - - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(2)), &arg2); + + JS::RootedValue jsarg2(cx, args.get(2)); + ok &= JS::ToNumber(cx, jsarg2, &arg2); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Error processing arguments"); bool ret = cobj->initWithDuration(arg0, arg1, arg2); @@ -3939,7 +3963,8 @@ bool js_cocos2dx_CCTMXLayer_getTileFlagsAt(JSContext *cx, uint32_t argc, jsval * static bool jsval_to_string_vector(JSContext* cx, jsval v, std::vector& ret) { JS::RootedObject jsobj(cx); - bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, v), &jsobj ); + JS::RootedValue jsv(cx, v); + bool ok = JS_ValueToObject(cx, jsv, &jsobj); JSB_PRECONDITION2( ok, cx, false, "Error converting value to object"); JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); @@ -4542,7 +4567,8 @@ bool js_PlistParser_parse(JSContext *cx, unsigned argc, JS::Value *vp) { //JS_GetStringCharsZ was removed in SpiderMonkey 33 //ok = JS_ParseJSON(cx, JS_GetStringCharsZ(cx, strVal), static_cast(JS_GetStringEncodingLength(JSVAL_TO_STRING(strVal))), &outVal); - ok = JS_ParseJSON(cx, JS::RootedString(cx, strVal.toString()), &outVal); + JS::RootedString jsout(cx, strVal.toString()); + ok = JS_ParseJSON(cx, jsout, &outVal); if (ok) args.rval().set(outVal); @@ -4655,8 +4681,9 @@ bool jsval_to_TTFConfig(JSContext *cx, jsval v, TTFConfig* ret) { std::string fontFilePath,customGlyphs; double fontSize, glyphs, outlineSize; - bool ok = v.isObject() && - JS_ValueToObject(cx, JS::RootedValue(cx, v), &tmp) && + JS::RootedValue jsv(cx, v); + bool ok = jsv.isObject() && + JS_ValueToObject(cx, jsv, &tmp) && JS_GetProperty(cx, tmp, "fontFilePath", &js_fontFilePath) && JS_GetProperty(cx, tmp, "fontSize", &js_fontSize) && JS_GetProperty(cx, tmp, "outlineSize", &js_outlineSize) && @@ -4805,7 +4832,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); if (!ok) { ok = true; break; } bool arg2; - arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + JS::RootedValue jsarg2(cx, args.get(2)); + arg2 = JS::ToBoolean(jsarg2); bool ret = cobj->saveToFile(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); @@ -4823,7 +4851,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); if (!ok) { ok = true; break; } bool arg2; - arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + JS::RootedValue jsarg2(cx, args.get(2)); + arg2 = JS::ToBoolean(jsarg2); std::function &)> arg3; do { std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(3))); @@ -4877,7 +4906,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v ok &= jsval_to_std_string(cx, args.get(0), &arg0); if (!ok) { ok = true; break; } bool arg1; - arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1))); + JS::RootedValue jsarg1(cx, args.get(1)); + arg1 = JS::ToBoolean(jsarg1); bool ret = cobj->saveToFile(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); @@ -4892,7 +4922,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v ok &= jsval_to_std_string(cx, args.get(0), &arg0); if (!ok) { ok = true; break; } bool arg1; - arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1))); + JS::RootedValue jsarg1(cx, args.get(1)); + arg1 = JS::ToBoolean(jsarg1); std::function &)> arg2; do { std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(2))); @@ -4972,14 +5003,15 @@ bool js_cocos2dx_Camera_isVisibleInFrustum(JSContext *cx, uint32_t argc, jsval * cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_isVisibleInFrustum : Invalid Native Object"); if (argc == 1) { - cocos2d::Vec3 min; + cocos2d::Vec3 min; JS::RootedValue jsmin(cx); - ok &= JS_GetProperty(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()), "min", &jsmin); + JS::RootedObject jsarg0(cx, args.get(0).toObjectOrNull()); + ok &= JS_GetProperty(cx, jsarg0, "min", &jsmin); ok &= jsval_to_vector3(cx, jsmin, &min); cocos2d::Vec3 max; JS::RootedValue jsmax(cx); - ok &= JS_GetProperty(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()), "max", &jsmax); + ok &= JS_GetProperty(cx, jsarg0, "max", &jsmax); ok &= jsval_to_vector3(cx, jsmax, &max); cocos2d::AABB aabb(min, max); @@ -5088,7 +5120,8 @@ bool js_cocos2dx_EventKeyboard_constructor(JSContext *cx, uint32_t argc, jsval * ok &= jsval_to_int32(cx, retVal, (int32_t *)&arg0); bool arg1; - arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1))); + JS::RootedValue jsarg1(cx, args.get(1)); + arg1 = JS::ToBoolean(jsarg1); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventKeyboard_constructor : Error processing arguments"); @@ -5104,8 +5137,11 @@ bool js_cocos2dx_EventKeyboard_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); - args.rval().set( OBJECT_TO_JSVAL(obj)); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); + JS::RootedValue objVal(cx, OBJECT_TO_JSVAL(obj)); + args.rval().set(objVal); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventKeyboard"); @@ -5150,32 +5186,20 @@ void js_register_cocos2dx_EventKeyboard(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parentProto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventKeyboard_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parentProto, jsb_cocos2d_EventKeyboard_class, js_cocos2dx_EventKeyboard_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, "EventKeyboard", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventKeyboard_class; - p->proto = jsb_cocos2d_EventKeyboard_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventKeyboard_prototype); + jsb_register_class(cx, jsb_cocos2d_EventKeyboard_class, proto, parentProto); } // console.log("Message"); @@ -5525,8 +5549,8 @@ bool js_cocos2dx_PolygonInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5596,17 +5620,8 @@ void js_register_cocos2dx_PolygonInfo(JSContext *cx, JS::HandleObject global) st_funcs); // add the proto and JSClass to the type->js info hash table - TypeTest 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)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PolygonInfo_prototype); + jsb_register_class(cx, jsb_cocos2d_PolygonInfo_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_AutoPolygon_class; @@ -5715,8 +5730,8 @@ bool js_cocos2dx_AutoPolygon_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5778,23 +5793,10 @@ void js_register_cocos2dx_AutoPolygon(JSContext *cx, JS::HandleObject global) { 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 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)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AutoPolygon_prototype); + jsb_register_class(cx, jsb_cocos2d_AutoPolygon_class, proto, JS::NullPtr()); } bool js_cocos2dx_ComponentJS_getScriptObject(JSContext *cx, uint32_t argc, jsval *vp) diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp index 8bd306404d..209f313ae8 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp @@ -100,8 +100,8 @@ inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - JS::RootedObject proto(cx, const_cast(typeProxy->proto.get())); - JS::RootedObject parent(cx, const_cast(typeProxy->parentProto.get())); + JS::RootedObject proto(cx, typeProxy->proto.ref().get()); + JS::RootedObject parent(cx, typeProxy->parentProto.ref().get()); JS::RootedObject js_obj(cx, JS_NewObject(cx, typeProxy->jsclass, proto, parent)); proxy = jsb_new_proxy(native_obj, js_obj); #ifdef DEBUG diff --git a/cocos/scripting/js-bindings/manual/cocosbuilder/cocosbuilder_specifics.hpp b/cocos/scripting/js-bindings/manual/cocosbuilder/cocosbuilder_specifics.hpp index d3fb9a0da0..3937486b55 100644 --- a/cocos/scripting/js-bindings/manual/cocosbuilder/cocosbuilder_specifics.hpp +++ b/cocos/scripting/js-bindings/manual/cocosbuilder/cocosbuilder_specifics.hpp @@ -44,7 +44,9 @@ public: JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - JS_CallFunctionValue(cx, JS::RootedObject(cx, thisObj.toObjectOrNull()), JS::RootedValue(cx, callback), JS::HandleValueArray::empty(), &retval); + JS::RootedObject jsThis(cx, thisObj.toObjectOrNull()); + JS::RootedValue jsCallback(cx, callback); + JS_CallFunctionValue(cx, jsThis, jsCallback, JS::HandleValueArray::empty(), &retval); } } diff --git a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp index 3f41693eb5..efdcb743e5 100644 --- a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp +++ b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp @@ -325,6 +325,8 @@ void register_CCBuilderReader(JSContext *cx, JS::HandleObject global) JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocosbuilder_CCBReader_prototype), "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocosbuilder_CCBAnimationManager_prototype), "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocosbuilder_CCBReader_prototype); + JS_DefineFunction(cx, tmpObj, "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocosbuilder_CCBAnimationManager_prototype); + JS_DefineFunction(cx, tmpObj, "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); } diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp index f996404c8c..8ad8a10f6e 100644 --- a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp @@ -29,7 +29,8 @@ jsval animationInfo_to_jsval(JSContext* cx, const cocostudio::timeline::Animatio { JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); if (!tmp) return JSVAL_NULL; - bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, std_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS::RootedValue jsname(cx, std_string_to_jsval(cx, v.name)); + bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "startIndex", v.startIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "endIndex", v.endIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp index 20f7fc1822..841409e802 100644 --- a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -217,8 +217,6 @@ static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32 } if(argc == 5){ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); @@ -747,7 +745,8 @@ bool js_set_AnimationData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); if (cobj) { std::string name; - bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name); + JS::RootedValue jsname(cx, vp.get()); + bool ok = jsval_to_std_string(cx, jsname, &name); JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_name : Error processing arguments"); cobj->name = name; return true; @@ -776,7 +775,8 @@ bool js_set_AnimationData_movementNames(JSContext *cx, JS::HandleObject obj, JS: cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); if (cobj) { std::vector movementNames; - bool ok = jsval_to_std_vector_string(cx, JS::RootedValue(cx, vp.get()), &movementNames); + JS::RootedValue jsmovementNames(cx, vp.get()); + bool ok = jsval_to_std_vector_string(cx, jsmovementNames, &movementNames); JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_movementNames : Error processing arguments."); cobj->movementNames.clear(); cobj->movementNames = movementNames; @@ -901,7 +901,8 @@ bool js_set_MovementData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); if (cobj) { std::string name; - bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name); + JS::RootedValue jsname(cx, vp.get()); + bool ok = jsval_to_std_string(cx, jsname, &name); JSB_PRECONDITION2(ok, cx, false, "js_set_MovementData_name : Error processing arguments"); cobj->name = name; return true; @@ -1375,7 +1376,8 @@ bool js_set_TextureData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId i cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { std::string name; - bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name); + JS::RootedValue jsname(cx, vp.get()); + bool ok = jsval_to_std_string(cx, jsname, &name); JSB_PRECONDITION2(ok, cx, false, "js_set_TextureData_name : Error processing arguments"); cobj->name = name; return true; @@ -1398,15 +1400,18 @@ extern JSObject* jsb_cocostudio_timeline_Frame_prototype; void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global) { - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ColliderBody_prototype), "getCalculatedVertexList", js_cocos2dx_studio_ColliderBody_getCalculatedVertexList, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject proto(cx, jsb_cocostudio_ColliderBody_prototype); + JS_DefineFunction(cx, proto, "getCalculatedVertexList", js_cocos2dx_studio_ColliderBody_getCalculatedVertexList, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureAnimation_prototype), "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureAnimation_prototype), "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureDataManager_prototype), "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ActionManagerEx_prototype), "initWithDictionaryEx", js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE); + proto.set(jsb_cocostudio_ArmatureAnimation_prototype); + JS_DefineFunction(cx, proto, "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, proto, "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + proto.set(jsb_cocostudio_ArmatureDataManager_prototype); + JS_DefineFunction(cx, proto, "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + proto.set(jsb_cocostudio_ActionManagerEx_prototype); + JS_DefineFunction(cx, proto, "initWithDictionaryEx", js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE); JS::RootedObject frame(cx, jsb_cocostudio_timeline_Frame_prototype); JS_DefineFunction(cx, frame, "setEasingParams", js_cocos2dx_studio_Frame_setEasingParams, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); @@ -1442,7 +1447,8 @@ void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global) JS_DefineProperty(cx, movementData, "loop", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_loop, js_set_MovementData_loop); JS_DefineProperty(cx, movementData, "tweenEasing", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_tweenEasing, js_set_MovementData_tweenEasing); - JS_DefineProperty(cx, JS::RootedObject(cx, jsb_cocostudio_ContourData_prototype), "vertextList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_ContourData_vertexList, js_set_ContourData_vertexList); + proto.set(jsb_cocostudio_ContourData_prototype); + JS_DefineProperty(cx, proto, "vertextList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_ContourData_vertexList, js_set_ContourData_vertexList); JS::RootedObject textureData(cx, jsb_cocostudio_TextureData_prototype); JS_DefineProperty(cx, textureData, "contourDataList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_contourDataList, js_set_TextureData_contourDataList); diff --git a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp index 643a3abde3..a8d81732f4 100644 --- a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp +++ b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp @@ -61,10 +61,10 @@ ComponentJS::ComponentJS(const std::string& scriptFileName) if (_succeedLoadingScript) { - JSObject* classObj = classValue.toObjectOrNull(); + JS::RootedObject classObj(cx, classValue.toObjectOrNull()); const JSClass* theClass = JS_GetClass(classObj); JS::RootedValue protoValue(cx); - JS_GetProperty(cx, JS::RootedObject(cx, classObj), "prototype", &protoValue); + JS_GetProperty(cx, classObj, "prototype", &protoValue); TypeTest t; js_type_class_t *typeClass = nullptr; diff --git a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp index d46c0bc9a6..7f3f343ad5 100644 --- a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp +++ b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp @@ -43,7 +43,8 @@ extern JSObject* jsb_cocos2d_experimental_ui_VideoPlayer_prototype; void register_all_cocos2dx_experimental_video_manual(JSContext* cx, JS::HandleObject global) { - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype), "addEventListener", jsb_cocos2dx_experimental_ui_VideoPlayer_addEventListener, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype); + JS_DefineFunction(cx, proto, "addEventListener", jsb_cocos2dx_experimental_ui_VideoPlayer_addEventListener, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); } #endif diff --git a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp index e58790c37a..08b0e37cac 100644 --- a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp +++ b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp @@ -145,10 +145,11 @@ extern JSObject* jsb_cocos2d_experimental_ui_WebView_prototype; void register_all_cocos2dx_experimental_webView_manual(JSContext* cx, JS::HandleObject global) { - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnShouldStartLoading", jsb_cocos2dx_experimental_webView_setOnShouldStartLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnDidFinishLoading", jsb_cocos2dx_experimental_webView_setOnDidFinishLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnDidFailLoading", jsb_cocos2dx_experimental_webView_setOnDidFailLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_WebView_prototype), "setOnJSCallback", jsb_cocos2dx_experimental_webView_setOnJSCallback, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_WebView_prototype); + JS_DefineFunction(cx, proto, "setOnShouldStartLoading", jsb_cocos2dx_experimental_webView_setOnShouldStartLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, proto, "setOnDidFinishLoading", jsb_cocos2dx_experimental_webView_setOnDidFinishLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, proto, "setOnDidFailLoading", jsb_cocos2dx_experimental_webView_setOnDidFailLoading, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, proto, "setOnJSCallback", jsb_cocos2dx_experimental_webView_setOnJSCallback, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); } #endif diff --git a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp index 3b2df42968..b3411b3752 100644 --- a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp @@ -377,7 +377,8 @@ static bool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc, if (argc == 1) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull())); + JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); + pNativeSource->setTableViewDataSource(jsdata); __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); if (NULL == userDict) @@ -409,7 +410,8 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval * { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull())); + JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); + pNativeSource->setTableViewDataSource(jsdata); cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, args.get(1), &arg1); @@ -479,7 +481,8 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); - pNativeSource->setTableViewDataSource(JS::RootedObject(cx, args.get(0).toObjectOrNull())); + JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); + pNativeSource->setTableViewDataSource(jsdata); cobj->setDataSource(pNativeSource); cocos2d::Size arg1; @@ -630,7 +633,8 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext // save the delegate JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget(); - nativeDelegate->setJSCallback(args.get(1), JS::RootedObject(cx, jsDelegate)); + JS::RootedObject jscb(cx, jsDelegate); + nativeDelegate->setJSCallback(args.get(1), jscb); nativeDelegate->setEventType(arg2); __Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject()); @@ -997,17 +1001,18 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject glob JS::RootedObject tmpObj(cx); get_or_create_js_obj(cx, global, "cc", &ccObj); - JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype); - JS_DefineFunction(cx, am, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, am, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS::RootedObject manifest(cx, jsb_cocos2d_extension_Manifest_prototype); - JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, manifest, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_extension_AssetsManagerEx_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_extension_Manifest_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_extension_ScrollView_prototype), "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_extension_ScrollView_prototype); + JS_DefineFunction(cx, tmpObj, "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS::RootedObject tableview(cx, jsb_cocos2d_extension_TableView_prototype); JS_DefineFunction(cx, tableview, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, tableview, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); @@ -1017,7 +1022,7 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject glob JS_DefineFunction(cx, control, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_GetProperty(cx, ccObj, "TableView", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); + tmpObj.set(tmpVal.toObjectOrNull()); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT); JS::RootedObject jsbObj(cx); diff --git a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp index 9b7a9663b0..3b6251b5c1 100644 --- a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp +++ b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp @@ -85,7 +85,9 @@ bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -159,32 +161,21 @@ void js_register_cocos2dx_GLNode(JSContext *cx, JS::HandleObject global) { JS_FN("create", js_cocos2dx_GLNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; - + + JS::RootedObject parentProto(cx, jsb_cocos2d_Node_prototype); js_cocos2dx_GLNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parentProto, js_cocos2dx_GLNode_class, js_cocos2dx_GLNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -// JS_SetPropertyAttributes(cx, global, "GLNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = js_cocos2dx_GLNode_class; - p->proto = js_cocos2dx_GLNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + // add the proto and JSClass to the type->js info hash table + JS::RootedObject proto(cx, js_cocos2dx_GLNode_prototype); + jsb_register_class(cx, js_cocos2dx_GLNode_class, proto, parentProto); + anonEvaluate(cx, global, "(function () { cc.GLNode.extend = cc.Class.extend; })()"); } diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index a2645181c1..1214e32f89 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -73,15 +73,8 @@ void JSStringWrapper::set(JSString* str, JSContext* cx) { cx = ScriptingCore::getInstance()->getGlobalContext(); } - // JS_EncodeString isn't supported in SpiderMonkey ff19.0. - //buffer = JS_EncodeString(cx, string); - - //JS_GetStringCharsZ is removed in SpiderMonkey 33 -// unsigned short* pStrUTF16 = (unsigned short*)JS_GetStringCharsZ(cx, str); - -// _buffer = cc_utf16_to_utf8(pStrUTF16, -1, NULL, NULL); - - _buffer = JS_EncodeStringToUTF8(cx, JS::RootedString(cx, str)); + JS::RootedString jsstr(cx, str); + _buffer = JS_EncodeStringToUTF8(cx, jsstr); } const char* JSStringWrapper::get() @@ -315,7 +308,7 @@ bool jsval_to_charptr( JSContext *cx, JS::HandleValue vp, const char **ret ) JSStringWrapper strWrapper(jsstr); // XXX: It is converted to String and then back to char* to autorelease the created object. - __String *tmp = String::create(strWrapper.get()); + __String *tmp = __String::create(strWrapper.get()); JSB_PRECONDITION2( tmp, cx, false, "Error creating string from UTF8"); @@ -696,27 +689,28 @@ bool jsval_to_ray(JSContext *cx, JS::HandleValue v, cocos2d::Ray* ret) bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, __Array** ret) { bool ok = true; - __Array* pArray = Array::create(); + __Array* pArray = __Array::create(); for( int i=0; i < argc; i++ ) { double num = 0.0; // optimization: JS::ToNumber is expensive. And can convert an string like "12" to a number - if (vp->isNumber()) { - ok &= JS::ToNumber(cx, JS::RootedValue(cx, *vp), &num ); + JS::RootedValue jsv(cx, *vp); + if (jsv.isNumber()) { + ok &= JS::ToNumber(cx, jsv, &num ); if (!ok) { break; } - pArray->addObject(Integer::create((int)num)); + pArray->addObject(__Integer::create((int)num)); } - else if (vp->isString()) + else if (jsv.isString()) { - JSStringWrapper str(vp->toString(), cx); - pArray->addObject(String::create(str.get())); + JSStringWrapper str(jsv, cx); + pArray->addObject(__String::create(str.get())); } else { js_proxy_t* p; - JSObject* obj = vp->toObjectOrNull(); + JS::RootedObject obj(cx, jsv.toObjectOrNull()); p = jsb_get_js_proxy(obj); if (p) { pArray->addObject((Ref*)p->ptr); @@ -1003,20 +997,20 @@ bool jsval_to_ccarray(JSContext* cx, JS::HandleValue v, __Array** ret) } else if (value.isString()) { JSStringWrapper valueWapper(value.toString(), cx); - arr->addObject(String::create(valueWapper.get())); + arr->addObject(__String::create(valueWapper.get())); // CCLOG("iterate array: value = %s", valueWapper.get().c_str()); } else if (value.isNumber()) { double number = 0.0; ok = JS::ToNumber(cx, value, &number); if (ok) { - arr->addObject(Double::create(number)); + arr->addObject(__Double::create(number)); // CCLOG("iterate array: value = %lf", number); } } else if (value.isBoolean()) { bool boolVal = JS::ToBoolean(value); - arr->addObject(Bool::create(boolVal)); + arr->addObject(__Bool::create(boolVal)); // CCLOG("iterate object: value = %d", boolVal); } else { @@ -1928,20 +1922,20 @@ bool jsval_to_ccdictionary(JSContext* cx, JS::HandleValue v, __Dictionary** ret) } else if (value.isString()) { JSStringWrapper valueWapper(value.toString(), cx); - dict->setObject(String::create(valueWapper.get()), keyWrapper.get()); + dict->setObject(__String::create(valueWapper.get()), keyWrapper.get()); // CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str()); } else if (value.isNumber()) { double number = 0.0; bool ok = JS::ToNumber(cx, value, &number); if (ok) { - dict->setObject(Double::create(number), keyWrapper.get()); + dict->setObject(__Double::create(number), keyWrapper.get()); // CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number); } } else if (value.isBoolean()) { bool boolVal = JS::ToBoolean(value); - dict->setObject(Bool::create(boolVal), keyWrapper.get()); + dict->setObject(__Bool::create(boolVal), keyWrapper.get()); // CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal); } else { @@ -2184,10 +2178,11 @@ jsval uniform_to_jsval(JSContext* cx, const cocos2d::Uniform* uniform) { JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); if(!tmp) return JSVAL_NULL; + JS::RootedValue jsname(cx, std_string_to_jsval(cx, uniform->name)); bool ok = JS_DefineProperty(cx, tmp, "location", uniform->location, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "size", uniform->size, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "type", uniform->type, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, std_string_to_jsval(cx, uniform->name)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT); if(ok) return OBJECT_TO_JSVAL(tmp); @@ -2214,39 +2209,33 @@ jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t) JS::RootedObject proto(cx); JS::RootedObject parent(cx); JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); -// if (!tmp) return JSVAL_NULL; + JS::RootedValue prop(cx); + bool ok = true; - - ok &= JS_DefineProperty(cx, tmp, "fontName", JS::RootedValue(cx, std_string_to_jsval(cx, t._fontName)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(std_string_to_jsval(cx, t._fontName)); + ok &= JS_DefineProperty(cx, tmp, "fontName", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "fontSize", t._fontSize, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "textAlign", (int32_t)t._alignment, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "verticalAlign", (int32_t)t._vertAlignment, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "fillStyle", JS::RootedValue(cx, cccolor3b_to_jsval(cx, t._fontFillColor)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - + prop.set(cccolor3b_to_jsval(cx, t._fontFillColor)); + ok &= JS_DefineProperty(cx, tmp, "fillStyle", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "boundingWidth", t._dimensions.width, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "boundingHeight", t._dimensions.height, JSPROP_ENUMERATE | JSPROP_PERMANENT); // Shadow - ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", JS::RootedValue(cx, BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - + prop.set(BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled)); + ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "shadowOffsetX", t._shadow._shadowOffset.width, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "shadowOffsetY", t._shadow._shadowOffset.height, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "shadowBlur", t._shadow._shadowBlur, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "shadowOpacity", t._shadow._shadowOpacity, JSPROP_ENUMERATE | JSPROP_PERMANENT); // Stroke - ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", JS::RootedValue(cx, BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "strokeStyle", JS::RootedValue(cx, cccolor3b_to_jsval(cx, t._stroke._strokeColor)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - + prop.set(BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled)); + ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(cccolor3b_to_jsval(cx, t._stroke._strokeColor)); + ok &= JS_DefineProperty(cx, tmp, "strokeStyle", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "lineWidth", t._stroke._strokeSize, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { @@ -2343,7 +2332,8 @@ bool jsval_to_FontDefinition( JSContext *cx, JS::HandleValue vp, FontDefinition JS_GetProperty(cx, jsobj, "fillStyle", &jsr); JS::RootedObject jsobjColor(cx); - if (!JS_ValueToObject( cx, JS::RootedValue(cx, jsr), &jsobjColor ) ) + JS::RootedValue jsvalColor(cx, jsr); + if (!JS_ValueToObject( cx, jsvalColor, &jsobjColor ) ) return false; out->_fontFillColor = getColorFromJSObject(cx, jsobjColor); diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 646348ff85..738ab0a337 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -123,14 +123,13 @@ bool jsvals_variadic_to_ccvector( JSContext *cx, /*jsval *vp, int argc,*/const J for (int i = 0; i < args.length(); i++) { js_proxy_t* p; - JSObject* obj = JS::RootedValue(cx, args.get(i)).toObjectOrNull(); + JS::RootedObject obj(cx, args.get(i).toObjectOrNull()); p = jsb_get_js_proxy(obj); CCASSERT(p, "Native object not found!"); if (p) { ret->pushBack((T)p->ptr); } - } JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); diff --git a/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp b/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp index c960160cca..eb8f4edd0c 100644 --- a/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp +++ b/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp @@ -273,9 +273,10 @@ bool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp) JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() )); JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object"); + JS::RootedValue jsname(cx, charptr_to_jsval(cx, buffer)); if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) || - !JS_DefineProperty(cx, object, "name", JS::RootedValue(cx, charptr_to_jsval(cx, buffer)), JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + !JS_DefineProperty(cx, object, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) return false; retval = OBJECT_TO_JSVAL(object); @@ -317,9 +318,10 @@ bool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp) JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() )); JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object"); + JS::RootedValue jsname(cx, charptr_to_jsval(cx, buffer)); if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) || - !JS_DefineProperty(cx, object, "name", JS::RootedValue(cx, charptr_to_jsval(cx, buffer)), JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + !JS_DefineProperty(cx, object, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) return false; retval = OBJECT_TO_JSVAL(object); diff --git a/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.cpp b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.cpp index 6474c62a32..4bb4edf400 100644 --- a/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.cpp +++ b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.cpp @@ -37,23 +37,22 @@ void jsb_register_system( JSContext *_cx, JS::HandleObject object) // JS::RootedObject proto(_cx); JS::RootedObject parent(_cx); - JSObject *sys = JS_NewObject(_cx, nullptr, proto, parent); + JS::RootedObject sys(_cx, JS_NewObject(_cx, nullptr, proto, parent)); JS::RootedValue systemVal(_cx); - systemVal = OBJECT_TO_JSVAL(sys); + systemVal.set(OBJECT_TO_JSVAL(sys)); JS_SetProperty(_cx, object, "sys", systemVal); // sys.localStorage JSObject *ls = JS_NewObject(_cx, nullptr, proto, parent); JS::RootedValue lsVal(_cx); - lsVal = OBJECT_TO_JSVAL(ls); - JS_SetProperty(_cx, JS::RootedObject(_cx, sys), "localStorage", lsVal); + lsVal.set(OBJECT_TO_JSVAL(ls)); + JS_SetProperty(_cx, sys, "localStorage", lsVal); // sys.localStorage functions JS::RootedObject system(_cx, ls); #include "js_bindings_system_functions_registration.h" - // Init DB with full path //NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; //NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; diff --git a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_conversions.cpp b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_conversions.cpp index 6d8500e015..f952c33f62 100644 --- a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_conversions.cpp @@ -84,8 +84,10 @@ jsval offMeshLinkData_to_jsval(JSContext* cx, const cocos2d::OffMeshLinkData& v) JS::RootedObject parent(cx); JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); if (!tmp) return JSVAL_NULL; - bool ok = JS_DefineProperty(cx, tmp, "startPosition", JS::RootedValue(cx, vector3_to_jsval(cx, v.startPosition)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "endPosition", JS::RootedValue(cx, vector3_to_jsval(cx, v.endPosition)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedValue jsstartPos(cx, vector3_to_jsval(cx, v.startPosition)); + JS::RootedValue jsendPos(cx, vector3_to_jsval(cx, v.endPosition)); + bool ok = JS_DefineProperty(cx, tmp, "startPosition", jsstartPos, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "endPosition", jsendPos, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } diff --git a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp index 313cee7be4..64bbfaaf32 100644 --- a/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp +++ b/cocos/scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp @@ -83,6 +83,7 @@ extern JSObject *jsb_cocos2d_NavMeshAgent_prototype; void register_all_cocos2dx_navmesh_manual(JSContext *cx, JS::HandleObject global) { - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_NavMeshAgent_prototype), "move", jsb_cocos2dx_navmesh_NavMeshAgent_move, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject proto(cx, jsb_cocos2d_NavMeshAgent_prototype); + JS_DefineFunction(cx, proto, "move", jsb_cocos2dx_navmesh_NavMeshAgent_move, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); } #endif //#if CC_USE_NAVMESH diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp index 29008bffe7..b71eb88b94 100644 --- a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp @@ -341,7 +341,9 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) js_proxy_t *p; jsval out; - JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, JS::RootedObject(cx, MinXmlHttpRequest::js_proto), JS::RootedObject(cx, MinXmlHttpRequest::js_parent)); + JS::RootedObject proto(cx, MinXmlHttpRequest::js_proto); + JS::RootedObject parentProto(cx, MinXmlHttpRequest::js_parent); + JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, proto, parentProto); if (obj) { JS_SetPrivate(obj, req); @@ -519,7 +521,7 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) { - args.rval().set(INT_TO_JSVAL(_status)); + args.rval().set(INT_TO_JSVAL((int)_status)); return true; } @@ -621,7 +623,8 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) //size_t utf16Count = 0; //const jschar* utf16Buf = JS_GetStringCharsZAndLength(cx, JSVAL_TO_STRING(strVal), &utf16Count); //bool ok = JS_ParseJSON(cx, utf16Buf, static_cast(utf16Count), &outVal); - bool ok = JS_ParseJSON(cx, JS::RootedString(cx, strVal.toString()), &outVal); + JS::RootedString jsstr(cx, strVal.toString()); + bool ok = JS_ParseJSON(cx, jsstr, &outVal); if (ok) { diff --git a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp index 309f09b0ac..0714054adf 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp @@ -169,9 +169,11 @@ bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp) if(!p) { //previous connection not found, create a new one - JSObject *obj = JS_NewObject(cx, js_cocos2dx_socketio_class, JS::RootedObject(cx, js_cocos2dx_socketio_prototype), JS::NullPtr()); + JS::RootedObject proto(cx, js_cocos2dx_socketio_prototype); + JSObject *obj = JS_NewObject(cx, js_cocos2dx_socketio_class, proto, JS::NullPtr()); p = jsb_new_proxy(ret, obj); - siodelegate->setJSDelegate(JS::RootedObject(cx, p->obj)); + JS::RootedObject jsdelegate(cx, p->obj); + siodelegate->setJSDelegate(jsdelegate); } jsret = OBJECT_TO_JSVAL(p->obj); } diff --git a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp index 4e293e4da8..bc4229416e 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp @@ -263,7 +263,8 @@ bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, j JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); } while (0); - JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, JS::RootedObject(cx, js_cocos2dx_websocket_prototype), JS::NullPtr())); + JS::RootedObject proto(cx, js_cocos2dx_websocket_prototype); + JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, proto, JS::NullPtr())); //JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, js_cocos2dx_websocket_class, args)); WebSocket* cobj = new WebSocket(); @@ -316,7 +317,8 @@ bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, j JS_DefineProperty(cx, obj, "URL", args.get(0), JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); //protocol not support yet (always return "") - JS_DefineProperty(cx, obj, "protocol", JS::RootedValue(cx, c_string_to_jsval(cx, "")), JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + JS::RootedValue jsprotocol(cx, c_string_to_jsval(cx, "")); + JS_DefineProperty(cx, obj, "protocol", jsprotocol, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); // link the native object with the javascript object js_proxy_t *p = jsb_new_proxy(cobj, obj); @@ -392,10 +394,6 @@ void register_jsb_websocket(JSContext *cx, JS::HandleObject global) { JS_DefineProperty(cx, jsclassObj, "OPEN", (int)WebSocket::State::OPEN, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); JS_DefineProperty(cx, jsclassObj, "CLOSING", (int)WebSocket::State::CLOSING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); JS_DefineProperty(cx, jsclassObj, "CLOSED", (int)WebSocket::State::CLOSED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - - // make the class enumerable in the registered namespace -//FIXME: bool found; -// JS_SetPropertyAttributes(cx, global, "WebSocket", JSPROP_ENUMERATE | JSPROP_READONLY, &found); } diff --git a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp index 203e94c50b..4a96368d95 100644 --- a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp +++ b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp @@ -222,11 +222,16 @@ jsval physics3d_collisionPoint_to_jsval(JSContext*cx, const Physics3DCollisionIn { JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); - JS_DefineProperty(cx, tmp, "localPositionOnA", JS::RootedValue(cx, vector3_to_jsval(cx, point.localPositionOnA)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineProperty(cx, tmp, "localPositionOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.localPositionOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineProperty(cx, tmp, "worldPositionOnA", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldPositionOnA)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineProperty(cx, tmp, "worldPositionOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldPositionOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineProperty(cx, tmp, "worldNormalOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldNormalOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedValue prop(cx, vector3_to_jsval(cx, point.localPositionOnA)); + JS_DefineProperty(cx, tmp, "localPositionOnA", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(vector3_to_jsval(cx, point.localPositionOnB)); + JS_DefineProperty(cx, tmp, "localPositionOnB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(vector3_to_jsval(cx, point.worldPositionOnA)); + JS_DefineProperty(cx, tmp, "worldPositionOnA", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(vector3_to_jsval(cx, point.worldPositionOnB)); + JS_DefineProperty(cx, tmp, "worldPositionOnB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(vector3_to_jsval(cx, point.worldNormalOnB)); + JS_DefineProperty(cx, tmp, "worldNormalOnB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); return OBJECT_TO_JSVAL(tmp); } @@ -236,10 +241,12 @@ jsval physics3d_collisioninfo_to_jsval(JSContext* cx, const Physics3DCollisionIn JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); js_proxy_t* proxy = js_get_or_create_proxy(cx, ci.objA); - JS_DefineProperty(cx, tmp, "objA", JS::RootedValue(cx, OBJECT_TO_JSVAL(proxy->obj)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedValue prop(cx, OBJECT_TO_JSVAL(proxy->obj)); + JS_DefineProperty(cx, tmp, "objA", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); proxy = js_get_or_create_proxy(cx, ci.objB); - JS_DefineProperty(cx, tmp, "objB", JS::RootedValue(cx, OBJECT_TO_JSVAL(proxy->obj)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(OBJECT_TO_JSVAL(proxy->obj)); + JS_DefineProperty(cx, tmp, "objB", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS::RootedObject jsarr(cx, JS_NewArrayObject(cx, ci.collisionPointList.size())); uint32_t i = 0; @@ -248,7 +255,8 @@ jsval physics3d_collisioninfo_to_jsval(JSContext* cx, const Physics3DCollisionIn JS::RootedValue element(cx, physics3d_collisionPoint_to_jsval(cx, *iter)); JS_SetElement(cx, jsarr, i++, element); } - JS_DefineProperty(cx, tmp, "collisionPointList", JS::RootedValue(cx, OBJECT_TO_JSVAL(jsarr)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + prop.set(OBJECT_TO_JSVAL(jsarr)); + JS_DefineProperty(cx, tmp, "collisionPointList", prop, JSPROP_ENUMERATE | JSPROP_PERMANENT); return OBJECT_TO_JSVAL(tmp); } @@ -265,7 +273,8 @@ bool jsb_cocos2d_Physics3DObject_setCollisionCallback(JSContext *cx, uint32_t ar JSB_PRECONDITION2( cobj, cx, false, "jsb_cocos2d_Physics3DObject_setCollisionCallback : Invalid Native Object"); std::function arg0; - std::shared_ptr func(new JSFunctionWrapper(cx, JS::RootedObject(cx, args.get(1).toObjectOrNull()), args.get(0))); + JS::RootedObject jstarget(cx, args.get(1).toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](const Physics3DCollisionInfo &ci) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET @@ -473,20 +482,23 @@ void register_all_cocos2dx_physics3d_manual(JSContext *cx, JS::HandleObject glob JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_PhysicsSprite3D_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_GetProperty(cx, ccObj, "Physics3DRigidBody", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); + tmpObj.set(tmpVal.toObjectOrNull()); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_physics3d_Physics3DRigidBody_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_GetProperty(cx, ccObj, "Physics3DShape", &tmpVal); - tmpObj = tmpVal.toObjectOrNull(); + tmpObj.set(tmpVal.toObjectOrNull()); JS_DefineFunction(cx, tmpObj, "createMesh", js_cocos2dx_physics3d_Physics3dShape_createMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "createHeightfield", js_cocos2dx_physics3d_Physics3dShape_createHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DShape_prototype), "initMesh", js_cocos2dx_physics3d_Physics3dShape_initMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DShape_prototype), "initHeightfield", js_cocos2dx_physics3d_Physics3dShape_initHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Physics3DShape_prototype); + JS_DefineFunction(cx, tmpObj, "initMesh", js_cocos2dx_physics3d_Physics3dShape_initMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "initHeightfield", js_cocos2dx_physics3d_Physics3dShape_initHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DObject_prototype), "setCollisionCallback", jsb_cocos2d_Physics3DObject_setCollisionCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Physics3DObject_prototype); + JS_DefineFunction(cx, tmpObj, "setCollisionCallback", jsb_cocos2d_Physics3DObject_setCollisionCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DWorld_prototype), "rayCast", js_cocos2dx_physics3d_Physics3DWorld_rayCast, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Physics3DWorld_prototype); + JS_DefineFunction(cx, tmpObj, "rayCast", js_cocos2dx_physics3d_Physics3DWorld_rayCast, 2, JSPROP_READONLY | JSPROP_PERMANENT); } #endif //CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION diff --git a/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm index 49dd7ee51b..daf362021b 100644 --- a/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm +++ b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm @@ -48,6 +48,8 @@ JS::Value JavaScriptObjCBridge::convertReturnValue(JSContext *cx, ReturnValue re return BOOLEAN_TO_JSVAL(retValue.boolValue); case TypeString: return c_string_to_jsval(cx, retValue.stringValue->c_str(),retValue.stringValue->size()); + default: + break; } return ret; @@ -74,11 +76,13 @@ bool JavaScriptObjCBridge::CallInfo::execute(JSContext *cx,jsval *argv,unsigned [m_dic setObject:[NSString stringWithCString:valueWapper.get() encoding:NSUTF8StringEncoding] forKey:key]; }else if(arg.isNumber()){ double a; - ok &= JS::ToNumber(cx, JS::RootedValue(cx,arg), &a); + JS::RootedValue jsa(cx,arg); + ok &= JS::ToNumber(cx, jsa, &a); [m_dic setObject:[NSNumber numberWithFloat:a] forKey:key]; }else if(arg.isBoolean()){ - bool a = JS::ToBoolean(JS::RootedValue(cx,arg)); + JS::RootedValue jsa(cx,arg); + bool a = JS::ToBoolean(jsa); [m_dic setObject:[NSNumber numberWithBool:a] forKey:key]; } } @@ -233,7 +237,9 @@ JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge) js_proxy_t *p; jsval out; - JSObject *obj = JS_NewObject(cx, &JavaScriptObjCBridge::js_class, JS::RootedObject(cx, JavaScriptObjCBridge::js_proto), JS::RootedObject(cx, JavaScriptObjCBridge::js_parent)); + JS::RootedObject proto(cx, JavaScriptObjCBridge::js_proto); + JS::RootedObject parentProto(cx, JavaScriptObjCBridge::js_parent); + JSObject *obj = JS_NewObject(cx, &JavaScriptObjCBridge::js_class, proto, parentProto); if (obj) { JS_SetPrivate(obj, jsj); diff --git a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h index 90adaadc81..535752474a 100644 --- a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h +++ b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h @@ -26,6 +26,7 @@ #include "jsapi.h" #include "jsfriendapi.h" #include "uthash.h" +#include "mozilla/Maybe.h" #include typedef struct js_proxy { @@ -39,8 +40,8 @@ extern js_proxy_t *_js_native_global_ht; typedef struct js_type_class { JSClass *jsclass; - JS::Heap proto; - JS::Heap parentProto; + mozilla::Maybe proto; + mozilla::Maybe parentProto; } js_type_class_t; extern std::unordered_map _js_global_type_map; diff --git a/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp index 79147fce85..bee3f344a3 100644 --- a/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp +++ b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp @@ -32,10 +32,12 @@ jsval speventdata_to_jsval(JSContext* cx, spEventData& v) { JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); if (!tmp) return JSVAL_NULL; - bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name)); + JS::RootedValue jsstr(cx, c_string_to_jsval(cx, v.stringValue)); + bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "stringValue", JS::RootedValue(cx, c_string_to_jsval(cx, v.stringValue)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "stringValue", jsstr, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { @@ -49,10 +51,12 @@ jsval spevent_to_jsval(JSContext* cx, spEvent& v) JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); if (!tmp) return JSVAL_NULL; - bool ok = JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, speventdata_to_jsval(cx, *v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS::RootedValue jsdata(cx, speventdata_to_jsval(cx, *v.data)); + JS::RootedValue jsstr(cx, c_string_to_jsval(cx, v.stringValue)); + bool ok = JS_DefineProperty(cx, tmp, "data", jsdata, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "stringValue", JS::RootedValue(cx, c_string_to_jsval(cx, v.stringValue)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "stringValue", jsstr, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { @@ -72,7 +76,8 @@ jsval spbonedata_to_jsval(JSContext* cx, const spBoneData* v) if (strcmp(v->name, "root") && v->parent) parentVal = spbonedata_to_jsval(cx, v->parent); - bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v->name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS::RootedValue jsname(cx, c_string_to_jsval(cx, v->name)); + bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "parent", parentVal,JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "length", v->length, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "x", v->x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && @@ -101,7 +106,8 @@ jsval spbone_to_jsval(JSContext* cx, spBone& v) if (strcmp(v.data->name, "root") && v.parent) parentVal = spbone_to_jsval(cx, *v.parent); - bool ok = JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, spbonedata_to_jsval(cx, v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS::RootedValue jsdata(cx, spbonedata_to_jsval(cx, v.data)); + bool ok = JS_DefineProperty(cx, tmp, "data", jsdata, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "parent", parentVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && @@ -152,7 +158,8 @@ jsval spattachment_to_jsval(JSContext* cx, spAttachment& v) JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); if (!tmp) return JSVAL_NULL; - bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name)); + bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "type", v.type, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) @@ -168,14 +175,17 @@ jsval spslotdata_to_jsval(JSContext* cx, spSlotData& v) JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); if (!tmp) return JSVAL_NULL; - bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "attachmentName", JS::RootedValue(cx, c_string_to_jsval(cx, v.attachmentName)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name)); + JS::RootedValue jsattachmentName(cx, c_string_to_jsval(cx, v.attachmentName)); + JS::RootedValue jsboneData(cx, spbonedata_to_jsval(cx, v.boneData)); + bool ok = JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "attachmentName", jsattachmentName, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "blendMode", v.blendMode, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "boneData", JS::RootedValue(cx, spbonedata_to_jsval(cx, v.boneData)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "boneData", jsboneData, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { @@ -190,14 +200,17 @@ jsval spslot_to_jsval(JSContext* cx, spSlot& v) JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); if (!tmp) return JSVAL_NULL; + JS::RootedValue jsbone(cx, spbone_to_jsval(cx, *v.bone)); + JS::RootedValue jsattachment(cx, spattachment_to_jsval(cx, *v.attachment)); + JS::RootedValue jsdata(cx, spslotdata_to_jsval(cx, *v.data)); bool ok = JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "bone", JS::RootedValue(cx, spbone_to_jsval(cx, *v.bone)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "bone", jsbone, JSPROP_ENUMERATE | JSPROP_PERMANENT) && //JS_DefineProperty(cx, tmp, "skeleton", spskeleton_to_jsval(cx, *v.skeleton), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "attachment", JS::RootedValue(cx, spattachment_to_jsval(cx, *v.attachment)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, spslotdata_to_jsval(cx, *v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "attachment", jsattachment, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "data", jsdata, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { @@ -243,10 +256,12 @@ jsval spanimation_to_jsval(JSContext* cx, spAnimation& v) JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); if (!tmp) return JSVAL_NULL; + JS::RootedValue jsname(cx, c_string_to_jsval(cx, v.name)); + JS::RootedValue jstimelines(cx, sptimeline_to_jsval(cx, **v.timelines)); bool ok = JS_DefineProperty(cx, tmp, "duration", v.duration, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "timelineCount", v.timelinesCount, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "timelines", JS::RootedValue(cx, sptimeline_to_jsval(cx, **v.timelines)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "name", jsname, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "timelines", jstimelines, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { @@ -269,6 +284,7 @@ jsval sptrackentry_to_jsval(JSContext* cx, spTrackEntry& v) if (v.previous) previousVal = sptrackentry_to_jsval(cx, *v.previous); + JS::RootedValue jsanimation(cx, spanimation_to_jsval(cx, *v.animation)); bool ok = JS_DefineProperty(cx, tmp, "delay", v.delay, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "time", v.time, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "lastTime", v.lastTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) && @@ -276,7 +292,7 @@ jsval sptrackentry_to_jsval(JSContext* cx, spTrackEntry& v) JS_DefineProperty(cx, tmp, "timeScale", v.timeScale, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "mixTime", v.mixTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "mixDuration", v.mixDuration, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "animation", JS::RootedValue(cx, spanimation_to_jsval(cx, *v.animation)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "animation", jsanimation, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "next", nextVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "previous", previousVal, JSPROP_ENUMERATE | JSPROP_PERMANENT); @@ -472,7 +488,7 @@ bool jsb_cocos2dx_spine_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); - bool arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + bool arg2 = JS::ToBoolean(args.get(2)); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); spTrackEntry* ret = cobj->setAnimation(arg0, arg1, arg2); diff --git a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp index e63f5ba13d..c8836a4a4f 100755 --- a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp @@ -61,10 +61,14 @@ static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, else if (argc == 4) { bool ok = true; double left, top,right,bottom; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[0]), &left); - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[1]), &top); - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[2]), &right); - ok &= JS::ToNumber( cx, JS::RootedValue(cx, args[3]), &bottom); + JS::RootedValue jsv(cx, args[0]); + ok &= JS::ToNumber( cx, jsv, &left); + jsv.set(args[1]); + ok &= JS::ToNumber( cx, jsv, &top); + jsv.set(args[2]); + ok &= JS::ToNumber( cx, jsv, &right); + jsv.set(args[3]); + ok &= JS::ToNumber( cx, jsv, &bottom); JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); @@ -200,7 +204,10 @@ extern JSObject* jsb_cocos2d_ui_EditBox_prototype; void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global) { - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_EditBox_prototype), "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype); + JS_DefineFunction(cx, proto, "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, proto, "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + proto.set(jsb_cocos2d_ui_EditBox_prototype); + JS_DefineFunction(cx, proto, "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); } diff --git a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp index 9618fb9926..10320ee135 100644 --- a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp +++ b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp @@ -557,32 +557,20 @@ void js_register_cocos2dx_DrawNode3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; - jsb_cocos2d_DrawNode3D_prototype = JS_InitClass( + JS::RootedObject parentProto(cx, jsb_cocos2d_Node_prototype); + JS::RootedObject proto(cx, JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parentProto, jsb_cocos2d_DrawNode3D_class, js_cocos2dx_DrawNode3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "DrawNode3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - + st_funcs)); + + jsb_cocos2d_DrawNode3D_prototype = proto.get(); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_DrawNode3D_class; - p->proto = jsb_cocos2d_DrawNode3D_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + jsb_register_class(cx, jsb_cocos2d_DrawNode3D_class, proto, parentProto); } void register_DrawNode3D_bindings(JSContext *cx, JS::HandleObject global) diff --git a/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp index b4de7b6830..f3a4d760fd 100644 --- a/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp +++ b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp @@ -525,32 +525,20 @@ void js_register_cocos2dx_Effect3DOutline(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parentProto(cx, jsb_Effect3D_prototype); jsb_Effect3DOutline_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_Effect3D_prototype), + parentProto, jsb_Effect3DOutline_class, jsb_Effect3DOutline_constructor, 0, 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, "Effect3DOutline", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Effect3DOutline_class; - p->proto = jsb_Effect3DOutline_prototype; - p->parentProto = jsb_Effect3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_Effect3DOutline_prototype); + jsb_register_class(cx, jsb_Effect3DOutline_class, proto, parentProto); } @@ -740,32 +728,20 @@ void js_register_cocos2dx_EffectSprite3D(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parentProto(cx, jsb_cocos2d_Sprite3D_prototype); jsb_EffectSprite3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), + parentProto, jsb_EffectSprite3D_class, jsb_EffectSprite3D_constructor, 1, 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, "EffectSprite3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EffectSprite3D_class; - p->proto = jsb_EffectSprite3D_prototype; - p->parentProto = jsb_cocos2d_Sprite3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_EffectSprite3D_prototype); + jsb_register_class(cx, jsb_EffectSprite3D_class, proto, parentProto); } void register_Effect3D_bindings(JSContext *cx, JS::HandleObject global) diff --git a/tools/bindings-generator b/tools/bindings-generator index 4ecd2f4536..3dd232b790 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 4ecd2f4536bd57d42b4b370a6a4fc7c7420f5404 +Subproject commit 3dd232b790e85b2cc4a0a0a0e2fb1fc103f57249 From 73c3a5dcf5ddf3812641906fb8b573e542bf2702 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 01:27:39 +0800 Subject: [PATCH 152/192] Activate DEBUG to test --- build/cocos2d_tests.xcodeproj/project.pbxproj | 1 + .../proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj | 1 + 2 files changed, 2 insertions(+) diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 7cd2fb0d3d..4fc63d72ae 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -7149,6 +7149,7 @@ "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + DEBUG, ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index ab0bc1f418..29753b4cbf 100644 --- a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -903,6 +903,7 @@ "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + DEBUG, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; From d23ffe4fc77de77692368a664aaf3df1e4b6b082 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 10:16:11 +0800 Subject: [PATCH 153/192] Fix some issue of js_type_class usage --- .../scripting/js-bindings/manual/cocos2d_specifics.cpp | 2 +- .../js-bindings/manual/component/CCComponentJS.cpp | 4 ++-- .../project/Classes/js_DrawNode3D_bindings.cpp | 4 ++-- .../js-tests/project/Classes/js_Effect3D_bindings.cpp | 10 ++++------ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 36e11f4378..d0955ef93f 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -5807,7 +5807,7 @@ bool js_cocos2dx_ComponentJS_getScriptObject(JSContext *cx, uint32_t argc, jsval cocos2d::ComponentJS* cobj = (cocos2d::ComponentJS *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentJS_getScriptObject : Invalid Native Object"); if (argc == 0) { - JSObject* ret = static_cast(cobj->getScriptObject()); + JS::RootedObject ret(cx, static_cast(cobj->getScriptObject())); jsval jsret = OBJECT_TO_JSVAL(ret); args.rval().set(jsret); return true; diff --git a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp index a8d81732f4..597903d11a 100644 --- a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp +++ b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp @@ -76,7 +76,7 @@ ComponentJS::ComponentJS(const std::string& scriptFileName) mozilla::Maybe *jsObj = new mozilla::Maybe(); JS::RootedObject proto(cx, protoValue.toObjectOrNull()); - JS::RootedObject parent(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->proto.ref()); jsObj->construct(cx); jsObj->ref() = JS_NewObject(cx, theClass, proto, parent); @@ -85,7 +85,7 @@ ComponentJS::ComponentJS(const std::string& scriptFileName) JS::RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(jsb_get_native_proxy(this), jsproxy); // link the native object with the javascript object - jsb_new_proxy(this, jsObj->ref().get()); + jsb_new_proxy(this, jsObj->ref()); _jsObj = jsObj; } diff --git a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp index 10320ee135..cc1bb7a1f0 100644 --- a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp +++ b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp @@ -499,8 +499,8 @@ bool js_cocos2dx_DrawNode3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 diff --git a/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp index f3a4d760fd..d235238172 100644 --- a/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp +++ b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp @@ -483,9 +483,8 @@ bool jsb_Effect3DOutline_constructor(JSContext *cx, uint32_t argc, jsval *vp) 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -685,9 +684,8 @@ bool jsb_EffectSprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 From 8320c2f7020a5696182a372bf35c795af3020be2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 10:19:13 +0800 Subject: [PATCH 154/192] Use rooted object for js_proxy new and get --- .../js-bindings/manual/ScriptingCore.cpp | 6 ++- .../chipmunk/js_bindings_chipmunk_manual.cpp | 12 ++--- .../js-bindings/manual/cocos2d_specifics.cpp | 48 ++++++++++--------- .../cocosbuilder/js_bindings_ccbreader.cpp | 8 ++-- .../cocostudio/jsb_cocos2dx_studio_manual.cpp | 34 ++++++------- .../jsb_cocos2dx_extension_manual.cpp | 16 +++---- .../js-bindings/manual/js_bindings_opengl.cpp | 2 +- .../manual/js_manual_conversions.h | 4 +- .../manual/network/XMLHTTPRequest.cpp | 4 +- .../manual/network/jsb_socketio.cpp | 6 +-- .../manual/network/jsb_websocket.cpp | 5 +- .../jsb_cocos2dx_physics3d_manual.cpp | 6 ++- .../platform/ios/JavaScriptObjCBridge.mm | 4 +- 13 files changed, 82 insertions(+), 73 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index cf9a1c7728..cc76082102 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -224,7 +224,8 @@ void removeJSObject(JSContext* cx, void* nativeObj) nproxy = jsb_get_native_proxy(nativeObj); if (nproxy) { - jsproxy = jsb_get_js_proxy(nproxy->obj); + JS::RootedObject jsobj(cx, nproxy->obj); + jsproxy = jsb_get_js_proxy(jsobj); RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); } @@ -873,7 +874,8 @@ void ScriptingCore::removeScriptObjectByObject(Ref* pObj) if (nproxy) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - jsproxy = jsb_get_js_proxy(nproxy->obj); + JS::RootedObject jsobj(cx, nproxy->obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { RemoveObjectRoot(cx, &jsproxy->obj); diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp index 1780684783..659c1437ec 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -205,7 +205,7 @@ bool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t JS::RootedObject proto(cx, typeClass->proto.ref()); JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCDebugNode"); @@ -355,7 +355,7 @@ bool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t JS::RootedObject proto(cx, typeClass->proto.ref()); JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); @@ -385,7 +385,7 @@ bool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t CCASSERT(typeClass, "The value is null."); JS::RootedObject proto(cx, typeClass->proto.ref()); JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); @@ -408,7 +408,7 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32 if (argc >= 1) { do { js_proxy_t *proxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg0) @@ -428,7 +428,7 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32 CCASSERT(typeClass, "The value is null."); JS::RootedObject proto(cx, typeClass->proto.ref()); JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); @@ -464,7 +464,7 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, ui CCASSERT(typeClass, "The value is null."); JS::RootedObject proto(cx, typeClass->proto.ref()); JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index d0955ef93f..b9c1e2a412 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -189,7 +189,7 @@ void JSTouchDelegate::onTouchesCancelled(const std::vector& touches, Eve // cc.EventTouch#getTouches bool js_cocos2dx_EventTouch_getTouches(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = args.thisv().toObjectOrNull(); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EventTouch* cobj = (cocos2d::EventTouch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventTouch_getTouches : Invalid Native Object"); @@ -244,7 +244,7 @@ bool js_cocos2dx_EventTouch_setTouches(JSContext *cx, uint32_t argc, jsval *vp) JS::RootedValue value(cx); if (JS_GetElement(cx, jsobj, i, &value)) { - JSObject *tmp = value.toObjectOrNull(); + JS::RootedObject tmp(cx, value.toObjectOrNull()); proxy = jsb_get_js_proxy(tmp); cocos2d::Touch* touchObj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); if (touchObj) { @@ -279,7 +279,7 @@ bool js_cocos2dx_CCMenu_create(JSContext *cx, uint32_t argc, jsval *vp) uint32_t i = 0; while (i < argc) { js_proxy_t *proxy; - JSObject *tmpObj = args.get(i).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(i).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); cocos2d::MenuItem *item = (cocos2d::MenuItem*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) @@ -343,7 +343,7 @@ bool js_cocos2dx_CCSequence_create(JSContext *cx, uint32_t argc, jsval *vp) uint32_t i = 0; while (i < argc) { js_proxy_t *proxy; - JSObject *tmpObj = args.get(i).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(i).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); cocos2d::FiniteTimeAction *item = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) @@ -388,7 +388,7 @@ bool js_cocos2dx_CCSpawn_create(JSContext *cx, uint32_t argc, jsval *vp) uint32_t i = 0; while (i < argc) { js_proxy_t *proxy; - JSObject *tmpObj = args[i].toObjectOrNull(); + JS::RootedObject tmpObj(cx, args[i].toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); cocos2d::FiniteTimeAction *item = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) @@ -427,7 +427,7 @@ bool js_cocos2dx_CCMenuItemToggle_create(JSContext *cx, uint32_t argc, jsval *vp for (uint32_t i=0; i < argc; i++) { js_proxy_t *proxy; - JSObject *tmpObj = args.get(i).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(i).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); cocos2d::MenuItem* item = (cocos2d::MenuItem*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) @@ -519,7 +519,7 @@ bool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_CCScene_init(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = args.thisv().toObjectOrNull(); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_init : Invalid Native Object"); @@ -605,7 +605,7 @@ bool js_cocos2dx_JSTouchDelegate_unregisterTouchDelegate(JSContext *cx, uint32_t { if (argc == 1) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsobj = args.get(0).toObjectOrNull(); + JS::RootedObject jsobj(cx, args.get(0).toObjectOrNull()); JSTouchDelegate* pDelegate = JSTouchDelegate::getDelegateForJSObject(jsobj); if (pDelegate) { @@ -2311,7 +2311,7 @@ bool js_cocos2dx_CCNode_pause(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_pause : Invalid Native Object"); if (argc == 0) { do { -// JSObject *tmpObj = obj; +// JS::RootedObject tmpObj(cx, obj); __Array *arr = JSScheduleWrapper::getTargetForJSObject(obj); if(arr){ @@ -2343,7 +2343,7 @@ bool js_cocos2dx_CCNode_resume(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_resume : Invalid Native Object"); if (argc == 0) { do { -// JSObject *tmpObj = obj; +// JS::RootedObject tmpObj(cx, obj); __Array *arr = JSScheduleWrapper::getTargetForJSObject(obj); if(arr){ @@ -2427,7 +2427,7 @@ bool js_cocos2dx_CCTMXLayer_getTiles(JSContext *cx, uint32_t argc, jsval *vp) uint32_t* ret = cobj->getTiles(); Size size = cobj->getLayerSize(); int count = size.width * size.height; - JSObject* array = JS_NewUint32Array(cx, count); + JS::RootedObject array(cx, JS_NewUint32Array(cx, count)); if (NULL == array) { JS_ReportError(cx, "Can't allocate enough memory."); return false; @@ -3779,7 +3779,7 @@ bool js_cocos2dx_Sprite_initWithPolygon(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PolygonInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3810,7 +3810,7 @@ bool js_cocos2dx_Sprite_setPolygonInfo(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PolygonInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4081,7 +4081,7 @@ bool js_cocos2dx_CCFileUtils_getDataFromFile(JSContext *cx, uint32_t argc, jsval if (!data.isNull()) { uint32_t size = static_cast(data.getSize()); - JSObject* array = JS_NewUint8Array(cx, size); + JS::RootedObject array(cx, JS_NewUint8Array(cx, size)); if (nullptr == array) break; @@ -4443,7 +4443,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec4(JSContext *cx, uint32_t argc, jsv float y; \ float z; \ cobj->funcName(&x, &y, &z); \ - JSObject* tmp = JS_NewObject(cx, NULL, NULL, NULL); \ + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, NULL, NULL)); \ \ do \ { \ @@ -4508,7 +4508,7 @@ bool js_cocos2dx_NodeGrid_setGrid(JSContext *cx, uint32_t argc, jsval *vp) do { if(args.get(0).isNull()) { arg0 = nullptr; break;} if (!args.get(0).isObject()) { ok = false; break; } - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GridBase*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5086,7 +5086,7 @@ bool js_cocos2dx_ClippingNode_init(JSContext *cx, uint32_t argc, jsval *vp) do { if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, 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"); @@ -5252,7 +5252,7 @@ bool js_cocos2dx_Scene_setPhysics3DDebugCamera(JSContext *cx, uint32_t argc, jsv { if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5330,7 +5330,7 @@ bool js_cocos2dx_Scene_setNavMeshDebugCamera(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2(arg0, cx, false, "Invalid Native Object"); @@ -5358,7 +5358,7 @@ bool js_cocos2dx_Scene_setNavMesh(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMesh*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2(arg0, cx, false, "Invalid Native Object"); @@ -5564,7 +5564,9 @@ 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); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); @@ -5745,7 +5747,9 @@ 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); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); diff --git a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp index efdcb743e5..bf8d014297 100644 --- a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp +++ b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp @@ -131,7 +131,7 @@ bool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, j cocos2d::Ref* arg1; do { js_proxy_t *proxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); } while (0); @@ -173,7 +173,7 @@ bool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, j cocos2d::Ref* arg1; do { js_proxy_t *proxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); } while (0); @@ -212,7 +212,7 @@ bool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint3 cocos2d::Ref* arg1; do { js_proxy_t *proxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) @@ -255,7 +255,7 @@ bool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint3 cocos2d::Ref* arg1; do { js_proxy_t *proxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp index 841409e802..0923abf765 100644 --- a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -262,7 +262,7 @@ static bool js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx(JSContext *c do { if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -863,7 +863,7 @@ bool js_set_AnimationData_movementDataDic(JSContext *cx, JS::HandleObject obj, J do { if (!value.isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = value.toObjectOrNull(); + JS::RootedObject tmpObj(cx, value.toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); movementData = (cocostudio::MovementData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2(movementData, cx, false, "js_set_AnimationData_movementDataDic : Invalid Native Object."); @@ -1071,7 +1071,7 @@ bool js_set_MovementData_tweenEasing(JSContext *cx, JS::HandleObject obj, JS::Ha bool js_get_ContourData_vertexList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::ContourData* cobj = (cocostudio::ContourData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1104,7 +1104,7 @@ bool js_get_ContourData_vertexList(JSContext *cx, JS::HandleObject obj, JS::Hand } bool js_set_ContourData_vertexList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::ContourData* cobj = (cocostudio::ContourData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1142,7 +1142,7 @@ bool js_set_ContourData_vertexList(JSContext *cx, JS::HandleObject obj, JS::Hand bool js_get_TextureData_contourDataList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1176,7 +1176,7 @@ bool js_get_TextureData_contourDataList(JSContext *cx, JS::HandleObject obj, JS: } bool js_set_TextureData_contourDataList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1198,7 +1198,7 @@ bool js_set_TextureData_contourDataList(JSContext *cx, JS::HandleObject obj, JS: do { if (!value.isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = value.toObjectOrNull(); + JS::RootedObject tmpObj(cx, value.toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); contourData = (cocostudio::ContourData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2(contourData, cx, false, "Invalid Native Object"); @@ -1218,7 +1218,7 @@ bool js_set_TextureData_contourDataList(JSContext *cx, JS::HandleObject obj, JS: bool js_get_TextureData_width(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); @@ -1243,7 +1243,7 @@ bool js_get_TextureData_width(JSContext *cx, JS::HandleObject obj, JS::HandleId } bool js_set_TextureData_width(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1256,7 +1256,7 @@ bool js_set_TextureData_width(JSContext *cx, JS::HandleObject obj, JS::HandleId bool js_get_TextureData_height(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1275,7 +1275,7 @@ bool js_get_TextureData_height(JSContext *cx, JS::HandleObject obj, JS::HandleId } bool js_set_TextureData_height(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1288,7 +1288,7 @@ bool js_set_TextureData_height(JSContext *cx, JS::HandleObject obj, JS::HandleId bool js_get_TextureData_pivotX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1307,7 +1307,7 @@ bool js_get_TextureData_pivotX(JSContext *cx, JS::HandleObject obj, JS::HandleId } bool js_set_TextureData_pivotX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1320,7 +1320,7 @@ bool js_set_TextureData_pivotX(JSContext *cx, JS::HandleObject obj, JS::HandleId bool js_get_TextureData_pivotY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1339,7 +1339,7 @@ bool js_get_TextureData_pivotY(JSContext *cx, JS::HandleObject obj, JS::HandleId } bool js_set_TextureData_pivotY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1352,7 +1352,7 @@ bool js_set_TextureData_pivotY(JSContext *cx, JS::HandleObject obj, JS::HandleId bool js_get_TextureData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { @@ -1371,7 +1371,7 @@ bool js_get_TextureData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId i } bool js_set_TextureData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { - JSObject* jsobj = obj.get(); + JS::RootedObject jsobj(cx, obj); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); if (cobj) { diff --git a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp index b3411b3752..1f6d03429d 100644 --- a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp @@ -267,7 +267,7 @@ public: cocos2d::extension::TableViewCell* arg0; do { js_proxy_t *proxy; - JSObject *tmpObj = ret.toObjectOrNull(); + JS::RootedObject tmpObj(cx, ret.toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::TableViewCell*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, NULL, "Invalid Native Object"); @@ -444,7 +444,7 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval * do { js_proxy_t *proxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -497,7 +497,7 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp cocos2d::Node* arg2; do { - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -705,7 +705,7 @@ static bool js_cocos2dx_ext_AssetsManager_updateAssets(JSContext *cx, uint32_t a { jsval *argv = JS_ARGV(cx, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManager_updateAssets : Invalid Native Object"); @@ -713,7 +713,7 @@ static bool js_cocos2dx_ext_AssetsManager_updateAssets(JSContext *cx, uint32_t a std::unordered_map dict; do { if (!argv[0].isObject()) { ok = false; break; } - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + JS::RootedObject tmpObj(cx, JSVAL_TO_OBJECT(argv[0])); if (!tmpObj) { CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); @@ -786,7 +786,7 @@ static bool js_cocos2dx_ext_AssetsManager_updateAssets(JSContext *cx, uint32_t a bool js_cocos2dx_ext_AssetsManager_getFailedAssets(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManager_getFailedAssets : Invalid Native Object"); @@ -800,7 +800,7 @@ bool js_cocos2dx_ext_AssetsManager_getFailedAssets(JSContext *cx, uint32_t argc, std::string key = it->first; const Downloader::DownloadUnit& unit = it->second; - JSObject *elem = JS_NewObject(cx, NULL, NULL, NULL); + JS::RootedObject elem(cx, JS_NewObject(cx, NULL, NULL, NULL)); if (!elem) { JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getFailedAssets : can not create js object"); @@ -942,7 +942,7 @@ void __JSDownloaderDelegator::onSuccess(Texture2D *tex) if (!p) { JS::RootedObject texProto(_cx, jsb_cocos2d_Texture2D_prototype); - JSObject *obj = JS_NewObject(_cx, jsb_cocos2d_Texture2D_class, texProto, global); + JS::RootedObject obj(_cx, JS_NewObject(_cx, jsb_cocos2d_Texture2D_class, texProto, global)); // link the native object with the javascript object p = jsb_new_proxy(tex, obj); JS::AddNamedObjectRoot(_cx, &p->obj, "cocos2d::Texture2D"); diff --git a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp index 3b6251b5c1..605bc616fd 100644 --- a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp +++ b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp @@ -87,7 +87,7 @@ bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) JS::RootedObject proto(cx, typeClass->proto.ref()); JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 738ab0a337..83c9af710e 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -161,7 +161,7 @@ bool jsval_to_ccvector(JSContext* cx, JS::HandleValue v, cocos2d::Vector* ret CCASSERT(value.isObject(), "the element in Vector isn't a native object."); js_proxy_t *proxy; - JSObject *tmp = value.toObjectOrNull(); + JS::RootedObject tmp(cx, value.toObjectOrNull()); proxy = jsb_get_js_proxy(tmp); T cobj = (T)(proxy ? proxy->ptr : nullptr); if (cobj) @@ -234,7 +234,7 @@ bool jsval_to_ccmap_string_key(JSContext *cx, JS::HandleValue v, cocos2d::Mapptr : nullptr); diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp index b71eb88b94..e072836378 100644 --- a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp @@ -343,7 +343,7 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) JS::RootedObject proto(cx, MinXmlHttpRequest::js_proto); JS::RootedObject parentProto(cx, MinXmlHttpRequest::js_parent); - JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, &MinXmlHttpRequest::js_class, proto, parentProto)); if (obj) { JS_SetPrivate(obj, req); @@ -351,7 +351,7 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) } args.rval().set(out); - p =jsb_new_proxy(req, obj); + p = jsb_new_proxy(req, obj); JS::AddNamedObjectRoot(cx, &p->obj, "XMLHttpRequest"); return true; diff --git a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp index 0714054adf..886254a0a0 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp @@ -170,7 +170,7 @@ bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp) { //previous connection not found, create a new one JS::RootedObject proto(cx, js_cocos2dx_socketio_prototype); - JSObject *obj = JS_NewObject(cx, js_cocos2dx_socketio_class, proto, JS::NullPtr()); + JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_socketio_class, proto, JS::NullPtr())); p = jsb_new_proxy(ret, obj); JS::RootedObject jsdelegate(cx, p->obj); siodelegate->setJSDelegate(jsdelegate); @@ -297,7 +297,7 @@ static bool _js_set_SIOClient_tag(JSContext* cx, uint32_t argc, jsval* vp) { CCLOG("JSB SocketIO.setTag method called"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsobj = args.thisv().toObjectOrNull(); + JS::RootedObject jsobj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); @@ -320,7 +320,7 @@ static bool _js_get_SIOClient_tag(JSContext* cx, uint32_t argc, jsval* vp) { CCLOG("JSB SocketIO.getTag method called"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsobj = args.thisv().toObjectOrNull(); + JS::RootedObject jsobj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); diff --git a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp index bc4229416e..fcaffca5ed 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp @@ -139,7 +139,8 @@ public: jsval args = OBJECT_TO_JSVAL(jsobj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "onclose", 1, &args); - js_proxy_t* jsproxy = jsb_get_js_proxy(p->obj); + JS::RootedObject wsobj(cx, p->obj); + js_proxy_t* jsproxy = jsb_get_js_proxy(wsobj); JS::RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(p, jsproxy); CC_SAFE_DELETE(ws); @@ -335,7 +336,7 @@ bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, j static bool js_cocos2dx_extension_WebSocket_get_readyState(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject* jsobj = args.thisv().toObjectOrNull(); + JS::RootedObject jsobj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); diff --git a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp index 4a96368d95..a0335e5522 100644 --- a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp +++ b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp @@ -46,7 +46,8 @@ bool jsval_to_physics3DRigidBodyDes(JSContext* cx, JS::HandleValue v, Physics3DR } if(JS_GetProperty(cx, jsobj, "shape", &tmp)) { - js_proxy_t* proxy = jsb_get_js_proxy(tmp.toObjectOrNull()); + JS::RootedObject tmpObj(cx, tmp.toObjectOrNull()); + js_proxy_t* proxy = jsb_get_js_proxy(tmpObj); des->shape = proxy ? (cocos2d::Physics3DShape*)proxy->ptr : nullptr; } if(JS_GetProperty(cx, jsobj, "localInertia", &tmp)) @@ -405,7 +406,8 @@ bool jsval_to_Physics3DWorld_HitResult(JSContext *cx, JS::HandleValue v, cocos2d JSB_PRECONDITION2(ok, cx, false, "jsval_to_Physics3DWorld_HitResult : Error processing arguments"); - js_proxy_t *proxy = jsb_get_js_proxy(jshitObject.toObjectOrNull()); + tmp.set(jshitObject.toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(tmp); ret->hitObj = (cocos2d::Physics3DObject *)(proxy ? proxy->ptr : nullptr); return true; diff --git a/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm index daf362021b..700865d94f 100644 --- a/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm +++ b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm @@ -239,7 +239,7 @@ JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge) JS::RootedObject proto(cx, JavaScriptObjCBridge::js_proto); JS::RootedObject parentProto(cx, JavaScriptObjCBridge::js_parent); - JSObject *obj = JS_NewObject(cx, &JavaScriptObjCBridge::js_class, proto, parentProto); + JS::RootedObject obj(cx, JS_NewObject(cx, &JavaScriptObjCBridge::js_class, proto, parentProto)); if (obj) { JS_SetPrivate(obj, jsj); @@ -248,7 +248,7 @@ JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().set(out); - p =jsb_new_proxy(jsj, obj); + p = jsb_new_proxy(jsj, obj); JS::AddNamedObjectRoot(cx, &p->obj, "JavaScriptObjCBridge"); return true; From 955ddaafb77fc9f5f107c657905fabe5218b3f0c Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 10:20:04 +0800 Subject: [PATCH 155/192] Use rooted object for js_proxy new and get (missed) --- tests/js-tests/project/Classes/js_Effect3D_bindings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp index d235238172..eb242f1ad1 100644 --- a/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp +++ b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp @@ -557,7 +557,7 @@ bool js_cocos2dx_EffectSprite3D_setEffect3D(JSContext *cx, uint32_t argc, jsval do { if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (Effect3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -585,7 +585,7 @@ bool js_cocos2dx_EffectSprite3D_addEffect(JSContext *cx, uint32_t argc, jsval *v do { if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (Effect3DOutline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); From 1ee7b11e31755d6c81456d1aea21e69ade99b1c9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 10:20:51 +0800 Subject: [PATCH 156/192] Refactor jsb_new_proxy and jsb_get_js_proxy with RootedObject --- .../js-bindings/manual/ScriptingCore.cpp | 27 ++++++++++++++++--- .../js-bindings/manual/ScriptingCore.h | 4 +-- .../manual/js_manual_conversions.h | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index cc76082102..3f836a3bfd 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -1915,10 +1915,28 @@ bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret) return true; } -js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj) +js_proxy_t* jsb_new_proxy(void* nativeObj, JS::HandleObject jsObj) { js_proxy_t* p = nullptr; - JS_NEW_PROXY(p, nativeObj, jsObj); + JSObject* ptr = jsObj.get(); + do { + p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); + assert(p); + js_proxy_t* nativeObjJsObjtmp = NULL; + HASH_FIND_PTR(_native_js_global_ht, &nativeObj, nativeObjJsObjtmp); + assert(!nativeObjJsObjtmp); + p->ptr = nativeObj; + p->obj = ptr; + HASH_ADD_PTR(_native_js_global_ht, ptr, p); + p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); + assert(p); + nativeObjJsObjtmp = NULL; + HASH_FIND_PTR(_js_native_global_ht, &ptr, nativeObjJsObjtmp); + assert(!nativeObjJsObjtmp); + p->ptr = nativeObj; + p->obj = ptr; + HASH_ADD_PTR(_js_native_global_ht, obj, p); + } while(0); return p; } @@ -1929,10 +1947,11 @@ js_proxy_t* jsb_get_native_proxy(void* nativeObj) return p; } -js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) +js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj) { js_proxy_t* p = nullptr; - JS_GET_NATIVE_PROXY(p, jsObj); + JSObject* ptr = jsObj.get(); + JS_GET_NATIVE_PROXY(p, ptr); return p; } diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index f31f425a49..97d71c8c83 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -532,9 +532,9 @@ js_type_class_t *jsb_register_class(JSContext *cx, JSClass *jsClass, JS::HandleO return p; } -js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj); +js_proxy_t* jsb_new_proxy(void* nativeObj, JS::HandleObject jsObj); js_proxy_t* jsb_get_native_proxy(void* nativeObj); -js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); +js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj); void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy); template diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 83c9af710e..d6324c0bcc 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -113,7 +113,7 @@ bool jsval_to_obb(JSContext *cx, JS::HandleValue vp, cocos2d::OBB* ret); bool jsval_to_ray(JSContext *cx, JS::HandleValue vp, cocos2d::Ray* ret); // forward declaration -js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); +js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj); template bool jsvals_variadic_to_ccvector( JSContext *cx, /*jsval *vp, int argc,*/const JS::CallArgs& args, cocos2d::Vector* ret) From f5d2ea11b754c6d4f7d2cc15b0c94d09c0003da4 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 27 Nov 2015 10:58:48 +0800 Subject: [PATCH 157/192] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 30f44ad00a..0108fbd1df 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ cocos2d-x-3.10 December ? 2015 [NEW] Core: Added Application::getVersion() to get the app version. +[NEW] UI: Add PageView indicator. [REFINE] UI: RichText support new line element. [REFINE] UI: Set focus to Widget when touched. From 4bedfa4f144d4de351a56ed1adc8765849275099 Mon Sep 17 00:00:00 2001 From: Xpol Wan Date: Wed, 18 Nov 2015 17:47:07 +0800 Subject: [PATCH 158/192] Fixes boring deprecated warning. I know I duplicated the code but there is no cpp for me to move body into. --- cocos/network/HttpRequest.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index eafe52538a..bcccd0136d 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -242,7 +242,15 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector) { - setResponseCallback(pTarget, (SEL_HttpResponse) pSelector); + // This function have duplicated body with setResponseCallback(Ref* , SEL_HttpResponse ) + // You must repeat youself in that function when modified. + _pTarget = pTarget; + _pSelector = (SEL_HttpResponse)pSelector; + + if (_pTarget) + { + _pTarget->retain(); + } } /** @@ -254,6 +262,8 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) { + // This function have duplicated body with setResponseCallback(Ref* , SEL_CallFuncND ) + // You must repeat youself in that function. _pTarget = pTarget; _pSelector = pSelector; From 520aa9d351ef8953b42bd0e69180b0887b112091 Mon Sep 17 00:00:00 2001 From: Xpol Wan Date: Wed, 18 Nov 2015 17:52:24 +0800 Subject: [PATCH 159/192] Remove duplicated code by introduce a private doSetResponseCallback. --- cocos/network/HttpRequest.h | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index bcccd0136d..ea3de64a2d 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -242,15 +242,7 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector) { - // This function have duplicated body with setResponseCallback(Ref* , SEL_HttpResponse ) - // You must repeat youself in that function when modified. - _pTarget = pTarget; - _pSelector = (SEL_HttpResponse)pSelector; - - if (_pTarget) - { - _pTarget->retain(); - } + doSetResponseCallback(pTarget, (SEL_HttpResponse)pSelector); } /** @@ -262,15 +254,7 @@ public: */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) { - // This function have duplicated body with setResponseCallback(Ref* , SEL_CallFuncND ) - // You must repeat youself in that function. - _pTarget = pTarget; - _pSelector = pSelector; - - if (_pTarget) - { - _pTarget->retain(); - } + doSetResponseCallback(pTarget, pSelector); } /** * Set response callback function of HttpRequest object. @@ -352,6 +336,18 @@ public: return _headers; } +private: + inline void doSetResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector) + { + _pTarget = pTarget; + _pSelector = pSelector; + + if (_pTarget) + { + _pTarget->retain(); + } + } + protected: // properties Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums From 3f9b40c093050074772af1b21c338ed4d2f0c943 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Fri, 20 Nov 2015 15:53:36 +0900 Subject: [PATCH 160/192] Fix #14440 --- cocos/ui/UILayoutComponent.cpp | 4 ++-- cocos/ui/UIPageView.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/ui/UILayoutComponent.cpp b/cocos/ui/UILayoutComponent.cpp index 56fbee58a7..b36f568c50 100644 --- a/cocos/ui/UILayoutComponent.cpp +++ b/cocos/ui/UILayoutComponent.cpp @@ -672,8 +672,8 @@ namespace ui { PageView* page = static_cast(_owner); page->forceDoLayout(); - Vector _layoutVector = page->getPages(); - for(auto& item : _layoutVector) + Vector _widgetVector = page->getItems(); + for(auto& item : _widgetVector) { ui::Helper::doLayout(item); } diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 42198f6f0c..17904d2c38 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -298,7 +298,7 @@ ssize_t PageView::getCurPageIndex() const Vector& PageView::getPages() { - CCASSERT(false, "This method is obsolete!"); + CCLOG("This method is obsolete!"); // Temporary code to keep backward compatibility. static Vector pages; From 40f6f76030f6553688a706c40a081894ece3e806 Mon Sep 17 00:00:00 2001 From: cesarpachon Date: Tue, 24 Nov 2015 20:54:12 -0500 Subject: [PATCH 161/192] AudioEngine:Linux: implementation using FMOD, refactor to SimpleAudioEngine now as wrapper of AUdioEngine, upgrade FMOD binaries --- CMakeLists.txt | 2 +- cmake/Modules/CocosUsePrebuiltLibs.cmake | 6 +- cmake/Modules/FindFMOD.cmake | 51 ++ cmake/Modules/FindFMODEX.cmake | 51 -- cocos/CMakeLists.txt | 2 +- cocos/audio/AudioEngine.cpp | 6 +- cocos/audio/CMakeLists.txt | 7 +- cocos/audio/include/AudioEngine.h | 2 - cocos/audio/linux/AudioEngine-linux.cpp | 302 +++++++++++ cocos/audio/linux/AudioEngine-linux.h | 106 ++++ cocos/audio/linux/AudioPlayer.h | 158 ------ cocos/audio/linux/FmodAudioPlayer.cpp | 477 ------------------ cocos/audio/linux/FmodAudioPlayer.h | 190 ------- cocos/audio/linux/SimpleAudioEngine.cpp | 211 ++++++++ cocos/audio/linux/SimpleAudioEngineFMOD.cpp | 168 ------ external/config.json | 2 +- .../NewAudioEngineTest/NewAudioEngineTest.cpp | 3 - .../NewAudioEngineTest/NewAudioEngineTest.h | 2 - tests/cpp-tests/Classes/controller.cpp | 2 - tests/cpp-tests/Classes/tests.h | 2 - 20 files changed, 681 insertions(+), 1069 deletions(-) create mode 100644 cmake/Modules/FindFMOD.cmake delete mode 100644 cmake/Modules/FindFMODEX.cmake create mode 100644 cocos/audio/linux/AudioEngine-linux.cpp create mode 100644 cocos/audio/linux/AudioEngine-linux.h delete mode 100644 cocos/audio/linux/AudioPlayer.h delete mode 100644 cocos/audio/linux/FmodAudioPlayer.cpp delete mode 100644 cocos/audio/linux/FmodAudioPlayer.h create mode 100644 cocos/audio/linux/SimpleAudioEngine.cpp delete mode 100644 cocos/audio/linux/SimpleAudioEngineFMOD.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 22f431eb5c..7d4e896e89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,7 @@ if(LINUX OR MACOSX OR WINDOWS) find_package(Threads REQUIRED) set(THREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) - cocos_find_package(FMODEX FMODEX REQUIRED) + cocos_find_package(FMOD FMOD REQUIRED) cocos_find_package(Fontconfig FONTCONFIG REQUIRED) cocos_find_package(GTK3 GTK3 REQUIRED) endif() diff --git a/cmake/Modules/CocosUsePrebuiltLibs.cmake b/cmake/Modules/CocosUsePrebuiltLibs.cmake index f4c1d426df..788493d9d9 100644 --- a/cmake/Modules/CocosUsePrebuiltLibs.cmake +++ b/cmake/Modules/CocosUsePrebuiltLibs.cmake @@ -60,9 +60,9 @@ set(_OpenalSoft_libs OpenAL32) set(_zlib_inc zlib.h) set(_zlib_libs z libzlib libz) -set(_fmod_prefix FMODEX) -set(_fmod_inc fmod.h) -set(_fmod_libs fmodex fmodex64 fmodexL fmodexL64) +set(_fmod_prefix FMOD) +set(_fmod_inc fmod.hpp) +set(_fmod_libs fmod fmod64 fmod fmod64) set(all_prebuilt_libs chipmunk diff --git a/cmake/Modules/FindFMOD.cmake b/cmake/Modules/FindFMOD.cmake new file mode 100644 index 0000000000..f14a9a4d5c --- /dev/null +++ b/cmake/Modules/FindFMOD.cmake @@ -0,0 +1,51 @@ +#.rst: +# FindFMOD +# ------------ +# +# Locate FMOD Ex library +# +# This module defines +# +# :: +# +# FMOD_LIBRARIES, the library to link against +# FMOD_FOUND, if false, do not try to link to fmodex +# FMOD_INCLUDE_DIRS, where to find headers. +# + +find_path(FMOD_INCLUDE_DIR fmod.hpp + HINTS ENV FMOD_DIR + PATH_SUFFIXES include/fmod include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +find_library(FMOD_LIBRARY NAMES fmod fmod64 + HINTS ENV FMOD_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +set(FMOD_INCLUDE_DIRS "${FMOD_INCLUDE_DIR}") +set(FMOD_LIBRARIES "${FMOD_LIBRARY}") + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(FMOD DEFAULT_MSG FMOD_LIBRARIES FMOD_INCLUDE_DIRS) + +mark_as_advanced(FMOD_INCLUDE_DIR FMOD_LIBRARY FMOD_INCLUDE_DIRS FMOD_LIBRARIES) + diff --git a/cmake/Modules/FindFMODEX.cmake b/cmake/Modules/FindFMODEX.cmake deleted file mode 100644 index 54e4d4a800..0000000000 --- a/cmake/Modules/FindFMODEX.cmake +++ /dev/null @@ -1,51 +0,0 @@ -#.rst: -# FindFMODEX -# ------------ -# -# Locate FMOD Ex library -# -# This module defines -# -# :: -# -# FMODEX_LIBRARIES, the library to link against -# FMODEX_FOUND, if false, do not try to link to fmodex -# FMODEX_INCLUDE_DIRS, where to find headers. -# - -find_path(FMODEX_INCLUDE_DIR fmod.h - HINTS ENV FMODEX_DIR - PATH_SUFFIXES include/fmodex include - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) - -find_library(FMODEX_LIBRARY NAMES fmodex fmodex64 - HINTS ENV FMODEX_DIR - PATH_SUFFIXES lib - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) - -set(FMODEX_INCLUDE_DIRS "${FMODEX_INCLUDE_DIR}") -set(FMODEX_LIBRARIES "${FMODEX_LIBRARY}") - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(FMODEX DEFAULT_MSG FMODEX_LIBRARIES FMODEX_INCLUDE_DIRS) - -mark_as_advanced(FMODEX_INCLUDE_DIR FMODEX_LIBRARY FMODEX_INCLUDE_DIRS FMODEX_LIBRARIES) - diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index 6cff5b9a26..a6e8a0a7cf 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -96,7 +96,7 @@ if(WINDOWS) endforeach() list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm) elseif(LINUX) - foreach(_pkg OPENGL GLEW GLFW3 FMODEX FONTCONFIG THREADS GTK3) + foreach(_pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3) cocos_use_pkg(cocos2d ${_pkg}) endforeach() elseif(MACOSX OR APPLE) diff --git a/cocos/audio/AudioEngine.cpp b/cocos/audio/AudioEngine.cpp index 4162505c5f..c224934198 100644 --- a/cocos/audio/AudioEngine.cpp +++ b/cocos/audio/AudioEngine.cpp @@ -24,8 +24,6 @@ #include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "audio/include/AudioEngine.h" #include #include @@ -40,6 +38,8 @@ #include "win32/AudioEngine-win32.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "winrt/AudioEngine-winrt.h" +#elif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX +#include "linux/AudioEngine-linux.h" #endif #define TIME_DELAY_PRECISION 0.0001 @@ -538,5 +538,3 @@ void AudioEngine::addTask(const std::function& task) s_threadPool->addTask(task); } } - -#endif diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index 27437db0d4..80cdbb7676 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -15,10 +15,9 @@ if(WINDOWS) elseif(LINUX) set(COCOS_AUDIO_PLATFORM_SRC - audio/linux/SimpleAudioEngineFMOD.cpp - audio/linux/FmodAudioPlayer.cpp - audio/linux/FmodAudioPlayer.h - audio/linux/AudioPlayer.h + audio/linux/SimpleAudioEngine.cpp + audio/linux/AudioEngine-linux.h + audio/linux/AudioEngine-linux.cpp ) elseif(MACOSX) diff --git a/cocos/audio/include/AudioEngine.h b/cocos/audio/include/AudioEngine.h index 2af34d083b..db2e6d148f 100644 --- a/cocos/audio/include/AudioEngine.h +++ b/cocos/audio/include/AudioEngine.h @@ -23,7 +23,6 @@ ****************************************************************************/ #include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #ifndef __AUDIO_ENGINE_H_ #define __AUDIO_ENGINE_H_ @@ -360,4 +359,3 @@ NS_CC_END /// @} #endif // __AUDIO_ENGINE_H_ -#endif diff --git a/cocos/audio/linux/AudioEngine-linux.cpp b/cocos/audio/linux/AudioEngine-linux.cpp new file mode 100644 index 0000000000..9fc54a58b4 --- /dev/null +++ b/cocos/audio/linux/AudioEngine-linux.cpp @@ -0,0 +1,302 @@ +/** + * @author cesarpachon + */ +#include +#include "AudioEngine-linux.h" +#include "cocos2d.h" +using namespace cocos2d; +using namespace cocos2d::experimental; + +AudioEngineImpl * g_AudioEngineImpl = nullptr; + +void ERRCHECKWITHEXIT(FMOD_RESULT result) { + if (result != FMOD_OK) { + printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result)); + } +} + +bool ERRCHECK(FMOD_RESULT result) { + if (result != FMOD_OK) { + printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result)); + return true; + } + return false; +} + +FMOD_RESULT F_CALLBACK channelCallback(FMOD_CHANNELCONTROL *channelcontrol, + FMOD_CHANNELCONTROL_TYPE controltype, + FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype, + void *commandData1, void *commandData2) +{ + + if(controltype == FMOD_CHANNELCONTROL_CHANNEL && callbacktype == FMOD_CHANNELCONTROL_CALLBACK_END){ + g_AudioEngineImpl->onSoundFinished((FMOD::Channel *)channelcontrol); + }else{ + } + return FMOD_OK; +} + + +AudioEngineImpl::AudioEngineImpl(){ +}; + +AudioEngineImpl::~AudioEngineImpl(){ + FMOD_RESULT result; + result = pSystem->close(); + ERRCHECKWITHEXIT(result); + result = pSystem->release(); + ERRCHECKWITHEXIT(result); +}; + + +bool AudioEngineImpl::init(){ + FMOD_RESULT result; + /* + Create a System object and initialize. + */ + result = FMOD::System_Create(&pSystem); + ERRCHECKWITHEXIT(result); + + result = pSystem->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO); + ERRCHECKWITHEXIT(result); + + result = pSystem->init(32, FMOD_INIT_NORMAL, 0); + ERRCHECKWITHEXIT(result); + + mapChannelInfo.clear(); + mapSound.clear(); + + auto scheduler = cocos2d::Director::getInstance()->getScheduler(); + scheduler->schedule(schedule_selector(AudioEngineImpl::update), this, 0.05f, false); + + g_AudioEngineImpl = this; + + return true; +}; + +int AudioEngineImpl::play2d(const std::string &fileFullPath ,bool loop ,float volume){ + int id = preload(fileFullPath, nullptr); + if(id >= 0){ + mapChannelInfo[id].loop=loop; + mapChannelInfo[id].channel->setPaused(true); + mapChannelInfo[id].volume = volume; + AudioEngine::_audioIDInfoMap[id].state = AudioEngine::AudioState::PAUSED; + resume(id); + } + return id; +}; + +void AudioEngineImpl::setVolume(int audioID,float volume){ + try{ + mapChannelInfo[audioID].channel->setVolume(volume); + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::setVolume: invalid audioID: %d\n", audioID); + } +}; + +void AudioEngineImpl::setLoop(int audioID, bool loop){ + try{ + mapChannelInfo[audioID].channel->setLoopCount(loop?-1:0); + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::setLoop: invalid audioID: %d\n", audioID); + } +}; + +bool AudioEngineImpl::pause(int audioID){ + try{ + mapChannelInfo[audioID].channel->setPaused(true); + AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PAUSED; + return true; + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::pause: invalid audioID: %d\n", audioID); + return false; + } +}; + +bool AudioEngineImpl::resume(int audioID){ +try{ + + if(!mapChannelInfo[audioID].channel){ + FMOD::Channel *channel = nullptr; + FMOD::ChannelGroup *channelgroup = nullptr; + //starts the sound in pause mode, use the channel to unpause + FMOD_RESULT result = pSystem->playSound(mapChannelInfo[audioID].sound, channelgroup, true, &channel); + if(ERRCHECK(result)){ + return false; + } + channel->setMode(mapChannelInfo[audioID].loop?FMOD_LOOP_NORMAL:FMOD_LOOP_OFF); + channel->setLoopCount(mapChannelInfo[audioID].loop?-1:0); + channel->setVolume(mapChannelInfo[audioID].volume); + channel->setUserData((void *)mapChannelInfo[audioID].id); + mapChannelInfo[audioID].channel = channel; + } + + mapChannelInfo[audioID].channel->setPaused(false); + AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PLAYING; + + return true; + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::resume: invalid audioID: %d\n", audioID); + return false; + } +}; + +bool AudioEngineImpl::stop(int audioID){ + try{ + mapChannelInfo[audioID].channel->stop(); + mapChannelInfo[audioID].channel = nullptr; + return true; + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::stop: invalid audioID: %d\n", audioID); + return false; + } +}; + +void AudioEngineImpl::stopAll(){ + for (auto it = mapChannelInfo.begin(); it != mapChannelInfo.end(); ++it) { + ChannelInfo & audioRef = it->second; + audioRef.channel->stop(); + audioRef.channel = nullptr; + } +}; + +float AudioEngineImpl::getDuration(int audioID){ + try{ + FMOD::Sound * sound = mapChannelInfo[audioID].sound; + unsigned int length; + FMOD_RESULT result = sound->getLength(&length, FMOD_TIMEUNIT_MS); + ERRCHECK(result); + float duration = (float)length / 1000.0f; + return duration; + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::getDuration: invalid audioID: %d\n", audioID); + return AudioEngine::TIME_UNKNOWN; + } +}; + +float AudioEngineImpl::getCurrentTime(int audioID){ + try{ + unsigned int position; + FMOD_RESULT result = mapChannelInfo[audioID].channel->getPosition(&position, FMOD_TIMEUNIT_MS); + ERRCHECK(result); + float currenttime = position /1000.0f; + return currenttime; + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::getCurrentTime: invalid audioID: %d\n", audioID); + return AudioEngine::TIME_UNKNOWN; + } +}; + +bool AudioEngineImpl::setCurrentTime(int audioID, float time){ + try{ + unsigned int position = (unsigned int)(time * 1000.0f); + FMOD_RESULT result = mapChannelInfo[audioID].channel->setPosition(position, FMOD_TIMEUNIT_MS); + ERRCHECK(result); + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::setCurrentTime: invalid audioID: %d\n", audioID); + } +}; + +void AudioEngineImpl::setFinishCallback(int audioID, const std::function &callback){ + try{ + FMOD::Channel * channel = mapChannelInfo[audioID].channel; + mapChannelInfo[audioID].callback = callback; + FMOD_RESULT result = channel->setCallback(channelCallback); + ERRCHECK(result); + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::setFinishCallback: invalid audioID: %d\n", audioID); + } +}; + + +void AudioEngineImpl::onSoundFinished(FMOD::Channel * channel){ + size_t id; + try{ + void * data; + channel->getUserData(&data); + id = (size_t) data; + if(mapChannelInfo[id].callback){ + mapChannelInfo[id].callback(id, mapChannelInfo[id].path); + } + mapChannelInfo[id].channel = nullptr; + }catch(const std::out_of_range& oor){ + printf("AudioEngineImpl::onSoundFinished: invalid audioID: %d\n", id); + } +}; + + +void AudioEngineImpl::uncache(const std::string& path){ + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path); + std::map::const_iterator it = mapSound.find(fullPath); + if(it!=mapSound.end()){ + FMOD::Sound * sound = it->second; + if(sound){ + sound->release(); + } + mapSound.erase(it); + } +}; + + +void AudioEngineImpl::uncacheAll(){ +for (auto it = mapSound.cbegin(); it != mapSound.cend(); ++it) { + auto sound = it->second; + if(sound){ + sound->release(); + } + } + mapSound.clear(); +}; + + +int AudioEngineImpl::preload(const std::string& filePath, std::function callback){ + FMOD::Sound * sound = findSound(filePath); + if(!sound){ + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath); + FMOD_RESULT result = pSystem->createSound(fullPath.c_str(), FMOD_LOOP_OFF, 0, &sound); + if (ERRCHECK(result)){ + printf("sound effect in %s could not be preload\n", filePath.c_str()); + if(callback){ + callback(false); + } + return -1; + } + mapSound[fullPath] = sound; + } + + int id = mapChannelInfo.size() + 1; + auto& chanelInfo = mapChannelInfo[id]; + chanelInfo.sound = sound; + chanelInfo.id = (size_t) id; + chanelInfo.channel = nullptr; + chanelInfo.callback = nullptr; + chanelInfo.path = filePath; + //we are going to use UserData to store pointer to Channel when playing + chanelInfo.sound->setUserData((void *)id); + + if(callback){ + callback(true); + } + return id; +}; + + +void AudioEngineImpl::update(float dt){ + pSystem->update(); +}; + + +FMOD::Sound * AudioEngineImpl::findSound(const std::string &path){ + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path); + std::map::const_iterator it = mapSound.find(fullPath); + return (it!=mapSound.end())?(it->second):nullptr; +} + + +FMOD::Channel * AudioEngineImpl::getChannel(FMOD::Sound *sound){ + size_t id; + void * data; + sound->getUserData(&data); + id = (size_t) data; + return mapChannelInfo[id].channel; +}; diff --git a/cocos/audio/linux/AudioEngine-linux.h b/cocos/audio/linux/AudioEngine-linux.h new file mode 100644 index 0000000000..c0625ad1f1 --- /dev/null +++ b/cocos/audio/linux/AudioEngine-linux.h @@ -0,0 +1,106 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#include "platform/CCPlatformConfig.h" + +#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX + +#ifndef __AUDIO_ENGINE_LINUX_H_ +#define __AUDIO_ENGINE_LINUX_H_ + +#include +#include +#include +#include "fmod.hpp" +#include "fmod_errors.h" +#include "AudioEngine.h" + +#include "base/CCRef.h" + +NS_CC_BEGIN + namespace experimental{ +#define MAX_AUDIOINSTANCES 32 + +class CC_DLL AudioEngineImpl : public cocos2d::Ref +{ +public: + AudioEngineImpl(); + ~AudioEngineImpl(); + + bool init(); + int play2d(const std::string &fileFullPath ,bool loop ,float volume); + void setVolume(int audioID,float volume); + void setLoop(int audioID, bool loop); + bool pause(int audioID); + bool resume(int audioID); + bool stop(int audioID); + void stopAll(); + float getDuration(int audioID); + float getCurrentTime(int audioID); + bool setCurrentTime(int audioID, float time); + void setFinishCallback(int audioID, const std::function &callback); + + void uncache(const std::string& filePath); + void uncacheAll(); + + + int preload(const std::string& filePath, std::function callback); + + void update(float dt); + + /** + * used internally by ffmod callback + */ + void onSoundFinished(FMOD::Channel * channel); + +private: + + /** + * returns null if a sound with the given path is not found + */ + FMOD::Sound * findSound(const std::string &path); + + FMOD::Channel * getChannel(FMOD::Sound *); + + struct ChannelInfo{ + size_t id; + std::string path; + FMOD::Sound * sound; + FMOD::Channel * channel; + bool loop; + float volume; + std::function callback; + }; + + std::map mapChannelInfo; + + std::map mapSound; + + FMOD::System* pSystem; + +}; +} +NS_CC_END +#endif // __AUDIO_ENGINE_LINUX_H_ +#endif + diff --git a/cocos/audio/linux/AudioPlayer.h b/cocos/audio/linux/AudioPlayer.h deleted file mode 100644 index 28aafdce16..0000000000 --- a/cocos/audio/linux/AudioPlayer.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -Copyright (c) 2011 Laschweinski -Copyright (c) 2013-2014 Chukong Technologies Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef AUDIOPLAYER_H_ -#define AUDIOPLAYER_H_ - -namespace CocosDenshion { - -class AudioPlayer { -public: - virtual void close() = 0; - - /** - @brief Preload background music - @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo - */ - virtual void preloadBackgroundMusic(const char* pszFilePath) = 0; - - /** - @brief Play background music - @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo - @param bLoop Whether the background music loop or not - */ - virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false) = 0; - - /** - @brief Stop playing background music - @param bReleaseData If release the background music data or not.As default value is false - */ - virtual void stopBackgroundMusic(bool bReleaseData = false) = 0; - - /** - @brief Pause playing background music - */ - virtual void pauseBackgroundMusic() = 0; - - /** - @brief Resume playing background music - */ - virtual void resumeBackgroundMusic() = 0; - - /** - @brief Rewind playing background music - */ - virtual void rewindBackgroundMusic() = 0; - - virtual bool willPlayBackgroundMusic() = 0; - - /** - @brief Whether the background music is playing - @return If is playing return true,or return false - */ - virtual bool isBackgroundMusicPlaying() = 0; - - // properties - /** - @brief The volume of the background music max value is 1.0,the min value is 0.0 - */ - virtual float getBackgroundMusicVolume() = 0; - - /** - @brief set the volume of background music - @param volume must be in 0.0~1.0 - */ - virtual void setBackgroundMusicVolume(float volume) = 0; - - /** - @brief The volume of the effects max value is 1.0,the min value is 0.0 - */ - virtual float getEffectsVolume() = 0; - - /** - @brief set the volume of sound effecs - @param volume must be in 0.0~1.0 - */ - virtual void setEffectsVolume(float volume) = 0; - - // for sound effects - /** - @brief Play sound effect - @param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo - @bLoop Whether to loop the effect playing, default value is false - */ - virtual unsigned int playEffect(const char* pszFilePath, bool bLoop, - float pitch, float pan, float gain) = 0; - - /** - @brief Stop playing sound effect - @param nSoundId The return value of function playEffect - */ - virtual void stopEffect(unsigned int nSoundId) = 0; - - /** - @brief preload a compressed audio file - @details the compressed audio will be decode to wave, then write into an - internal buffer in SimpleaudioEngine - */ - virtual void preloadEffect(const char* pszFilePath) = 0; - - /** - @brief unload the preloaded effect from internal buffer - @param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo - */ - virtual void unloadEffect(const char* pszFilePath) = 0; - - /** - @brief pause an effect identified by sound id - @param[in] uSoundId sound id - */ - virtual void pauseEffect(unsigned int uSoundId) = 0; - - /** - @brief pause all playing effects - */ - virtual void pauseAllEffects() = 0; - - /** - @brief resume an effect identified by sound id - @param[in] uSoundId sound id - */ - virtual void resumeEffect(unsigned int uSoundId) = 0; - - /** - @brief resume a effect identified by sound id - */ - virtual void resumeAllEffects() = 0; - - /** - @brief stop all playing effects - */ - virtual void stopAllEffects() = 0; -}; -} - - -#endif /* AUDIOPLAYER_H_ */ diff --git a/cocos/audio/linux/FmodAudioPlayer.cpp b/cocos/audio/linux/FmodAudioPlayer.cpp deleted file mode 100644 index ffe27136a5..0000000000 --- a/cocos/audio/linux/FmodAudioPlayer.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/**************************************************************************** -Copyright (c) 2011 Laschweinski -Copyright (c) 2013-2014 Chukong Technologies Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "FmodAudioPlayer.h" -#include -#include "stdlib.h" -#include "assert.h" -#include "string.h" - -#define szMusicSuffix "|" - -namespace CocosDenshion { - -FmodAudioPlayer* FmodAudioPlayer::sharedPlayer() { - static FmodAudioPlayer s_SharedPlayer; - return &s_SharedPlayer; -} - -void ERRCHECKWITHEXIT(FMOD_RESULT result) { - if (result != FMOD_OK) { - printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result)); -// exit(-1); - } -} - -bool ERRCHECK(FMOD_RESULT result) { - if (result != FMOD_OK) { - printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result)); - return true; - } - return false; -} - -FmodAudioPlayer::FmodAudioPlayer() : - pMusic(0), pBGMChannel(0), iSoundChannelCount(0) { - init(); -} - -void FmodAudioPlayer::init() { - //init - FMOD_RESULT result; - FMOD::ChannelGroup *masterChannelGroup; - - /* - Create a System object and initialize. - */ - result = FMOD::System_Create(&pSystem); - ERRCHECKWITHEXIT(result); - - result = pSystem->setOutput(FMOD_OUTPUTTYPE_ALSA); - ERRCHECKWITHEXIT(result); - - result = pSystem->init(32, FMOD_INIT_NORMAL, 0); - ERRCHECKWITHEXIT(result); - - result = pSystem->createChannelGroup("Channel Group", &pChannelGroup); - ERRCHECKWITHEXIT(result); - - result = pSystem->getMasterChannelGroup(&masterChannelGroup); - ERRCHECKWITHEXIT(result); - - result = masterChannelGroup->addGroup(pChannelGroup); - ERRCHECKWITHEXIT(result); - - mapEffectSound.clear(); - -} - -void FmodAudioPlayer::close() { - FMOD_RESULT result; - //BGM - if (pBGMChannel != NULL) { - result = pBGMChannel->stop(); - ERRCHECKWITHEXIT(result); - pBGMChannel = 0; - } - - if (pMusic != NULL) { - result = pMusic->release(); - ERRCHECKWITHEXIT(result); - pMusic = 0; - } - - result = pChannelGroup->release(); - ERRCHECKWITHEXIT(result); - sMusicPath.clear(); - - result = pSystem->close(); - ERRCHECKWITHEXIT(result); - result = pSystem->release(); - ERRCHECKWITHEXIT(result); - - init(); -} - -FmodAudioPlayer::~FmodAudioPlayer() { - FMOD_RESULT result; - //BGM - if (pBGMChannel != NULL) { - result = pBGMChannel->stop(); - ERRCHECKWITHEXIT(result); - } - - if (pMusic != NULL) { - result = pMusic->release(); - ERRCHECKWITHEXIT(result); - } - - result = pChannelGroup->release(); - ERRCHECKWITHEXIT(result); - - result = pSystem->close(); - ERRCHECKWITHEXIT(result); - result = pSystem->release(); - ERRCHECKWITHEXIT(result); -} - -// BGM -void FmodAudioPlayer::preloadBackgroundMusic(const char* pszFilePath) { - FMOD_RESULT result; - pSystem->update(); - string sNewMusicPath = string(pszFilePath) + szMusicSuffix; - if (pMusic && sNewMusicPath != sMusicPath) { - //release old - result = pMusic->release(); - ERRCHECKWITHEXIT(result); - - sMusicPath = sNewMusicPath; - - } - - result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pMusic); - ERRCHECK(result); -} - -void FmodAudioPlayer::playBackgroundMusic(const char* pszFilePath, bool bLoop) { - pSystem->update(); - if (pMusic == NULL) { - //did not load it - //load the new music - FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, - 0, &pMusic); - if (!ERRCHECK(result)) { - sMusicPath = string(pszFilePath) + szMusicSuffix; - } - - } else { - string sNewMusicPath = string(pszFilePath) + szMusicSuffix; - if (pBGMChannel) { - pBGMChannel->stop(); - pBGMChannel = 0; - } - - if (sNewMusicPath != sMusicPath) { - - pMusic->release(); - //load the new music - FMOD_RESULT result = pSystem->createSound(pszFilePath, - FMOD_LOOP_NORMAL, 0, &pMusic); - - if (!ERRCHECK(result)) { - sMusicPath = sNewMusicPath; - } - } - - } - - FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pMusic, true, - &pBGMChannel); - if (!ERRCHECK(result)) { - pBGMChannel->setLoopCount((bLoop) ? -1 : 0); - result = pBGMChannel->setPaused(false); - } -} - -void FmodAudioPlayer::stopBackgroundMusic(bool bReleaseData) { - FMOD_RESULT result; - pSystem->update(); - - if (pBGMChannel == NULL || pMusic == NULL) { - return; - } - if (bReleaseData) { - result = pBGMChannel->stop(); - ERRCHECKWITHEXIT(result); - result = pMusic->release(); - ERRCHECKWITHEXIT(result); - pBGMChannel = 0; - pMusic = 0; - } else { - result = pBGMChannel->stop(); - ERRCHECKWITHEXIT(result); - pBGMChannel = 0; - } - sMusicPath.clear(); - -} - -void FmodAudioPlayer::pauseBackgroundMusic() { - if (pBGMChannel == NULL) { - return; - } - pSystem->update(); - FMOD_RESULT result = pBGMChannel->setPaused(true); - ERRCHECKWITHEXIT(result); - -} - -void FmodAudioPlayer::resumeBackgroundMusic() { - if (pBGMChannel == NULL) { - return; - } - pSystem->update(); - FMOD_RESULT result = pBGMChannel->setPaused(false); - ERRCHECKWITHEXIT(result); -} - -void FmodAudioPlayer::rewindBackgroundMusic() { - if (pBGMChannel == NULL) { - return; - } - pSystem->update(); - FMOD_RESULT result = pBGMChannel->setPosition(0, FMOD_TIMEUNIT_MS); - ERRCHECKWITHEXIT(result); -} - -bool FmodAudioPlayer::willPlayBackgroundMusic() { - pSystem->update(); - return false; //do it according to win -} - -bool FmodAudioPlayer::isBackgroundMusicPlaying() { - bool bPlaying; - if (pBGMChannel == NULL) { - return false; - } - pSystem->update(); - FMOD_RESULT result = pBGMChannel->isPlaying(&bPlaying); - ERRCHECKWITHEXIT(result); - return bPlaying; - -} - -float FmodAudioPlayer::getBackgroundMusicVolume() { - float fVolumn; - if (pBGMChannel == NULL) { - return 0; - } - pSystem->update(); - FMOD_RESULT result = pBGMChannel->getVolume(&fVolumn); - ERRCHECKWITHEXIT(result); - return fVolumn; -} - -void FmodAudioPlayer::setBackgroundMusicVolume(float volume) { - if (pBGMChannel == NULL) { - return; - } - pSystem->update(); - FMOD_RESULT result = pBGMChannel->setVolume(volume); - ERRCHECKWITHEXIT(result); - -} -//~BGM - -// for sound effects -float FmodAudioPlayer::getEffectsVolume() { - float fVolumn; - pSystem->update(); - FMOD_RESULT result = pChannelGroup->getVolume(&fVolumn); - ERRCHECKWITHEXIT(result); - return fVolumn; -} - -void FmodAudioPlayer::setEffectsVolume(float volume) { - pSystem->update(); - FMOD_RESULT result = pChannelGroup->setVolume(volume); - ERRCHECKWITHEXIT(result); - -} - -unsigned int FmodAudioPlayer::playEffect(const char* pszFilePath, bool bLoop, - float pitch, float pan, float gain) { - FMOD::Channel* pChannel; - FMOD::Sound* pSound = NULL; - - do { - pSystem->update(); - - map::iterator l_it = mapEffectSound.find( - string(pszFilePath)); - if (l_it == mapEffectSound.end()) { - //no load it yet - preloadEffect(pszFilePath); - l_it = mapEffectSound.find(string(pszFilePath)); - } - pSound = l_it->second; - if (pSound==NULL){ - break; - } - - FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pSound, true, - &pChannel); - - if (ERRCHECK(result)) { - printf("sound effect in %s could not be played", pszFilePath); - break; - } - - pChannel->setChannelGroup(pChannelGroup); - pChannel->setPan(pan); - float freq = 0; - pChannel->getFrequency(&freq); - pChannel->setFrequency(pitch * freq); - pChannel->setVolume(gain); - - //set its loop - pChannel->setLoopCount((bLoop) ? -1 : 0); - result = pChannel->setPaused(false); - - mapEffectSoundChannel[iSoundChannelCount] = pChannel; - return iSoundChannelCount++; - } while (0); - - return 0; -} - -void FmodAudioPlayer::stopEffect(unsigned int nSoundId) { - FMOD::Channel* pChannel; - pSystem->update(); - - map::iterator l_it = - mapEffectSoundChannel.find(nSoundId); - if (l_it == mapEffectSoundChannel.end()) { - //no play yet - return; - } - pChannel = l_it->second; - //stop the channel; - pChannel->stop(); - - //delete from the map; - mapEffectSoundChannel.erase(nSoundId); -} - -void FmodAudioPlayer::pauseEffect(unsigned int uSoundId) { - FMOD::Channel* pChannel; - pSystem->update(); - - map::iterator l_it = - mapEffectSoundChannel.find(uSoundId); - if (l_it == mapEffectSoundChannel.end()) { - //no play yet - return; - } - pChannel = l_it->second; - //pause the channel; - pChannel->setPaused(true); -} - -void FmodAudioPlayer::pauseAllEffects() { - FMOD::Channel* pChannel; - pSystem->update(); - - map::iterator l_it = - mapEffectSoundChannel.begin(); - - for (; l_it != mapEffectSoundChannel.end(); l_it++) { - pChannel = l_it->second; - //pause the channel; - pChannel->setPaused(true); - } -} - -void FmodAudioPlayer::resumeEffect(unsigned int uSoundId) { - FMOD::Channel* pChannel; - pSystem->update(); - - map::iterator l_it = - mapEffectSoundChannel.find(uSoundId); - if (l_it == mapEffectSoundChannel.end()) { - //no play yet - return; - } - - pChannel = l_it->second; - //resume the channel; - pChannel->setPaused(false); -} - -void FmodAudioPlayer::resumeAllEffects() { - FMOD::Channel* pChannel; - pSystem->update(); - - map::iterator l_it = - mapEffectSoundChannel.begin(); - - for (; l_it != mapEffectSoundChannel.end(); l_it++) { - pChannel = l_it->second; - //resume the channel; - pChannel->setPaused(false); - } -} - -void FmodAudioPlayer::stopAllEffects() { - FMOD::Channel* pChannel; - pSystem->update(); - - map::iterator l_it = - mapEffectSoundChannel.begin(); - - for (; l_it != mapEffectSoundChannel.end(); l_it++) { - pChannel = l_it->second; - //resume the channel; - pChannel->stop(); - } - - mapEffectSoundChannel.clear(); -} - -void FmodAudioPlayer::preloadEffect(const char* pszFilePath) { - FMOD::Sound* pLoadSound; - - pSystem->update(); - FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, - &pLoadSound); - if (ERRCHECK(result)){ - printf("sound effect in %s could not be preload", pszFilePath); - return; - } - mapEffectSound[string(pszFilePath)] = pLoadSound; -} - -void FmodAudioPlayer::unloadEffect(const char* pszFilePath) { - FMOD::Sound* pSound; - pSystem->update(); - - map::iterator l_it = mapEffectSound.find( - string(pszFilePath)); - if (l_it == mapEffectSound.end()) { - //no load yet - return; - } - pSound = l_it->second; - - //release the sound; - pSound->release(); - - //delete from the map - mapEffectSound.erase(string(pszFilePath)); -} - -//~for sound effects - -} /* namespace CocosDenshion */ diff --git a/cocos/audio/linux/FmodAudioPlayer.h b/cocos/audio/linux/FmodAudioPlayer.h deleted file mode 100644 index 887d67ea8a..0000000000 --- a/cocos/audio/linux/FmodAudioPlayer.h +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -Copyright (c) 2011 Laschweinski -Copyright (c) 2013-2014 Chukong Technologies Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef FMODAUDIOPLAYER_H_ -#define FMODAUDIOPLAYER_H_ - -#include "fmod.hpp" -#include "fmod_errors.h" -#include "AudioPlayer.h" -#include "string" -#include - - -using namespace std; - -namespace CocosDenshion { - -class FmodAudioPlayer : public AudioPlayer{ -public: - FmodAudioPlayer(); - virtual ~FmodAudioPlayer(); - - static FmodAudioPlayer* sharedPlayer(); - - virtual void close(); - - - - /** - @brief Preload background music - @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo - */ - virtual void preloadBackgroundMusic(const char* pszFilePath); - - /** - @brief Play background music - @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo - @param bLoop Whether the background music loop or not - */ - virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop); - - /** - @brief Stop playing background music - @param bReleaseData If release the background music data or not.As default value is false - */ - virtual void stopBackgroundMusic(bool bReleaseData); - - /** - @brief Pause playing background music - */ - virtual void pauseBackgroundMusic(); - - /** - @brief Resume playing background music - */ - virtual void resumeBackgroundMusic(); - - /** - @brief Rewind playing background music - */ - virtual void rewindBackgroundMusic(); - - virtual bool willPlayBackgroundMusic(); - - /** - @brief Whether the background music is playing - @return If is playing return true,or return false - */ - virtual bool isBackgroundMusicPlaying(); - - // properties - /** - @brief The volume of the background music max value is 1.0,the min value is 0.0 - */ - virtual float getBackgroundMusicVolume(); - - /** - @brief set the volume of background music - @param volume must be in 0.0~1.0 - */ - virtual void setBackgroundMusicVolume(float volume); - - /** - @brief The volume of the effects max value is 1.0,the min value is 0.0 - */ - virtual float getEffectsVolume(); - - /** - @brief set the volume of sound effecs - @param volume must be in 0.0~1.0 - */ - virtual void setEffectsVolume(float volume); - - // for sound effects - /** - @brief Play sound effect - @param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo - @bLoop Whether to loop the effect playing, default value is false - */ - virtual unsigned int playEffect(const char* pszFilePath, bool bLoop, - float pitch, float pan, float gain); - - /** - @brief Stop playing sound effect - @param nSoundId The return value of function playEffect - */ - virtual void stopEffect(unsigned int nSoundId); - - /** - @brief preload a compressed audio file - @details the compressed audio will be decode to wave, then write into an - internal buffer in SimpleaudioEngine - */ - virtual void preloadEffect(const char* pszFilePath); - - /** - @brief unload the preloaded effect from internal buffer - @param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo - */ - virtual void unloadEffect(const char* pszFilePath); - - /** - @brief pause an effect identified by sound id - @param[in] uSoundId sound id - */ - virtual void pauseEffect(unsigned int uSoundId); - - /** - @brief pause all playing effects - */ - virtual void pauseAllEffects(); - - /** - @brief resume an effect identified by sound id - @param[in] uSoundId sound id - */ - virtual void resumeEffect(unsigned int uSoundId); - - /** - @brief resume a effect identified by sound id - */ - virtual void resumeAllEffects(); - - /** - @brief stop all playing effects - */ - virtual void stopAllEffects(); - -private: - - void init(); - map mapEffectSound; - map mapEffectSoundChannel; - - FMOD::System* pSystem; - FMOD::Sound* pMusic; //BGM - FMOD::Channel* pBGMChannel; - - FMOD::ChannelGroup* pChannelGroup; - - unsigned int iSoundChannelCount; - - string sMusicPath; - -}; - -} /* namespace CocosDenshion */ -#endif /* FMODAUDIOPLAYER_H_ */ diff --git a/cocos/audio/linux/SimpleAudioEngine.cpp b/cocos/audio/linux/SimpleAudioEngine.cpp new file mode 100644 index 0000000000..828271ff2f --- /dev/null +++ b/cocos/audio/linux/SimpleAudioEngine.cpp @@ -0,0 +1,211 @@ +#include + +#include "../include/SimpleAudioEngine.h" +#include "../include/AudioEngine.h" + +using namespace CocosDenshion; +using namespace cocos2d; +using namespace cocos2d::experimental; + + +struct SimpleAudioEngineLinux{ + SimpleAudioEngine * engine = nullptr; + int musicid; + float effectsvolume; + std::string musicpath; +}; + +SimpleAudioEngineLinux * g_SimpleAudioEngineLinux = nullptr; + + +SimpleAudioEngine* SimpleAudioEngine::getInstance(){ + if(!g_SimpleAudioEngineLinux){ + g_SimpleAudioEngineLinux = new SimpleAudioEngineLinux(); + g_SimpleAudioEngineLinux->engine = new SimpleAudioEngine(); + } + return g_SimpleAudioEngineLinux->engine; +}; + + void SimpleAudioEngine::end(){ + if(g_SimpleAudioEngineLinux){ + delete g_SimpleAudioEngineLinux->engine; + delete g_SimpleAudioEngineLinux; + } + g_SimpleAudioEngineLinux = nullptr; + }; + + + SimpleAudioEngine::SimpleAudioEngine(){ + g_SimpleAudioEngineLinux->musicid = -1; + g_SimpleAudioEngineLinux->effectsvolume = 1.0f; + }; + + SimpleAudioEngine::~SimpleAudioEngine(){ + + }; + + void SimpleAudioEngine::preloadBackgroundMusic(const char* filePath){ + g_SimpleAudioEngineLinux->musicpath = filePath; + AudioEngine::preload(filePath); + }; + + void SimpleAudioEngine::playBackgroundMusic(const char* filePath, bool loop){ + g_SimpleAudioEngineLinux->musicpath = filePath; + g_SimpleAudioEngineLinux->musicid = AudioEngine::play2d(filePath, loop); + }; + + void SimpleAudioEngine::stopBackgroundMusic(bool releaseData){ + AudioEngine::stop(g_SimpleAudioEngineLinux->musicid); + if(releaseData){ + AudioEngine::uncache(g_SimpleAudioEngineLinux->musicpath.c_str()); + } + }; + + void SimpleAudioEngine::pauseBackgroundMusic(){ + AudioEngine::pause(g_SimpleAudioEngineLinux->musicid); + }; + + void SimpleAudioEngine::resumeBackgroundMusic(){ + AudioEngine::resume(g_SimpleAudioEngineLinux->musicid); + }; + + void SimpleAudioEngine::rewindBackgroundMusic(){ + AudioEngine::setCurrentTime(g_SimpleAudioEngineLinux->musicid, 0); + }; + + bool SimpleAudioEngine::willPlayBackgroundMusic(){ + return g_SimpleAudioEngineLinux->musicid != -1; + }; + + bool SimpleAudioEngine::isBackgroundMusicPlaying(){ + return AudioEngine::getState(g_SimpleAudioEngineLinux->musicid) == AudioEngine::AudioState::PLAYING; + }; + + // + // properties + // + + /** + * The volume of the background music within the range of 0.0 as the minimum and 1.0 as the maximum. + * @js getMusicVolume + * @lua getMusicVolume + */ + float SimpleAudioEngine::getBackgroundMusicVolume(){ + return AudioEngine::getVolume(g_SimpleAudioEngineLinux->musicid); + }; + + /** + * Set the volume of background music. + * + * @param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum. + * @js setMusicVolume + * @lua setMusicVolume + */ + void SimpleAudioEngine::setBackgroundMusicVolume(float volume){ + AudioEngine::setVolume(g_SimpleAudioEngineLinux->musicid, volume); + }; + + /** + * The volume of the effects within the range of 0.0 as the minimum and 1.0 as the maximum. + */ + float SimpleAudioEngine::getEffectsVolume(){ + return g_SimpleAudioEngineLinux->effectsvolume; + }; + + /** + * Set the volume of sound effects. + * + * @param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum. + */ + void SimpleAudioEngine::setEffectsVolume(float volume){ + g_SimpleAudioEngineLinux->effectsvolume = volume; + }; + + /** + * Play sound effect with a file path, pitch, pan and gain. + * + * @param filePath The path of the effect file. + * @param loop Determines whether to loop the effect playing or not. The default value is false. + * @param pitch Frequency, normal value is 1.0. Will also change effect play time. + * @param pan Stereo effect, in the range of [-1..1] where -1 enables only left channel. + * @param gain Volume, in the range of [0..1]. The normal value is 1. + * @return The sound id. + * + * @note Full support is under development, now there are limitations: + * - no pitch effect on Samsung Galaxy S2 with OpenSL backend enabled; + * - no pitch/pan/gain on win32. + */ + unsigned int SimpleAudioEngine::playEffect(const char* filePath, bool loop, float pitch, float pan, float gain){ + return AudioEngine::play2d(filePath, loop, gain); + }; + + /** + * Pause playing sound effect. + * + * @param soundId The return value of function playEffect. + */ + void SimpleAudioEngine::pauseEffect(unsigned int soundId){ + AudioEngine::pause(soundId); + }; + + /** + * Pause all playing sound effect. + */ + void SimpleAudioEngine::pauseAllEffects(){ + AudioEngine::pauseAll(); + }; + + /** + * Resume playing sound effect. + * + * @param soundId The return value of function playEffect. + */ + void SimpleAudioEngine::resumeEffect(unsigned int soundId){ + AudioEngine::resume(soundId); + }; + + /** + * Resume all playing sound effect. + */ + void SimpleAudioEngine::resumeAllEffects(){ + AudioEngine::resumeAll(); + }; + + /** + * Stop playing sound effect. + * + * @param soundId The return value of function playEffect. + */ + void SimpleAudioEngine::stopEffect(unsigned int soundId){ + AudioEngine::stop(soundId); + }; + + /** + * Stop all playing sound effects. + */ + void SimpleAudioEngine::stopAllEffects(){ + AudioEngine::stopAll(); + }; + + /** + * Preload a compressed audio file. + * + * The compressed audio will be decoded to wave, then written into an internal buffer in SimpleAudioEngine. + * + * @param filePath The path of the effect file. + * @js NA + */ + void SimpleAudioEngine::preloadEffect(const char* filePath){ + AudioEngine::preload(filePath); + }; + + /** + * Unload the preloaded effect from internal buffer. + * + * @param filePath The path of the effect file. + */ + void SimpleAudioEngine::unloadEffect(const char* filePath){ + AudioEngine::uncache(filePath); + }; + + \ No newline at end of file diff --git a/cocos/audio/linux/SimpleAudioEngineFMOD.cpp b/cocos/audio/linux/SimpleAudioEngineFMOD.cpp deleted file mode 100644 index 26fd913abe..0000000000 --- a/cocos/audio/linux/SimpleAudioEngineFMOD.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -Copyright (c) 2011 Laschweinski -Copyright (c) 2013-2014 Chukong Technologies Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#ifndef OPENAL - -#include "audio/include/SimpleAudioEngine.h" -#include "FmodAudioPlayer.h" -#include "cocos2d.h" -USING_NS_CC; - -namespace CocosDenshion { - -static AudioPlayer* oAudioPlayer; - -SimpleAudioEngine::SimpleAudioEngine() { - oAudioPlayer = FmodAudioPlayer::sharedPlayer(); -} - -SimpleAudioEngine::~SimpleAudioEngine() { -} - -SimpleAudioEngine* SimpleAudioEngine::getInstance() { - static SimpleAudioEngine s_SharedEngine; - return &s_SharedEngine; -} - -void SimpleAudioEngine::end() { - if(oAudioPlayer) - { - oAudioPlayer->close(); - } -} - -////////////////////////////////////////////////////////////////////////// -// BackgroundMusic -////////////////////////////////////////////////////////////////////////// - -void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, - bool bLoop) { - // Changing file path to full path - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); - oAudioPlayer->playBackgroundMusic(fullPath.c_str(), bLoop); -} - -void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { - oAudioPlayer->stopBackgroundMusic(bReleaseData); -} - -void SimpleAudioEngine::pauseBackgroundMusic() { - oAudioPlayer->pauseBackgroundMusic(); -} - -void SimpleAudioEngine::resumeBackgroundMusic() { - oAudioPlayer->resumeBackgroundMusic(); -} - -void SimpleAudioEngine::rewindBackgroundMusic() { - oAudioPlayer->rewindBackgroundMusic(); -} - -bool SimpleAudioEngine::willPlayBackgroundMusic() { - return oAudioPlayer->willPlayBackgroundMusic(); -} - -bool SimpleAudioEngine::isBackgroundMusicPlaying() { - return oAudioPlayer->isBackgroundMusicPlaying(); -} - -void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { - // Changing file path to full path - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); - return oAudioPlayer->preloadBackgroundMusic(fullPath.c_str()); -} - -////////////////////////////////////////////////////////////////////////// -// effect function -////////////////////////////////////////////////////////////////////////// - -unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop, - float pitch, float pan, float gain) { - // Changing file path to full path - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); - return oAudioPlayer->playEffect(fullPath.c_str(), bLoop, pitch, pan, gain); -} - -void SimpleAudioEngine::stopEffect(unsigned int nSoundId) { - return oAudioPlayer->stopEffect(nSoundId); -} - -void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { - // Changing file path to full path - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); - return oAudioPlayer->preloadEffect(fullPath.c_str()); -} - -void SimpleAudioEngine::unloadEffect(const char* pszFilePath) { - // Changing file path to full path - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); - return oAudioPlayer->unloadEffect(fullPath.c_str()); -} - -void SimpleAudioEngine::pauseEffect(unsigned int uSoundId) { - oAudioPlayer->pauseEffect(uSoundId); -} - -void SimpleAudioEngine::pauseAllEffects() { - oAudioPlayer->pauseAllEffects(); -} - -void SimpleAudioEngine::resumeEffect(unsigned int uSoundId) { - oAudioPlayer->resumeEffect(uSoundId); -} - -void SimpleAudioEngine::resumeAllEffects() { - oAudioPlayer->resumeAllEffects(); -} - -void SimpleAudioEngine::stopAllEffects() { - oAudioPlayer->stopAllEffects(); -} - - - -////////////////////////////////////////////////////////////////////////// -// volume interface -////////////////////////////////////////////////////////////////////////// - -float SimpleAudioEngine::getBackgroundMusicVolume() { - return oAudioPlayer->getBackgroundMusicVolume(); -} - -void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { - return oAudioPlayer->setBackgroundMusicVolume(volume); -} - -float SimpleAudioEngine::getEffectsVolume() { - return oAudioPlayer->getEffectsVolume(); -} - -void SimpleAudioEngine::setEffectsVolume(float volume) { - return oAudioPlayer->setEffectsVolume(volume); -} - - -} // end of namespace CocosDenshion - -#endif diff --git a/external/config.json b/external/config.json index d9326b0071..4c7cebe515 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version":"v3-deps-75", + "version":"v3-deps-78", "zip_file_size":"119277304", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", diff --git a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp index bfd77a672a..3e41d3c117 100644 --- a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp +++ b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp @@ -23,8 +23,6 @@ ****************************************************************************/ #include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - #include "NewAudioEngineTest.h" #include "ui/CocosGUI.h" @@ -635,4 +633,3 @@ std::string AudioIssue11143Test::subtitle() const return "2 seconds after first sound play,you should hear another sound."; } -#endif diff --git a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h index 66e82aed59..4b2223092a 100644 --- a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h +++ b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h @@ -23,7 +23,6 @@ ****************************************************************************/ #include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #ifndef __NEWAUDIOENGINE_TEST_H_ #define __NEWAUDIOENGINE_TEST_H_ @@ -165,4 +164,3 @@ public: }; #endif /* defined(__NEWAUDIOENGINE_TEST_H_) */ -#endif diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index 3d571d5b7c..a95caece22 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -26,9 +26,7 @@ public: addTest("Actions - Progress", [](){return new (std::nothrow) ActionsProgressTests(); }); addTest("Allocator - Basic", [](){return new (std::nothrow) AllocatorTests(); }); addTest("Audio - CocosDenshion", []() { return new (std::nothrow) CocosDenshionTests(); }); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) addTest("Audio - NewAudioEngine", []() { return new (std::nothrow) AudioEngineTests(); }); -#endif #if CC_ENABLE_BOX2D_INTEGRATION addTest("Box2d - Basic", []() { return new (std::nothrow) Box2DTests(); }); addTest("Box2d - TestBed", []() { return new (std::nothrow) Box2dTestBedSuite(); }); diff --git a/tests/cpp-tests/Classes/tests.h b/tests/cpp-tests/Classes/tests.h index 0cbf4f42e9..be32d282ff 100644 --- a/tests/cpp-tests/Classes/tests.h +++ b/tests/cpp-tests/Classes/tests.h @@ -9,9 +9,7 @@ #include "ChipmunkTest/ChipmunkTest.h" #include "ClippingNodeTest/ClippingNodeTest.h" #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "NewAudioEngineTest/NewAudioEngineTest.h" -#endif #if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPEN) #if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) // bada don't support libcurl From 9e50c010e9e6d67311aabe270f9388bec9cba9dd Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 27 Nov 2015 11:49:35 +0800 Subject: [PATCH 162/192] Fix win8.1 project compile error --- .../libjscocos2d.Shared/libjscocos2d.Shared.vcxitems | 3 +++ .../libjscocos2d.Shared.vcxitems.filters | 9 +++++++++ .../libjscocos2d.Windows/libjscocos2d.Windows.vcxproj | 4 ++-- .../libjscocos2d.WindowsPhone.vcxproj | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems index 1bfe439955..8cbf544b9e 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems @@ -39,6 +39,7 @@ + @@ -48,6 +49,7 @@ + @@ -93,6 +95,7 @@ + diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters index 66007643dd..0d24214399 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters @@ -141,6 +141,12 @@ auto + + manual + + + manual + @@ -261,6 +267,9 @@ auto + + manual + diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj index 0a007232a3..b5980b36de 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj @@ -129,7 +129,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;_USRJSSTATIC;%(PreprocessorDefinitions) true ProgramDatabase @@ -150,7 +150,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manua\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;%(PreprocessorDefinitions) false ProgramDatabase diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj index 89be7f39b6..ec659e8365 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj @@ -94,7 +94,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(ProjectDir)..\..\..\manual\navmesh;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;_USRJSSTATIC;%(PreprocessorDefinitions) true ProgramDatabase @@ -115,7 +115,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;%(PreprocessorDefinitions) false ProgramDatabase From a61fe711e294e98efa7e0fafa7de641bab69cbd8 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 27 Nov 2015 14:01:43 +0800 Subject: [PATCH 163/192] Update --- cocos/3d/CCMesh.cpp | 2 +- cocos/3d/CCMesh.h | 2 +- cocos/3d/CCPlane.cpp | 4 ++-- cocos/3d/CCPlane.h | 2 +- cocos/3d/CCSprite3D.cpp | 29 ----------------------------- cocos/3d/CCSprite3D.h | 10 ---------- 6 files changed, 5 insertions(+), 44 deletions(-) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index f48510e672..30d3547e02 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -662,7 +662,7 @@ GLuint Mesh::getIndexBuffer() const return _meshIndexData->getIndexBuffer()->getVBO(); } -GLuint Mesh::checkTextureName() +GLuint Mesh::getTextureName() { if (TextureCache::getInstance()->isDirty()) { diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index ad5cff369d..964850e0e9 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -194,7 +194,7 @@ public: */ void setForce2DQueue(bool force2D) { _force2DQueue = force2D; } - GLuint checkTextureName(); + GLuint getTextureName(); CC_CONSTRUCTOR_ACCESS: diff --git a/cocos/3d/CCPlane.cpp b/cocos/3d/CCPlane.cpp index 5b8acc4a94..3fa0b7f8b9 100755 --- a/cocos/3d/CCPlane.cpp +++ b/cocos/3d/CCPlane.cpp @@ -92,10 +92,10 @@ PointSide Plane::getSide(const Vec3& point) const return PointSide::IN_PLANE; } -PointSide Plane::getSide(const Vec3& point, const Vec3& halfSize) const +PointSide Plane::getSide(const Vec3& point, const Vec3& tolerance) const { float dist = dist2Plane(point); - float maxAbsDist = fabs(_normal.x * halfSize.x) + fabs(_normal.y * halfSize.y) + fabs(_normal.z * halfSize.z); + float maxAbsDist = fabs(_normal.x * tolerance.x) + fabs(_normal.y * tolerance.y) + fabs(_normal.z * tolerance.z); if (dist > maxAbsDist) return PointSide::FRONT_PLANE; diff --git a/cocos/3d/CCPlane.h b/cocos/3d/CCPlane.h index 650c9c8655..87509b32f3 100755 --- a/cocos/3d/CCPlane.h +++ b/cocos/3d/CCPlane.h @@ -103,7 +103,7 @@ public: /** * Return the side where the point is. */ - PointSide getSide(const Vec3& point, const Vec3& halfSize) const; + PointSide getSide(const Vec3& point, const Vec3& tolerance) const; protected: Vec3 _normal; // the normal line of the plane diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 0e8e4198fa..f5178acc02 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -895,35 +895,6 @@ void Sprite3D::setForce2DQueue(bool force2D) } } -const AABB& Sprite3D::getAABB(bool world) const -{ - _aabbDirty = true; - - Mat4 nodeToWorldTransform(getNodeToWorldTransform()); - - // If nodeToWorldTransform matrix isn't changed, we don't need to transform aabb. - if (memcmp(_nodeToWorldTransform.m, nodeToWorldTransform.m, sizeof(Mat4)) == 0 && !_aabbDirty) - { - return _aabb; - } - else - { - _aabb.reset(); - Mat4 transform(nodeToWorldTransform); - for (const auto& it : _meshes) { - if (it->isVisible()) - _aabb.merge(it->getAABB()); - } - - if (world) - _aabb.transform(transform); - - _nodeToWorldTransform = nodeToWorldTransform; - } - - return _aabb; -} - /////////////////////////////////////////////////////////////////////////////////// Sprite3DCache* Sprite3DCache::_cacheInstance = nullptr; Sprite3DCache* Sprite3DCache::getInstance() diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index be9defb3a3..fa5a23ea99 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -205,16 +205,6 @@ public: */ const Vector& getMeshes() const { return _meshes; } - /* - * Get AABB - * If the sprite has animation, it can't be calculated accurately, - * because bone can drive the vertices, we just use the origin vertices - * to calculate the AABB. - * - * @param world Use world transform or not. - */ - const AABB& getAABB(bool world) const; - CC_CONSTRUCTOR_ACCESS: Sprite3D(); From 8e4276469c59a7254a9bf775ab9515c888e11eba Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 27 Nov 2015 14:08:27 +0800 Subject: [PATCH 164/192] Add comment to new function --- cocos/renderer/CCTexture2D.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/renderer/CCTexture2D.h b/cocos/renderer/CCTexture2D.h index 28d8059c5e..ced2f2e596 100644 --- a/cocos/renderer/CCTexture2D.h +++ b/cocos/renderer/CCTexture2D.h @@ -406,7 +406,9 @@ public: /** Get a shader program from the texture.*/ GLProgram* getGLProgram() const; + /** Set if the texture is valid, when it been set as false, it will display as default "file missing texture" */ void setValid(bool valid) { _valid = valid; } + bool isValid() const { return _valid; } std::string getPath()const { return _filePath; } From d6ddb365b6981496ed25d69487ce8677c6112d6c Mon Sep 17 00:00:00 2001 From: Xpol Wan Date: Fri, 27 Nov 2015 14:43:25 +0800 Subject: [PATCH 165/192] Remove boring logs in cocos studio supporting module. They are helpless for debugging, we should use break points for debugging. --- .../ActionTimeline/CCActionTimelineCache.cpp | 2 -- .../cocostudio/ActionTimeline/CSLoader.cpp | 14 -------------- .../cocostudio/CCActionManagerEx.cpp | 3 --- cocos/editor-support/cocostudio/CCSSceneReader.cpp | 3 --- 4 files changed, 22 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp index db9ed09714..4b7ed41437 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp @@ -139,7 +139,6 @@ ActionTimeline* ActionTimelineCache::createAction(const std::string& filename) std::string path = filename; size_t pos = path.find_last_of('.'); std::string suffix = path.substr(pos + 1, path.length()); - CCLOG("suffix = %s", suffix.c_str()); ActionTimelineCache* cache = ActionTimelineCache::getInstance(); @@ -507,7 +506,6 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti if(property == "") return nullptr; - CCLOG("property = %s", property.c_str()); if(property != "") { diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index ccb532481f..f967fb4d68 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -264,7 +264,6 @@ Node* CSLoader::createNode(const std::string& filename) std::string path = filename; size_t pos = path.find_last_of('.'); std::string suffix = path.substr(pos + 1, path.length()); - CCLOG("suffix = %s", suffix.c_str()); CSLoader* load = CSLoader::getInstance(); @@ -285,7 +284,6 @@ Node* CSLoader::createNode(const std::string &filename, const ccNodeLoadCallback std::string path = filename; size_t pos = path.find_last_of('.'); std::string suffix = path.substr(pos + 1, path.length()); - CCLOG("suffix = %s", suffix.c_str()); CSLoader* load = CSLoader::getInstance(); @@ -335,7 +333,6 @@ std::string CSLoader::getExtentionName(const std::string& name) ActionTimeline* CSLoader::createTimeline(const std::string &filename) { std::string suffix = getExtentionName(filename); - CCLOG("suffix = %s", suffix.c_str()); ActionTimelineCache* cache = ActionTimelineCache::getInstance(); @@ -354,7 +351,6 @@ ActionTimeline* CSLoader::createTimeline(const std::string &filename) ActionTimeline* CSLoader::createTimeline(const Data data, const std::string& filename) { std::string suffix = getExtentionName(filename); - CCLOG("suffix = %s", suffix.c_str()); ActionTimelineCache* cache = ActionTimelineCache::getInstance(); @@ -982,7 +978,6 @@ Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName, const ccNod // decode plist auto textures = csparsebinary->textures(); int textureSize = textures->size(); - CCLOG("textureSize = %d", textureSize); for (int i = 0; i < textureSize; ++i) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(textures->Get(i)->c_str()); @@ -1007,7 +1002,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const Node* node = nullptr; std::string classname = nodetree->classname()->c_str(); - CCLOG("classname = %s", classname.c_str()); auto options = nodetree->options(); @@ -1016,7 +1010,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const auto reader = ProjectNodeReader::getInstance(); auto projectNodeOptions = (ProjectNodeOptions*)options->data(); std::string filePath = projectNodeOptions->fileName()->c_str(); - CCLOG("filePath = %s", filePath.c_str()); cocostudio::timeline::ActionTimeline* action = nullptr; if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) @@ -1079,7 +1072,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const { _callbackHandlers.pushBack(node); _rootNode = _callbackHandlers.back(); - CCLOG("after push back _rootNode name = %s", _rootNode->getName().c_str()); } /**/ // _loadingNodeParentHierarchy.push_back(node); @@ -1093,12 +1085,10 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const auto children = nodetree->children(); int size = children->size(); - CCLOG("size = %d", size); for (int i = 0; i < size; ++i) { auto subNodeTree = children->Get(i); Node* child = nodeWithFlatBuffers(subNodeTree, callback); - CCLOG("child = %p", child); if (child) { PageView* pageView = dynamic_cast(node); @@ -1356,7 +1346,6 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod Node* node = nullptr; std::string classname = nodetree->classname()->c_str(); - CCLOG("classname = %s", classname.c_str()); auto options = nodetree->options(); @@ -1365,7 +1354,6 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod auto reader = ProjectNodeReader::getInstance(); auto projectNodeOptions = (ProjectNodeOptions*)options->data(); std::string filePath = projectNodeOptions->fileName()->c_str(); - CCLOG("filePath = %s", filePath.c_str()); cocostudio::timeline::ActionTimeline* action = nullptr; if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) @@ -1431,12 +1419,10 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod auto children = nodetree->children(); int size = children->size(); - CCLOG("size = %d", size); for (int i = 0; i < size; ++i) { auto subNodeTree = children->Get(i); Node* child = nodeWithFlatBuffersForSimulator(subNodeTree); - CCLOG("child = %p", child); if (child) { PageView* pageView = dynamic_cast(node); diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp index 6faed2ed76..efcba92117 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp @@ -63,7 +63,6 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V std::string path = jsonName; ssize_t pos = path.find_last_of("/"); std::string fileName = path.substr(pos+1,path.length()); - CCLOG("filename == %s",fileName.c_str()); cocos2d::Vector actionList; int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist"); for (int i=0; i actionList; stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader); @@ -118,7 +116,6 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* std::string path = jsonName; ssize_t pos = path.find_last_of("/"); std::string fileName = path.substr(pos+1,path.length()); - CCLOG("find filename == %s",fileName.c_str()); auto iterator = _actionDic.find(fileName); if (iterator == _actionDic.end()) { diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index d9137358f1..17eb393652 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -110,7 +110,6 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, { pCom = createComponent(comName); } - CCLOG("classname = %s", comName); if (pCom != nullptr) { data->_rData = nullptr; @@ -270,7 +269,6 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par } const char *comName = DICTOOL->getStringValue_json(subDict, "classname"); Component *com = this->createComponent(comName); - CCLOG("classname = %s", comName); SerData *data = new (std::nothrow) SerData(); if (com != nullptr) { @@ -388,7 +386,6 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode * { pCom = createComponent(comName); } - CCLOG("classname = %s", comName); if (pCom != nullptr) { data->_rData = nullptr; From e13e0cb8869e87a8edfaada3220295a397c09f9d Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 14:54:25 +0800 Subject: [PATCH 166/192] Fix getJSObject issues --- .../js-bindings/manual/ScriptingCore.cpp | 24 +++++++++---------- .../js-bindings/manual/ScriptingCore.h | 4 ++++ .../manual/component/CCComponentJS.cpp | 3 ++- .../manual/jsb_event_dispatcher_manual.cpp | 10 ++++---- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 3f836a3bfd..4c71b1a6a4 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -686,7 +686,7 @@ void ScriptingCore::compileScript(const char *path, JS::HandleObject global, JSC ReportException(cx); std::string fullPath = futil->fullPathForFilename(path); - + JS::CompileOptions op(cx); op.setUTF8(true); op.setFileAndLine(fullPath.c_str(), 1); @@ -1189,7 +1189,7 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve for (const auto& touch : touches) { - JS::RootedValue jsret(_cx, getJSObject(this->_cx, touch)); + JS::RootedValue jsret(_cx, getJSObject(this->_cx, touch)); if (!JS_SetElement(this->_cx, jsretArr, count, jsret)) { break; @@ -1204,7 +1204,7 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve jsval dataVal[2]; dataVal[0] = OBJECT_TO_JSVAL(jsretArr); - dataVal[1] = getJSObject(_cx, event); + dataVal[1] = getJSObject(_cx, event); ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet); @@ -1242,8 +1242,8 @@ bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::Event if (!p) break; jsval dataVal[2]; - dataVal[0] = getJSObject(_cx, touch); - dataVal[1] = getJSObject(_cx, event); + dataVal[0] = getJSObject(_cx, touch); + dataVal[1] = getJSObject(_cx, event); // if (jsvalRet != nullptr) // { @@ -1293,7 +1293,7 @@ bool ScriptingCore::handleMouseEvent(void* nativeObj, cocos2d::EventMouse::Mouse if (!p) break; jsval dataVal[1]; - dataVal[0] = getJSObject(_cx, event); + dataVal[0] = getJSObject(_cx, event); // if (jsvalRet != nullptr) // { @@ -1404,7 +1404,7 @@ bool ScriptingCore::handleKeybardEvent(void* nativeObj, cocos2d::EventKeyboard:: jsval args[2] = { int32_to_jsval(_cx, (int32_t)keyCode), - getJSObject(_cx, event) + getJSObject(_cx, event) }; if (isPressed) @@ -1431,8 +1431,8 @@ bool ScriptingCore::handleFocusEvent(void* nativeObj, cocos2d::ui::Widget* widge return false; jsval args[2] = { - getJSObject(_cx, widgetLoseFocus), - getJSObject(_cx, widgetGetFocus) + getJSObject(_cx, widgetLoseFocus), + getJSObject(_cx, widgetGetFocus) }; bool ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onFocusChanged", 2, args); @@ -1451,7 +1451,7 @@ int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType, int count = 0; for (auto& touch : touches) { - jsval jsret = getJSObject(this->_cx, touch); + jsval jsret = getJSObject(this->_cx, touch); JS::RootedValue jsval(_cx, jsret); if (!JS_SetElement(this->_cx, jsretArr, count, jsval)) { break; @@ -1480,7 +1480,7 @@ int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, JS::RootedValue retval(_cx); std::string funcName = getTouchFuncName(eventType); - jsval jsTouch = getJSObject(this->_cx, pTouch); + jsval jsTouch = getJSObject(this->_cx, pTouch); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval); @@ -1500,7 +1500,7 @@ int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, std::string funcName = getTouchFuncName(eventType); - jsval jsTouch = getJSObject(this->_cx, pTouch); + jsval jsTouch = getJSObject(this->_cx, pTouch); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, retval); diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 97d71c8c83..471c094168 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -540,6 +540,10 @@ void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy); template jsval getJSObject(JSContext* cx, T* nativeObj) { + if (!nativeObj) + { + return JSVAL_NULL; + } js_proxy_t *proxy = js_get_or_create_proxy(cx, nativeObj); return proxy ? OBJECT_TO_JSVAL(proxy->obj) : JSVAL_NULL; } diff --git a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp index 597903d11a..3e76c6d114 100644 --- a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp +++ b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp @@ -78,7 +78,8 @@ ComponentJS::ComponentJS(const std::string& scriptFileName) JS::RootedObject proto(cx, protoValue.toObjectOrNull()); JS::RootedObject parent(cx, typeClass->proto.ref()); jsObj->construct(cx); - jsObj->ref() = JS_NewObject(cx, theClass, proto, parent); + JS::RootedObject obj(cx, JS_NewObject(cx, theClass, proto, parent)); + jsObj->ref() = obj; // Unbind current proxy binding js_proxy_t* jsproxy = js_get_or_create_proxy(cx, this); diff --git a/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp b/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp index 2481746993..83440d28e1 100644 --- a/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp +++ b/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp @@ -57,7 +57,7 @@ bool js_EventListenerTouchOneByOne_create(JSContext *cx, uint32_t argc, jsval *v ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::CANCELLED, touch, event); }; - jsval jsret = getJSObject(cx, ret); + jsval jsret = getJSObject(cx, ret); args.rval().set(jsret); return true; } @@ -88,7 +88,7 @@ bool js_EventListenerTouchAllAtOnce_create(JSContext *cx, uint32_t argc, jsval * ScriptingCore::getInstance()->handleTouchesEvent(ret, EventTouch::EventCode::CANCELLED, touches, event); }; - jsval jsret = getJSObject(cx, ret); + jsval jsret = getJSObject(cx, ret); args.rval().set(jsret); return true; } @@ -119,7 +119,7 @@ bool js_EventListenerMouse_create(JSContext *cx, uint32_t argc, jsval *vp) ScriptingCore::getInstance()->handleMouseEvent(ret, EventMouse::MouseEventType::MOUSE_SCROLL, event); }; - jsval jsret = getJSObject(cx, ret); + jsval jsret = getJSObject(cx, ret); args.rval().set(jsret); return true; } @@ -142,7 +142,7 @@ bool js_EventListenerKeyboard_create(JSContext *cx, uint32_t argc, jsval *vp) ScriptingCore::getInstance()->handleKeybardEvent(ret, keyCode, false, event); }; - jsval jsret = getJSObject(cx, ret); + jsval jsret = getJSObject(cx, ret); args.rval().set(jsret); return true; } @@ -160,7 +160,7 @@ bool js_EventListenerFocus_create(JSContext *cx, uint32_t argc, jsval *vp) ScriptingCore::getInstance()->handleFocusEvent(ret, widgetLoseFocus, widgetGetFocus); }; - jsval jsret = getJSObject(cx, ret); + jsval jsret = getJSObject(cx, ret); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().set(jsret); From f0cc8e7f255da6e70a02677ba8d1c32a1e92c91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=B3=B0?= Date: Fri, 27 Nov 2015 15:44:35 +0800 Subject: [PATCH 167/192] Fix keyboard won't dismiss on iOS issue --- cocos/platform/ios/CCEAGLView-ios.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/platform/ios/CCEAGLView-ios.mm b/cocos/platform/ios/CCEAGLView-ios.mm index 3edc3956c1..334fd30e88 100644 --- a/cocos/platform/ios/CCEAGLView-ios.mm +++ b/cocos/platform/ios/CCEAGLView-ios.mm @@ -378,8 +378,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. for(UIView* view in subviews) { if([view isKindOfClass:NSClassFromString(@"CCCustomUITextField")] || - [view isKindOfClass:NSClassFromString(@"UISingleLineTextField")] || - [view isKindOfClass:NSClassFromString(@"UIMultilineTextField")]) + [view isKindOfClass:NSClassFromString(@"CCUISingleLineTextField")] || + [view isKindOfClass:NSClassFromString(@"CCUIMultilineTextField")]) { if ([view isFirstResponder]) { From 71871bacf9d23078dd6c73fa45dfd645369240d2 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 27 Nov 2015 15:53:26 +0800 Subject: [PATCH 168/192] Add aabb dirty mark when load from file --- cocos/3d/CCSprite3D.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index f5178acc02..63b241f21b 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -286,6 +286,7 @@ bool Sprite3D::init() bool Sprite3D::initWithFile(const std::string& path) { + _aabbDirty = true; _meshes.clear(); _meshVertexDatas.clear(); CC_SAFE_RELEASE_NULL(_skeleton); From 9639208ce3c8ce58dc3cbc33b282ff888e90ebd8 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Fri, 27 Nov 2015 17:32:31 +0800 Subject: [PATCH 169/192] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 0108fbd1df..c2dc465d84 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ cocos2d-x-3.10 December ? 2015 [NEW] Core: Added Application::getVersion() to get the app version. [NEW] UI: Add PageView indicator. +[NEW] Label: Add three Overflow type to new label, see release note for more information. [REFINE] UI: RichText support new line element. [REFINE] UI: Set focus to Widget when touched. From 5c9084fd7d1ef3823240025cb43bb6fe0b1dc992 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 27 Nov 2015 09:41:59 +0000 Subject: [PATCH 170/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 76 +++- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 170 ++++++++- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 8 +- .../scripting/lua-bindings/auto/api/Label.lua | 60 ++- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 341 +++++++++++++++++- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 6 + 6 files changed, 618 insertions(+), 43 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 993733e0c6..6d0eca5575 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -11963,6 +11963,16 @@ getBlendFunc : function ( return cc.BlendFunc; }, +/** + * @method enableWrap + * @param {bool} arg0 + */ +enableWrap : function ( +bool +) +{ +}, + /** * @method setWidth * @param {float} arg0 @@ -11973,6 +11983,16 @@ float { }, +/** + * @method getBMFontSize + * @return {float} + */ +getBMFontSize : function ( +) +{ + return 0; +}, + /** * @method getMaxLineWidth * @return {float} @@ -12027,11 +12047,13 @@ str * @method setBMFontFilePath * @param {String} arg0 * @param {vec2_object} arg1 + * @param {float} arg2 * @return {bool} */ setBMFontFilePath : function ( str, -vec2 +vec2, +float ) { return false; @@ -12057,6 +12079,16 @@ float { }, +/** + * @method setOverflow + * @param {cc.Label::Overflow} arg0 + */ +setOverflow : function ( +overflow +) +{ +}, + /** * @method getLineSpacing * @return {float} @@ -12245,6 +12277,18 @@ color4b { }, +/** + * @method getLetter + * @param {int} arg0 + * @return {cc.Sprite} + */ +getLetter : function ( +int +) +{ + return cc.Sprite; +}, + /** * @method setHeight * @param {float} arg0 @@ -12276,15 +12320,13 @@ color4b }, /** - * @method getLetter - * @param {int} arg0 - * @return {cc.Sprite} + * @method getOverflow + * @return {cc.Label::Overflow} */ -getLetter : function ( -int +getOverflow : function ( ) { - return cc.Sprite; + return 0; }, /** @@ -12347,6 +12389,16 @@ texthalignment { }, +/** + * @method isWrapEnabled + * @return {bool} + */ +isWrapEnabled : function ( +) +{ + return false; +}, + /** * @method setAlignment * @param {cc.TextHAlignment|cc.TextHAlignment} texthalignment @@ -12367,6 +12419,16 @@ requestSystemFontRefresh : function ( { }, +/** + * @method setBMFontSize + * @param {float} arg0 + */ +setBMFontSize : function ( +float +) +{ +}, + /** * @method createWithBMFont * @param {String} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 5b6c247352..226143358d 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -37622,6 +37622,26 @@ bool js_cocos2dx_Label_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Label_enableWrap(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_enableWrap : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableWrap : Error processing arguments"); + cobj->enableWrap(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_enableWrap : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -37642,6 +37662,24 @@ bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_setWidth : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_getBMFontSize(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getBMFontSize : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getBMFontSize(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getBMFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -37768,6 +37806,20 @@ bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp args.rval().set(jsret); return true; } + if (argc == 3) { + std::string arg0; + cocos2d::Vec2 arg1; + double arg2 = 0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setBMFontFilePath : Error processing arguments"); + bool ret = cobj->setBMFontFilePath(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } JS_ReportError(cx, "js_cocos2dx_Label_setBMFontFilePath : wrong number of arguments: %d, was expecting %d", argc, 1); return false; @@ -37812,6 +37864,26 @@ bool js_cocos2dx_Label_setSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp JS_ReportError(cx, "js_cocos2dx_Label_setSystemFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_setOverflow(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setOverflow : Invalid Native Object"); + if (argc == 1) { + cocos2d::Label::Overflow arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setOverflow : Error processing arguments"); + cobj->setOverflow(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setOverflow : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_getLineSpacing(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -38219,6 +38291,35 @@ bool js_cocos2dx_Label_setTextColor(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_setTextColor : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_getLetter(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getLetter : Invalid Native Object"); + if (argc == 1) { + int arg0 = 0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_getLetter : Error processing arguments"); + cocos2d::Sprite* ret = cobj->getLetter(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getLetter : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -38277,33 +38378,22 @@ bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_enableGlow : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Label_getOverflow(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getLetter : Invalid Native Object"); - if (argc == 1) { - int arg0 = 0; - ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_getLetter : Error processing arguments"); - cocos2d::Sprite* ret = cobj->getLetter(arg0); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getOverflow : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getOverflow(); jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); + jsret = int32_to_jsval(cx, ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_Label_getLetter : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_Label_getOverflow : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp) @@ -38420,6 +38510,24 @@ bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_Label_setHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_isWrapEnabled(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_isWrapEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isWrapEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_isWrapEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) { bool ok = true; @@ -38475,6 +38583,26 @@ bool js_cocos2dx_Label_requestSystemFontRefresh(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_Label_requestSystemFontRefresh : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Label_setBMFontSize(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setBMFontSize : Invalid Native Object"); + if (argc == 1) { + double arg0 = 0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setBMFontSize : Error processing arguments"); + cobj->setBMFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setBMFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -38865,7 +38993,9 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("disableEffect", js_cocos2dx_Label_disableEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextColor", js_cocos2dx_Label_getTextColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBlendFunc", js_cocos2dx_Label_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableWrap", js_cocos2dx_Label_enableWrap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setWidth", js_cocos2dx_Label_setWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBMFontSize", js_cocos2dx_Label_getBMFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxLineWidth", js_cocos2dx_Label_getMaxLineWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHorizontalAlignment", js_cocos2dx_Label_getHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClipMarginEnabled", js_cocos2dx_Label_setClipMarginEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -38874,6 +39004,7 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("setBMFontFilePath", js_cocos2dx_Label_setBMFontFilePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLineHeight", js_cocos2dx_Label_setLineHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSystemFontSize", js_cocos2dx_Label_setSystemFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOverflow", js_cocos2dx_Label_setOverflow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLineSpacing", js_cocos2dx_Label_getLineSpacing, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateContent", js_cocos2dx_Label_updateContent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringLength", js_cocos2dx_Label_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -38892,18 +39023,21 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("getTTFConfig", js_cocos2dx_Label_getTTFConfig, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVerticalAlignment", js_cocos2dx_Label_getVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextColor", js_cocos2dx_Label_setTextColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLetter", js_cocos2dx_Label_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHeight", js_cocos2dx_Label_setHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWidth", js_cocos2dx_Label_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableGlow", js_cocos2dx_Label_enableGlow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getLetter", js_cocos2dx_Label_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOverflow", js_cocos2dx_Label_getOverflow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAdditionalKerning", js_cocos2dx_Label_setAdditionalKerning, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSystemFontSize", js_cocos2dx_Label_getSystemFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBlendFunc", js_cocos2dx_Label_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextAlignment", js_cocos2dx_Label_getTextAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBMFontFilePath", js_cocos2dx_Label_getBMFontFilePath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHorizontalAlignment", js_cocos2dx_Label_setHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isWrapEnabled", js_cocos2dx_Label_isWrapEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlignment", js_cocos2dx_Label_setAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestSystemFontRefresh", js_cocos2dx_Label_requestSystemFontRefresh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBMFontSize", js_cocos2dx_Label_setBMFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_Label_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 5cb07c92a4..fc47a4ce20 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -2221,7 +2221,9 @@ bool js_cocos2dx_Label_getHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getTextColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_enableWrap(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getBMFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -2230,6 +2232,7 @@ bool js_cocos2dx_Label_setSystemFontName(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setLineHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setOverflow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getLineSpacing(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_updateContent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); @@ -2248,18 +2251,21 @@ bool js_cocos2dx_Label_getLineHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getTTFConfig(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setTextColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getOverflow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_isWrapEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_requestSystemFontRefresh(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setBMFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index 8d37a58725..2b2c13b211 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -65,6 +65,15 @@ -- @param self -- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc) +-------------------------------- +-- Toggle wrap option of the label.
+-- Note: System font doesn't support manually toggle wrap.
+-- param enable Set true to enable wrap and false to disable wrap. +-- @function [parent=#Label] enableWrap +-- @param self +-- @param #bool enable +-- @return Label#Label self (return value: cc.Label) + -------------------------------- -- Makes the Label exactly this untransformed width.
-- The Label's width be used for text align if the value not equal zero. @@ -73,6 +82,13 @@ -- @param #float width -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Return the user define BMFont size.
+-- return The BMFont size in float value. +-- @function [parent=#Label] getBMFontSize +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- -- @function [parent=#Label] getMaxLineWidth @@ -114,6 +130,7 @@ -- @param self -- @param #string bmfontFilePath -- @param #vec2_table imageOffset +-- @param #float fontSize -- @return bool#bool ret (return value: bool) -------------------------------- @@ -138,6 +155,16 @@ -- @param #float fontSize -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type.
+-- Char Map font supports all the Overflow type except for SHRINK, because we can't measure it's font size.
+-- System font only support Overflow::Normal and Overflow::RESIZE_HEIGHT.
+-- param overflow see `Overflow` +-- @function [parent=#Label] setOverflow +-- @param self +-- @param #int overflow +-- @return Label#Label self (return value: cc.Label) + -------------------------------- -- -- @function [parent=#Label] getLineSpacing @@ -270,6 +297,14 @@ -- @param #color4b_table color -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Provides a way to treats each character like a Sprite.
+-- warning No support system font. +-- @function [parent=#Label] getLetter +-- @param self +-- @param #int lettetIndex +-- @return Sprite#Sprite ret (return value: cc.Sprite) + -------------------------------- -- Makes the Label exactly this untransformed height.
-- The Label's height be used for text align if the value not equal zero.
@@ -294,12 +329,11 @@ -- @return Label#Label self (return value: cc.Label) -------------------------------- --- Provides a way to treats each character like a Sprite.
--- warning No support system font. --- @function [parent=#Label] getLetter +-- Query the label's Overflow type.
+-- return see `Overflow` +-- @function [parent=#Label] getOverflow -- @param self --- @param #int lettetIndex --- @return Sprite#Sprite ret (return value: cc.Sprite) +-- @return int#int ret (return value: int) -------------------------------- -- Sets the additional kerning of the Label.
@@ -342,6 +376,13 @@ -- @param #int hAlignment -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Query the wrap is enabled or not.
+-- Note: System font will always return true. +-- @function [parent=#Label] isWrapEnabled +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- @overload self, int, int -- @overload self, int @@ -357,6 +398,15 @@ -- @param self -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Change font size of label type BMFONT
+-- Note: This function only scale the BMFONT letter to mimic the font size change effect.
+-- param fontSize The desired font size in float. +-- @function [parent=#Label] setBMFontSize +-- @param self +-- @param #float fontSize +-- @return Label#Label self (return value: cc.Label) + -------------------------------- -- Allocates and initializes a Label, with a bitmap font file.
-- param bmfontPath A bitmap font file, it's a FNT format.
diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 53bbc062c0..32e3b4a832 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -51038,6 +51038,56 @@ int lua_cocos2dx_Label_getBlendFunc(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_enableWrap(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_enableWrap'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Label:enableWrap"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_enableWrap'", nullptr); + return 0; + } + cobj->enableWrap(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:enableWrap",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_enableWrap'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setWidth(lua_State* tolua_S) { int argc = 0; @@ -51088,6 +51138,53 @@ int lua_cocos2dx_Label_setWidth(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getBMFontSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getBMFontSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getBMFontSize'", nullptr); + return 0; + } + double ret = cobj->getBMFontSize(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getBMFontSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getBMFontSize'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_getMaxLineWidth(lua_State* tolua_S) { int argc = 0; @@ -51389,6 +51486,26 @@ int lua_cocos2dx_Label_setBMFontFilePath(lua_State* tolua_S) tolua_pushboolean(tolua_S,(bool)ret); return 1; } + if (argc == 3) + { + std::string arg0; + cocos2d::Vec2 arg1; + double arg2; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Label:setBMFontFilePath"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.Label:setBMFontFilePath"); + + ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.Label:setBMFontFilePath"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_setBMFontFilePath'", nullptr); + return 0; + } + bool ret = cobj->setBMFontFilePath(arg0, arg1, arg2); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:setBMFontFilePath",argc, 1); return 0; @@ -51546,6 +51663,56 @@ int lua_cocos2dx_Label_setSystemFontSize(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_setOverflow(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setOverflow'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Label::Overflow arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Label:setOverflow"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_setOverflow'", nullptr); + return 0; + } + cobj->setOverflow(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:setOverflow",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setOverflow'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_getLineSpacing(lua_State* tolua_S) { int argc = 0; @@ -52474,6 +52641,56 @@ int lua_cocos2dx_Label_setTextColor(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getLetter(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getLetter'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Label:getLetter"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getLetter'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getLetter(arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getLetter",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getLetter'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setHeight(lua_State* tolua_S) { int argc = 0; @@ -52621,7 +52838,7 @@ int lua_cocos2dx_Label_enableGlow(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Label_getLetter(lua_State* tolua_S) +int lua_cocos2dx_Label_getOverflow(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; @@ -52641,32 +52858,29 @@ int lua_cocos2dx_Label_getLetter(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getLetter'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getOverflow'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Label:getLetter"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getLetter'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getOverflow'", nullptr); return 0; } - cocos2d::Sprite* ret = cobj->getLetter(arg0); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + int ret = (int)cobj->getOverflow(); + tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getLetter",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getOverflow",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getLetter'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getOverflow'.",&tolua_err); #endif return 0; @@ -52962,6 +53176,53 @@ int lua_cocos2dx_Label_setHorizontalAlignment(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_isWrapEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_isWrapEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_isWrapEnabled'", nullptr); + return 0; + } + bool ret = cobj->isWrapEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:isWrapEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_isWrapEnabled'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setAlignment(lua_State* tolua_S) { int argc = 0; @@ -53068,6 +53329,56 @@ int lua_cocos2dx_Label_requestSystemFontRefresh(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_setBMFontSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setBMFontSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Label:setBMFontSize"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_setBMFontSize'", nullptr); + return 0; + } + cobj->setBMFontSize(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:setBMFontSize",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setBMFontSize'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_createWithBMFont(lua_State* tolua_S) { int argc = 0; @@ -53400,7 +53711,9 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"setTTFConfig",lua_cocos2dx_Label_setTTFConfig); tolua_function(tolua_S,"getTextColor",lua_cocos2dx_Label_getTextColor); tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_Label_getBlendFunc); + tolua_function(tolua_S,"enableWrap",lua_cocos2dx_Label_enableWrap); tolua_function(tolua_S,"setWidth",lua_cocos2dx_Label_setWidth); + tolua_function(tolua_S,"getBMFontSize",lua_cocos2dx_Label_getBMFontSize); tolua_function(tolua_S,"getMaxLineWidth",lua_cocos2dx_Label_getMaxLineWidth); tolua_function(tolua_S,"getHorizontalAlignment",lua_cocos2dx_Label_getHorizontalAlignment); tolua_function(tolua_S,"setClipMarginEnabled",lua_cocos2dx_Label_setClipMarginEnabled); @@ -53410,6 +53723,7 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"getFontAtlas",lua_cocos2dx_Label_getFontAtlas); tolua_function(tolua_S,"setLineHeight",lua_cocos2dx_Label_setLineHeight); tolua_function(tolua_S,"setSystemFontSize",lua_cocos2dx_Label_setSystemFontSize); + tolua_function(tolua_S,"setOverflow",lua_cocos2dx_Label_setOverflow); tolua_function(tolua_S,"getLineSpacing",lua_cocos2dx_Label_getLineSpacing); tolua_function(tolua_S,"updateContent",lua_cocos2dx_Label_updateContent); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_Label_getStringLength); @@ -53428,18 +53742,21 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"getTTFConfig",lua_cocos2dx_Label_getTTFConfig); tolua_function(tolua_S,"getVerticalAlignment",lua_cocos2dx_Label_getVerticalAlignment); tolua_function(tolua_S,"setTextColor",lua_cocos2dx_Label_setTextColor); + tolua_function(tolua_S,"getLetter",lua_cocos2dx_Label_getLetter); tolua_function(tolua_S,"setHeight",lua_cocos2dx_Label_setHeight); tolua_function(tolua_S,"getWidth",lua_cocos2dx_Label_getWidth); tolua_function(tolua_S,"enableGlow",lua_cocos2dx_Label_enableGlow); - tolua_function(tolua_S,"getLetter",lua_cocos2dx_Label_getLetter); + tolua_function(tolua_S,"getOverflow",lua_cocos2dx_Label_getOverflow); tolua_function(tolua_S,"setAdditionalKerning",lua_cocos2dx_Label_setAdditionalKerning); tolua_function(tolua_S,"getSystemFontSize",lua_cocos2dx_Label_getSystemFontSize); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_Label_setBlendFunc); tolua_function(tolua_S,"getTextAlignment",lua_cocos2dx_Label_getTextAlignment); tolua_function(tolua_S,"getBMFontFilePath",lua_cocos2dx_Label_getBMFontFilePath); tolua_function(tolua_S,"setHorizontalAlignment",lua_cocos2dx_Label_setHorizontalAlignment); + tolua_function(tolua_S,"isWrapEnabled",lua_cocos2dx_Label_isWrapEnabled); tolua_function(tolua_S,"setAlignment",lua_cocos2dx_Label_setAlignment); tolua_function(tolua_S,"requestSystemFontRefresh",lua_cocos2dx_Label_requestSystemFontRefresh); + tolua_function(tolua_S,"setBMFontSize",lua_cocos2dx_Label_setBMFontSize); tolua_function(tolua_S,"createWithBMFont", lua_cocos2dx_Label_createWithBMFont); tolua_function(tolua_S,"create", lua_cocos2dx_Label_create); tolua_function(tolua_S,"createWithCharMap", lua_cocos2dx_Label_createWithCharMap); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 9cc34867e0..74d55a4bac 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2146,6 +2146,12 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + + + From 1d581264dffcf1f3c1e3a647e0b0dd1b8ca9b0ff Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 27 Nov 2015 09:42:17 +0000 Subject: [PATCH 171/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 76 +++- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 170 ++++++++- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 8 +- .../scripting/lua-bindings/auto/api/Label.lua | 60 ++- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 341 +++++++++++++++++- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 6 + 6 files changed, 618 insertions(+), 43 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 993733e0c6..6d0eca5575 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -11963,6 +11963,16 @@ getBlendFunc : function ( return cc.BlendFunc; }, +/** + * @method enableWrap + * @param {bool} arg0 + */ +enableWrap : function ( +bool +) +{ +}, + /** * @method setWidth * @param {float} arg0 @@ -11973,6 +11983,16 @@ float { }, +/** + * @method getBMFontSize + * @return {float} + */ +getBMFontSize : function ( +) +{ + return 0; +}, + /** * @method getMaxLineWidth * @return {float} @@ -12027,11 +12047,13 @@ str * @method setBMFontFilePath * @param {String} arg0 * @param {vec2_object} arg1 + * @param {float} arg2 * @return {bool} */ setBMFontFilePath : function ( str, -vec2 +vec2, +float ) { return false; @@ -12057,6 +12079,16 @@ float { }, +/** + * @method setOverflow + * @param {cc.Label::Overflow} arg0 + */ +setOverflow : function ( +overflow +) +{ +}, + /** * @method getLineSpacing * @return {float} @@ -12245,6 +12277,18 @@ color4b { }, +/** + * @method getLetter + * @param {int} arg0 + * @return {cc.Sprite} + */ +getLetter : function ( +int +) +{ + return cc.Sprite; +}, + /** * @method setHeight * @param {float} arg0 @@ -12276,15 +12320,13 @@ color4b }, /** - * @method getLetter - * @param {int} arg0 - * @return {cc.Sprite} + * @method getOverflow + * @return {cc.Label::Overflow} */ -getLetter : function ( -int +getOverflow : function ( ) { - return cc.Sprite; + return 0; }, /** @@ -12347,6 +12389,16 @@ texthalignment { }, +/** + * @method isWrapEnabled + * @return {bool} + */ +isWrapEnabled : function ( +) +{ + return false; +}, + /** * @method setAlignment * @param {cc.TextHAlignment|cc.TextHAlignment} texthalignment @@ -12367,6 +12419,16 @@ requestSystemFontRefresh : function ( { }, +/** + * @method setBMFontSize + * @param {float} arg0 + */ +setBMFontSize : function ( +float +) +{ +}, + /** * @method createWithBMFont * @param {String} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 5b6c247352..226143358d 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -37622,6 +37622,26 @@ bool js_cocos2dx_Label_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Label_enableWrap(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_enableWrap : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableWrap : Error processing arguments"); + cobj->enableWrap(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_enableWrap : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -37642,6 +37662,24 @@ bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_setWidth : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_getBMFontSize(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getBMFontSize : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getBMFontSize(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getBMFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -37768,6 +37806,20 @@ bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp args.rval().set(jsret); return true; } + if (argc == 3) { + std::string arg0; + cocos2d::Vec2 arg1; + double arg2 = 0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setBMFontFilePath : Error processing arguments"); + bool ret = cobj->setBMFontFilePath(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } JS_ReportError(cx, "js_cocos2dx_Label_setBMFontFilePath : wrong number of arguments: %d, was expecting %d", argc, 1); return false; @@ -37812,6 +37864,26 @@ bool js_cocos2dx_Label_setSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp JS_ReportError(cx, "js_cocos2dx_Label_setSystemFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_setOverflow(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setOverflow : Invalid Native Object"); + if (argc == 1) { + cocos2d::Label::Overflow arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setOverflow : Error processing arguments"); + cobj->setOverflow(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setOverflow : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_getLineSpacing(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -38219,6 +38291,35 @@ bool js_cocos2dx_Label_setTextColor(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_setTextColor : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_getLetter(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getLetter : Invalid Native Object"); + if (argc == 1) { + int arg0 = 0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_getLetter : Error processing arguments"); + cocos2d::Sprite* ret = cobj->getLetter(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getLetter : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -38277,33 +38378,22 @@ bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_enableGlow : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Label_getOverflow(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getLetter : Invalid Native Object"); - if (argc == 1) { - int arg0 = 0; - ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_getLetter : Error processing arguments"); - cocos2d::Sprite* ret = cobj->getLetter(arg0); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getOverflow : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getOverflow(); jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); + jsret = int32_to_jsval(cx, ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_Label_getLetter : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_Label_getOverflow : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp) @@ -38420,6 +38510,24 @@ bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_Label_setHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_isWrapEnabled(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_isWrapEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isWrapEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_isWrapEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) { bool ok = true; @@ -38475,6 +38583,26 @@ bool js_cocos2dx_Label_requestSystemFontRefresh(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_Label_requestSystemFontRefresh : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Label_setBMFontSize(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::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setBMFontSize : Invalid Native Object"); + if (argc == 1) { + double arg0 = 0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setBMFontSize : Error processing arguments"); + cobj->setBMFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setBMFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -38865,7 +38993,9 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("disableEffect", js_cocos2dx_Label_disableEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextColor", js_cocos2dx_Label_getTextColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBlendFunc", js_cocos2dx_Label_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableWrap", js_cocos2dx_Label_enableWrap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setWidth", js_cocos2dx_Label_setWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBMFontSize", js_cocos2dx_Label_getBMFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxLineWidth", js_cocos2dx_Label_getMaxLineWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHorizontalAlignment", js_cocos2dx_Label_getHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClipMarginEnabled", js_cocos2dx_Label_setClipMarginEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -38874,6 +39004,7 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("setBMFontFilePath", js_cocos2dx_Label_setBMFontFilePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLineHeight", js_cocos2dx_Label_setLineHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSystemFontSize", js_cocos2dx_Label_setSystemFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOverflow", js_cocos2dx_Label_setOverflow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLineSpacing", js_cocos2dx_Label_getLineSpacing, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateContent", js_cocos2dx_Label_updateContent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringLength", js_cocos2dx_Label_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -38892,18 +39023,21 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("getTTFConfig", js_cocos2dx_Label_getTTFConfig, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVerticalAlignment", js_cocos2dx_Label_getVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextColor", js_cocos2dx_Label_setTextColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLetter", js_cocos2dx_Label_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHeight", js_cocos2dx_Label_setHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWidth", js_cocos2dx_Label_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableGlow", js_cocos2dx_Label_enableGlow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getLetter", js_cocos2dx_Label_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOverflow", js_cocos2dx_Label_getOverflow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAdditionalKerning", js_cocos2dx_Label_setAdditionalKerning, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSystemFontSize", js_cocos2dx_Label_getSystemFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBlendFunc", js_cocos2dx_Label_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextAlignment", js_cocos2dx_Label_getTextAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBMFontFilePath", js_cocos2dx_Label_getBMFontFilePath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHorizontalAlignment", js_cocos2dx_Label_setHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isWrapEnabled", js_cocos2dx_Label_isWrapEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlignment", js_cocos2dx_Label_setAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestSystemFontRefresh", js_cocos2dx_Label_requestSystemFontRefresh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBMFontSize", js_cocos2dx_Label_setBMFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_Label_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 5cb07c92a4..fc47a4ce20 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -2221,7 +2221,9 @@ bool js_cocos2dx_Label_getHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getTextColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_enableWrap(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getBMFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -2230,6 +2232,7 @@ bool js_cocos2dx_Label_setSystemFontName(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setLineHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setOverflow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getLineSpacing(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_updateContent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); @@ -2248,18 +2251,21 @@ bool js_cocos2dx_Label_getLineHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getTTFConfig(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setTextColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getOverflow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_isWrapEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_requestSystemFontRefresh(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setBMFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index 8d37a58725..2b2c13b211 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -65,6 +65,15 @@ -- @param self -- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc) +-------------------------------- +-- Toggle wrap option of the label.
+-- Note: System font doesn't support manually toggle wrap.
+-- param enable Set true to enable wrap and false to disable wrap. +-- @function [parent=#Label] enableWrap +-- @param self +-- @param #bool enable +-- @return Label#Label self (return value: cc.Label) + -------------------------------- -- Makes the Label exactly this untransformed width.
-- The Label's width be used for text align if the value not equal zero. @@ -73,6 +82,13 @@ -- @param #float width -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Return the user define BMFont size.
+-- return The BMFont size in float value. +-- @function [parent=#Label] getBMFontSize +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- -- @function [parent=#Label] getMaxLineWidth @@ -114,6 +130,7 @@ -- @param self -- @param #string bmfontFilePath -- @param #vec2_table imageOffset +-- @param #float fontSize -- @return bool#bool ret (return value: bool) -------------------------------- @@ -138,6 +155,16 @@ -- @param #float fontSize -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type.
+-- Char Map font supports all the Overflow type except for SHRINK, because we can't measure it's font size.
+-- System font only support Overflow::Normal and Overflow::RESIZE_HEIGHT.
+-- param overflow see `Overflow` +-- @function [parent=#Label] setOverflow +-- @param self +-- @param #int overflow +-- @return Label#Label self (return value: cc.Label) + -------------------------------- -- -- @function [parent=#Label] getLineSpacing @@ -270,6 +297,14 @@ -- @param #color4b_table color -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Provides a way to treats each character like a Sprite.
+-- warning No support system font. +-- @function [parent=#Label] getLetter +-- @param self +-- @param #int lettetIndex +-- @return Sprite#Sprite ret (return value: cc.Sprite) + -------------------------------- -- Makes the Label exactly this untransformed height.
-- The Label's height be used for text align if the value not equal zero.
@@ -294,12 +329,11 @@ -- @return Label#Label self (return value: cc.Label) -------------------------------- --- Provides a way to treats each character like a Sprite.
--- warning No support system font. --- @function [parent=#Label] getLetter +-- Query the label's Overflow type.
+-- return see `Overflow` +-- @function [parent=#Label] getOverflow -- @param self --- @param #int lettetIndex --- @return Sprite#Sprite ret (return value: cc.Sprite) +-- @return int#int ret (return value: int) -------------------------------- -- Sets the additional kerning of the Label.
@@ -342,6 +376,13 @@ -- @param #int hAlignment -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Query the wrap is enabled or not.
+-- Note: System font will always return true. +-- @function [parent=#Label] isWrapEnabled +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- @overload self, int, int -- @overload self, int @@ -357,6 +398,15 @@ -- @param self -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Change font size of label type BMFONT
+-- Note: This function only scale the BMFONT letter to mimic the font size change effect.
+-- param fontSize The desired font size in float. +-- @function [parent=#Label] setBMFontSize +-- @param self +-- @param #float fontSize +-- @return Label#Label self (return value: cc.Label) + -------------------------------- -- Allocates and initializes a Label, with a bitmap font file.
-- param bmfontPath A bitmap font file, it's a FNT format.
diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 53bbc062c0..32e3b4a832 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -51038,6 +51038,56 @@ int lua_cocos2dx_Label_getBlendFunc(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_enableWrap(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_enableWrap'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Label:enableWrap"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_enableWrap'", nullptr); + return 0; + } + cobj->enableWrap(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:enableWrap",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_enableWrap'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setWidth(lua_State* tolua_S) { int argc = 0; @@ -51088,6 +51138,53 @@ int lua_cocos2dx_Label_setWidth(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getBMFontSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getBMFontSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getBMFontSize'", nullptr); + return 0; + } + double ret = cobj->getBMFontSize(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getBMFontSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getBMFontSize'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_getMaxLineWidth(lua_State* tolua_S) { int argc = 0; @@ -51389,6 +51486,26 @@ int lua_cocos2dx_Label_setBMFontFilePath(lua_State* tolua_S) tolua_pushboolean(tolua_S,(bool)ret); return 1; } + if (argc == 3) + { + std::string arg0; + cocos2d::Vec2 arg1; + double arg2; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Label:setBMFontFilePath"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.Label:setBMFontFilePath"); + + ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.Label:setBMFontFilePath"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_setBMFontFilePath'", nullptr); + return 0; + } + bool ret = cobj->setBMFontFilePath(arg0, arg1, arg2); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:setBMFontFilePath",argc, 1); return 0; @@ -51546,6 +51663,56 @@ int lua_cocos2dx_Label_setSystemFontSize(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_setOverflow(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setOverflow'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Label::Overflow arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Label:setOverflow"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_setOverflow'", nullptr); + return 0; + } + cobj->setOverflow(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:setOverflow",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setOverflow'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_getLineSpacing(lua_State* tolua_S) { int argc = 0; @@ -52474,6 +52641,56 @@ int lua_cocos2dx_Label_setTextColor(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getLetter(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getLetter'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Label:getLetter"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getLetter'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getLetter(arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getLetter",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getLetter'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setHeight(lua_State* tolua_S) { int argc = 0; @@ -52621,7 +52838,7 @@ int lua_cocos2dx_Label_enableGlow(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Label_getLetter(lua_State* tolua_S) +int lua_cocos2dx_Label_getOverflow(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; @@ -52641,32 +52858,29 @@ int lua_cocos2dx_Label_getLetter(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getLetter'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getOverflow'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Label:getLetter"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getLetter'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getOverflow'", nullptr); return 0; } - cocos2d::Sprite* ret = cobj->getLetter(arg0); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + int ret = (int)cobj->getOverflow(); + tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getLetter",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getOverflow",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getLetter'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getOverflow'.",&tolua_err); #endif return 0; @@ -52962,6 +53176,53 @@ int lua_cocos2dx_Label_setHorizontalAlignment(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_isWrapEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_isWrapEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_isWrapEnabled'", nullptr); + return 0; + } + bool ret = cobj->isWrapEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:isWrapEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_isWrapEnabled'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setAlignment(lua_State* tolua_S) { int argc = 0; @@ -53068,6 +53329,56 @@ int lua_cocos2dx_Label_requestSystemFontRefresh(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_setBMFontSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setBMFontSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Label:setBMFontSize"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_setBMFontSize'", nullptr); + return 0; + } + cobj->setBMFontSize(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:setBMFontSize",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setBMFontSize'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_createWithBMFont(lua_State* tolua_S) { int argc = 0; @@ -53400,7 +53711,9 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"setTTFConfig",lua_cocos2dx_Label_setTTFConfig); tolua_function(tolua_S,"getTextColor",lua_cocos2dx_Label_getTextColor); tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_Label_getBlendFunc); + tolua_function(tolua_S,"enableWrap",lua_cocos2dx_Label_enableWrap); tolua_function(tolua_S,"setWidth",lua_cocos2dx_Label_setWidth); + tolua_function(tolua_S,"getBMFontSize",lua_cocos2dx_Label_getBMFontSize); tolua_function(tolua_S,"getMaxLineWidth",lua_cocos2dx_Label_getMaxLineWidth); tolua_function(tolua_S,"getHorizontalAlignment",lua_cocos2dx_Label_getHorizontalAlignment); tolua_function(tolua_S,"setClipMarginEnabled",lua_cocos2dx_Label_setClipMarginEnabled); @@ -53410,6 +53723,7 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"getFontAtlas",lua_cocos2dx_Label_getFontAtlas); tolua_function(tolua_S,"setLineHeight",lua_cocos2dx_Label_setLineHeight); tolua_function(tolua_S,"setSystemFontSize",lua_cocos2dx_Label_setSystemFontSize); + tolua_function(tolua_S,"setOverflow",lua_cocos2dx_Label_setOverflow); tolua_function(tolua_S,"getLineSpacing",lua_cocos2dx_Label_getLineSpacing); tolua_function(tolua_S,"updateContent",lua_cocos2dx_Label_updateContent); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_Label_getStringLength); @@ -53428,18 +53742,21 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"getTTFConfig",lua_cocos2dx_Label_getTTFConfig); tolua_function(tolua_S,"getVerticalAlignment",lua_cocos2dx_Label_getVerticalAlignment); tolua_function(tolua_S,"setTextColor",lua_cocos2dx_Label_setTextColor); + tolua_function(tolua_S,"getLetter",lua_cocos2dx_Label_getLetter); tolua_function(tolua_S,"setHeight",lua_cocos2dx_Label_setHeight); tolua_function(tolua_S,"getWidth",lua_cocos2dx_Label_getWidth); tolua_function(tolua_S,"enableGlow",lua_cocos2dx_Label_enableGlow); - tolua_function(tolua_S,"getLetter",lua_cocos2dx_Label_getLetter); + tolua_function(tolua_S,"getOverflow",lua_cocos2dx_Label_getOverflow); tolua_function(tolua_S,"setAdditionalKerning",lua_cocos2dx_Label_setAdditionalKerning); tolua_function(tolua_S,"getSystemFontSize",lua_cocos2dx_Label_getSystemFontSize); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_Label_setBlendFunc); tolua_function(tolua_S,"getTextAlignment",lua_cocos2dx_Label_getTextAlignment); tolua_function(tolua_S,"getBMFontFilePath",lua_cocos2dx_Label_getBMFontFilePath); tolua_function(tolua_S,"setHorizontalAlignment",lua_cocos2dx_Label_setHorizontalAlignment); + tolua_function(tolua_S,"isWrapEnabled",lua_cocos2dx_Label_isWrapEnabled); tolua_function(tolua_S,"setAlignment",lua_cocos2dx_Label_setAlignment); tolua_function(tolua_S,"requestSystemFontRefresh",lua_cocos2dx_Label_requestSystemFontRefresh); + tolua_function(tolua_S,"setBMFontSize",lua_cocos2dx_Label_setBMFontSize); tolua_function(tolua_S,"createWithBMFont", lua_cocos2dx_Label_createWithBMFont); tolua_function(tolua_S,"create", lua_cocos2dx_Label_create); tolua_function(tolua_S,"createWithCharMap", lua_cocos2dx_Label_createWithCharMap); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 9cc34867e0..74d55a4bac 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2146,6 +2146,12 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + + + From 150d90763653705e746b34397cc01e2020749cbf Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 27 Nov 2015 19:01:30 +0800 Subject: [PATCH 172/192] Add missing changes to Particle 3d --- cocos/renderer/CCTextureCache.cpp | 1 + .../Particle3D/PU/CCPUBillboardChain.cpp | 29 +++++++++++++++-- extensions/Particle3D/PU/CCPUBillboardChain.h | 4 +++ extensions/Particle3D/PU/CCPURender.cpp | 32 ++++++++++++++++--- extensions/Particle3D/PU/CCPURender.h | 1 + 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index 89c70188ba..5269413eb3 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -59,6 +59,7 @@ TextureCache::TextureCache() : _loadingThread(nullptr) , _needQuit(false) , _asyncRefCount(0) +, _dirty(false) { } diff --git a/extensions/Particle3D/PU/CCPUBillboardChain.cpp b/extensions/Particle3D/PU/CCPUBillboardChain.cpp index 0009830a65..56a6860ebf 100644 --- a/extensions/Particle3D/PU/CCPUBillboardChain.cpp +++ b/extensions/Particle3D/PU/CCPUBillboardChain.cpp @@ -76,7 +76,8 @@ PUBillboardChain::PUBillboardChain(const std::string& name, const std::string &t _texture(nullptr), _glProgramState(nullptr), _indexBuffer(nullptr), - _vertexBuffer(nullptr) + _vertexBuffer(nullptr), + _texFile(texFile) { _stateBlock = RenderState::StateBlock::create(); @@ -695,7 +696,7 @@ void PUBillboardChain::render( Renderer* renderer, const Mat4 &transform, Partic updateIndexBuffer(); if (!_vertices.empty() && !_indices.empty()) { - GLuint texId = (_texture ? _texture->getName() : 0); + GLuint texId = this->getTextureName(); _stateBlock->setBlendFunc(particleSystem->getBlendFunc()); _meshCommand->init(0, texId, @@ -731,6 +732,30 @@ void PUBillboardChain::setBlendFunc(const BlendFunc& blendFunc) _stateBlock->setBlendFunc(blendFunc); } +GLuint PUBillboardChain::getTextureName() +{ + if (TextureCache::getInstance()->isDirty()) + { + if (TextureCache::getInstance()->getTextureForKey(_texFile) == nullptr) + { + _texture = nullptr; + this->init(""); + } + else + this->init(_texFile); + } + else if (_texture != nullptr && !_texture->isValid()) + { + _texture = nullptr; + this->init(""); + } + + if (_texture == nullptr) + return 0; + + return _texture->getName(); +} + //----------------------------------------------------------------------- //void PUBillboardChain::_updateRenderQueue(RenderQueue* queue) //{ diff --git a/extensions/Particle3D/PU/CCPUBillboardChain.h b/extensions/Particle3D/PU/CCPUBillboardChain.h index 1fd9295f8a..d97b61b984 100644 --- a/extensions/Particle3D/PU/CCPUBillboardChain.h +++ b/extensions/Particle3D/PU/CCPUBillboardChain.h @@ -234,6 +234,8 @@ public: //void getWorldTransforms(Matrix4*) const; /// @copydoc MovableObject::visitRenderables + GLuint getTextureName(); + protected: /// Setup the STL collections @@ -324,6 +326,8 @@ protected: std::vector _vertices; std::vector _indices; + + std::string _texFile; }; NS_CC_END diff --git a/extensions/Particle3D/PU/CCPURender.cpp b/extensions/Particle3D/PU/CCPURender.cpp index f5f79632b3..51dd172f83 100644 --- a/extensions/Particle3D/PU/CCPURender.cpp +++ b/extensions/Particle3D/PU/CCPURender.cpp @@ -58,6 +58,7 @@ PUParticle3DQuadRender* PUParticle3DQuadRender::create(const std::string& texFil auto ret = new (std::nothrow) PUParticle3DQuadRender(); if (ret && ret->initRender(texFile)) { + ret->_texFile = texFile; ret->autorelease(); } else @@ -243,7 +244,7 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, P _stateBlock->setBlendFunc(particleSystem->getBlendFunc()); - GLuint texId = (_texture ? _texture->getName() : 0); + GLuint texId = this->getTextureName(); _meshCommand->init(0, texId, _glProgramState, @@ -561,7 +562,6 @@ bool PUParticle3DEntityRender::initRender( const std::string &texFile ) if (tex) { _texture = tex; - _texFile = texFile; glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_PARTICLE_TEXTURE); } } @@ -587,6 +587,30 @@ bool PUParticle3DEntityRender::initRender( const std::string &texFile ) return true; } +GLuint PUParticle3DEntityRender::getTextureName() +{ + if (TextureCache::getInstance()->isDirty()) + { + if (TextureCache::getInstance()->getTextureForKey(_texFile) == nullptr) + { + _texture = nullptr; + this->initRender(""); + } + else + this->initRender(_texFile); + } + else if (_texture != nullptr && !_texture->isValid()) + { + _texture = nullptr; + this->initRender(""); + } + + if (_texture == nullptr) + return 0; + + return _texture->getName(); +} + void PUParticle3DEntityRender::copyAttributesTo(PUParticle3DEntityRender *render) { PURender::copyAttributesTo(render); @@ -701,7 +725,7 @@ void PUParticle3DBoxRender::render( Renderer* renderer, const Mat4 &transform, P _vertexBuffer->updateVertices(&_vertices[0], vertexindex/* * sizeof(_posuvcolors[0])*/, 0); _indexBuffer->updateIndices(&_indices[0], index/* * sizeof(unsigned short)*/, 0); - GLuint texId = (_texture ? _texture->getName() : 0); + GLuint texId = this->getTextureName(); _stateBlock->setBlendFunc(_particleSystem->getBlendFunc()); _meshCommand->init(0, texId, @@ -865,7 +889,7 @@ void PUSphereRender::render( Renderer* renderer, const Mat4 &transform, Particle _vertexBuffer->updateVertices(&_vertices[0], vertexindex/* * sizeof(_posuvcolors[0])*/, 0); _indexBuffer->updateIndices(&_indices[0], index/* * sizeof(unsigned short)*/, 0); - GLuint texId = (_texture ? _texture->getName() : 0); + GLuint texId = this->getTextureName(); _stateBlock->setBlendFunc(particleSystem->getBlendFunc()); _meshCommand->init( diff --git a/extensions/Particle3D/PU/CCPURender.h b/extensions/Particle3D/PU/CCPURender.h index f4600459d3..baf976c2b3 100644 --- a/extensions/Particle3D/PU/CCPURender.h +++ b/extensions/Particle3D/PU/CCPURender.h @@ -73,6 +73,7 @@ CC_CONSTRUCTOR_ACCESS: protected: bool initRender(const std::string &texFile); + GLuint getTextureName(); protected: From 6e0525156b8e6b54c1b0d755b7c4d32ab0ef0d84 Mon Sep 17 00:00:00 2001 From: PavlOm Date: Fri, 27 Nov 2015 23:33:20 +1000 Subject: [PATCH 173/192] no message --- cocos/2d/CCComponentContainer.cpp | 2 +- cocos/physics/CCPhysicsBody.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCComponentContainer.cpp b/cocos/2d/CCComponentContainer.cpp index 2ead55b2fd..3918cbfe4c 100644 --- a/cocos/2d/CCComponentContainer.cpp +++ b/cocos/2d/CCComponentContainer.cpp @@ -62,7 +62,7 @@ bool ComponentContainer::add(Component *com) if (_componentMap.find(componentName) != _componentMap.end()) { - CCASSERT(true, "ComponentContainer already have this kind of component"); + CCASSERT(false, "ComponentContainer already have this kind of component"); break; } _componentMap[componentName] = com; diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 81f10f84da..64de9a7b9d 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -76,6 +76,7 @@ PhysicsBody::PhysicsBody() , _recordScaleX(1.f) , _recordScaleY(1.f) { + _name = COMPONENT_NAME; } PhysicsBody::~PhysicsBody() From 43c68aa16bf4a5ac08e36a87045c7c3db8920d59 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 27 Nov 2015 18:27:08 +0800 Subject: [PATCH 174/192] Fix Chipmunk bindings issue --- build/cocos2d_tests.xcodeproj/project.pbxproj | 1 - .../js-bindings/manual/ScriptingCore.cpp | 2 +- .../chipmunk/js_bindings_chipmunk_manual.cpp | 156 ++++++------------ .../project.pbxproj | 1 - tools/bindings-generator | 2 +- 5 files changed, 57 insertions(+), 105 deletions(-) diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 4fc63d72ae..7cd2fb0d3d 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -7149,7 +7149,6 @@ "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", - DEBUG, ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 4c71b1a6a4..5aea0a1e29 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -601,7 +601,7 @@ void ScriptingCore::createGlobalContext() { JS_SetErrorReporter(_cx, ScriptingCore::reportError); #if defined(JS_GC_ZEAL) && defined(DEBUG) - //JS_SetGCZeal(this->_cx, 2, JS_DEFAULT_ZEAL_FREQ); + JS_SetGCZeal(this->_cx, 2, JS_DEFAULT_ZEAL_FREQ); #endif _global.construct(_cx); diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp index 659c1437ec..936430eff6 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -762,11 +762,11 @@ struct collision_handler { cpCollisionType typeA; cpCollisionType typeB; - JS::Heap begin; - JS::Heap pre; - JS::Heap post; - JS::Heap separate; - JS::Heap jsthis; + mozilla::Maybe begin; + mozilla::Maybe pre; + mozilla::Maybe post; + mozilla::Maybe separate; + mozilla::Maybe jsthis; JSContext *cx; // "owner" of the collision handler @@ -777,6 +777,16 @@ struct collision_handler { unsigned int is_oo; // Objected oriented API ? UT_hash_handle hh; + + collision_handler() + { + JSContext *globalcx = ScriptingCore::getInstance()->getGlobalContext(); + begin.construct(globalcx); + pre.construct(globalcx); + post.construct(globalcx); + separate.construct(globalcx); + jsthis.construct(globalcx); + } }; // hash @@ -803,16 +813,16 @@ static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data) args[0] = c_class_to_jsval(handler->cx, arb, arbiterProto, JSB_cpArbiter_class, "cpArbiter"); args[1] = c_class_to_jsval(handler->cx, space, spaceProto, JSB_cpSpace_class, "cpArbiter"); } else { - args[0] = opaque_to_jsval( handler->cx, arb); - args[1] = opaque_to_jsval( handler->cx, space ); + args[0] = opaque_to_jsval(handler->cx, arb); + args[1] = opaque_to_jsval(handler->cx, space ); } JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(handler->cx); - JS::RootedObject jsthis(handler->cx, handler->jsthis); - JS::RootedValue jsbegin(handler->cx, OBJECT_TO_JSVAL(handler->begin)); - bool ok = JS_CallFunctionValue( handler->cx, jsthis, jsbegin, JS::HandleValueArray::fromMarkedLocation(2, args), &rval); + JS::RootedObject jsthis(handler->cx, handler->jsthis.ref()); + JS::RootedValue jsbegin(handler->cx, OBJECT_TO_JSVAL(handler->begin.ref())); + bool ok = JS_CallFunctionValue(handler->cx, jsthis, jsbegin, JS::HandleValueArray::fromMarkedLocation(2, args), &rval); JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin"); if( rval.isBoolean() ) { @@ -840,8 +850,8 @@ static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data) JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(handler->cx); - JS::RootedObject jsthis(handler->cx, handler->jsthis); - JS::RootedValue jspre(handler->cx, OBJECT_TO_JSVAL(handler->pre)); + JS::RootedObject jsthis(handler->cx, handler->jsthis.ref()); + JS::RootedValue jspre(handler->cx, OBJECT_TO_JSVAL(handler->pre.ref())); bool ok = JS_CallFunctionValue( handler->cx, jsthis, jspre, JS::HandleValueArray::fromMarkedLocation(2, args), &rval); JSB_PRECONDITION2(ok, handler->cx, false, "Error calling collision callback: pre"); @@ -871,8 +881,8 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue ignore(handler->cx); - JS::RootedObject jsthis(handler->cx, handler->jsthis); - JS::RootedValue jspost(handler->cx, OBJECT_TO_JSVAL(handler->post)); + JS::RootedObject jsthis(handler->cx, handler->jsthis.ref()); + JS::RootedValue jspost(handler->cx, OBJECT_TO_JSVAL(handler->post.ref())); bool ok = JS_CallFunctionValue( handler->cx, jsthis, jspost, JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post"); } @@ -897,8 +907,8 @@ static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data) JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue ignore(handler->cx); - JS::RootedObject jsthis(handler->cx, handler->jsthis); - JS::RootedValue jssep(handler->cx, OBJECT_TO_JSVAL(handler->separate)); + JS::RootedObject jsthis(handler->cx, handler->jsthis.ref()); + JS::RootedValue jssep(handler->cx, OBJECT_TO_JSVAL(handler->separate.ref())); bool ok = JS_CallFunctionValue( handler->cx, jsthis, jssep, JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");} @@ -920,22 +930,8 @@ void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis) struct collision_handler *current = nullptr, *tmp = nullptr; HASH_ITER(hh, collision_handler_hash, current, tmp) { if( current->space == space ) { - - JSContext *cx = current->cx; - - // unroot it - if( current->begin ) { - JS::RemoveObjectRoot(cx, ¤t->begin); - } - if( current->pre ) - JS::RemoveObjectRoot(cx, ¤t->pre); - if( current->post ) - JS::RemoveObjectRoot(cx, ¤t->post); - if( current->separate ) - JS::RemoveObjectRoot(cx, ¤t->separate); - HASH_DEL(collision_handler_hash,current); /* delete; users advances to next */ - free(current); /* optional- if you want to free */ + delete current; /* optional- if you want to free */ } } @@ -953,13 +949,15 @@ void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis) #pragma mark addCollisionHandler static -bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space, unsigned int is_oo) +bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, JS::HandleObject jsspace, cpSpace *space, unsigned int is_oo) { - struct collision_handler *handler = (struct collision_handler*) malloc( sizeof(*handler) ); + struct collision_handler *handler = new collision_handler(); handler->typeA = 0; handler->typeB = 0; JSB_PRECONDITION(handler, "Error allocating memory"); + + handler->jsthis.ref() = jsspace; bool ok = true; @@ -969,40 +967,28 @@ bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, c ok &= jsval_to_int(cx, jstypeA, (int32_t*) &handler->typeA ); ok &= jsval_to_int(cx, jstypeB, (int32_t*) &handler->typeB ); - handler->begin = argvp->toObjectOrNull(); + handler->begin.ref() = argvp->toObjectOrNull(); argvp++; - handler->pre = argvp->toObjectOrNull(); + handler->pre.ref() = argvp->toObjectOrNull(); argvp++; - handler->post = argvp->toObjectOrNull(); + handler->post.ref() = argvp->toObjectOrNull(); argvp++; - handler->separate = argvp->toObjectOrNull(); + handler->separate.ref() = argvp->toObjectOrNull(); argvp++; JSB_PRECONDITION(ok, "Error parsing arguments"); // Object Oriented API ? handler->is_oo = is_oo; - // owner of the collision handler handler->space = space; - - // Root it - if( handler->begin ) - JS::AddNamedObjectRoot(cx, &handler->begin, "begin collision_handler"); - if( handler->pre ) - JS::AddNamedObjectRoot(cx, &handler->pre, "pre collision_handler"); - if( handler->post ) - JS::AddNamedObjectRoot(cx, &handler->post, "post collision_handler"); - if( handler->separate ) - JS::AddNamedObjectRoot(cx, &handler->separate, "separate collision_handler"); - handler->cx = cx; cpSpaceAddCollisionHandler(space, handler->typeA, handler->typeB, - !handler->begin ? NULL : &myCollisionBegin, - !handler->pre ? NULL : &myCollisionPre, - !handler->post ? NULL : &myCollisionPost, - !handler->separate ? NULL : &myCollisionSeparate, + !handler->begin.ref() ? NULL : &myCollisionBegin, + !handler->pre.ref() ? NULL : &myCollisionPre, + !handler->post.ref() ? NULL : &myCollisionPost, + !handler->separate.ref() ? NULL : &myCollisionSeparate, handler ); @@ -1015,7 +1001,7 @@ bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, c HASH_FIND_INT(collision_handler_hash, &paired_key, hashElement); if( hashElement ) { HASH_DEL( collision_handler_hash, hashElement ); - free( hashElement ); + delete hashElement; } handler->hash_key = paired_key; @@ -1037,7 +1023,8 @@ bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) bool ok = jsval_to_opaque(cx, jsarg, (void**)&space); JSB_PRECONDITION(ok, "Error parsing arguments"); - return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0); + JS::RootedObject jsspace(cx, jsarg.toObjectOrNull()); + return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, jsspace, space, 0); } // method @@ -1050,7 +1037,7 @@ bool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; - return __jsb_cpSpace_addCollisionHandler(cx, vp, args.array(), (cpSpace*)handle, 1); + return __jsb_cpSpace_addCollisionHandler(cx, vp, args.array(), jsthis, (cpSpace*)handle, 1); } bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) @@ -1061,30 +1048,28 @@ bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* space = (cpSpace*) proxy->handle; - collision_handler *handler = (collision_handler*) malloc( sizeof(collision_handler) ); + collision_handler *handler = new collision_handler(); JSB_PRECONDITION(handler, "Error allocating memory"); handler->typeA = 0; handler->typeB = 0; - handler->jsthis = jsthis; - - handler->begin = args.get(0).toObjectOrNull(); - handler->pre = args.get(1).toObjectOrNull(); - handler->post = args.get(2).toObjectOrNull(); - handler->separate = args.get(3).toObjectOrNull(); + handler->jsthis.ref() = jsthis; + handler->begin.ref() = args.get(0).toObjectOrNull(); + handler->pre.ref() = args.get(1).toObjectOrNull(); + handler->post.ref() = args.get(2).toObjectOrNull(); + handler->separate.ref() = args.get(3).toObjectOrNull(); // Object Oriented API ? handler->is_oo = 1; - // owner of the collision handler handler->space = space; handler->cx = cx; cpSpaceSetDefaultCollisionHandler(space, - !handler->begin ? NULL : &myCollisionBegin, - !handler->pre ? NULL : &myCollisionPre, - !handler->post ? NULL : &myCollisionPost, - !handler->separate ? NULL : &myCollisionSeparate, + !handler->begin.ref() ? NULL : &myCollisionBegin, + !handler->pre.ref() ? NULL : &myCollisionPre, + !handler->post.ref() ? NULL : &myCollisionPost, + !handler->separate.ref() ? NULL : &myCollisionSeparate, handler ); // @@ -1095,34 +1080,14 @@ bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval unsigned long paired_key = pair_ints(handler->typeA, handler->typeB ); HASH_FIND_INT(collision_handler_hash, &paired_key, hashElement); if( hashElement ) { - if( hashElement->begin ) { - JS::RemoveObjectRoot(cx, &hashElement->begin); - } - if( hashElement->pre ) - JS::RemoveObjectRoot(cx, &hashElement->pre); - if( hashElement->post ) - JS::RemoveObjectRoot(cx, &hashElement->post); - if( hashElement->separate ) - JS::RemoveObjectRoot(cx, &hashElement->separate); HASH_DEL( collision_handler_hash, hashElement ); - free( hashElement ); + delete hashElement; } handler->hash_key = paired_key; HASH_ADD_INT( collision_handler_hash, hash_key, handler ); - // Root it - if( handler->begin ) - JS::AddNamedObjectRoot(cx, &handler->begin, "begin collision_handler"); - if( handler->pre ) - JS::AddNamedObjectRoot(cx, &handler->pre, "pre collision_handler"); - if( handler->post ) - JS::AddNamedObjectRoot(cx, &handler->post, "post collision_handler"); - if( handler->separate ) - JS::AddNamedObjectRoot(cx, &handler->separate, "separate collision_handler"); - args.rval().setUndefined(); - return true; } @@ -1149,19 +1114,8 @@ bool __jsb_cpSpace_removeCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp unsigned long key = pair_ints(typeA, typeB ); HASH_FIND_INT(collision_handler_hash, &key, hashElement); if( hashElement ) { - - // unroot it - if( hashElement->begin ) - JS::RemoveObjectRoot(cx, &hashElement->begin); - if( hashElement->pre ) - JS::RemoveObjectRoot(cx, &hashElement->pre); - if( hashElement->post ) - JS::RemoveObjectRoot(cx, &hashElement->post); - if( hashElement->separate ) - JS::RemoveObjectRoot(cx, &hashElement->separate); - HASH_DEL( collision_handler_hash, hashElement ); - free( hashElement ); + delete hashElement; } return true; diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index 29753b4cbf..ab0bc1f418 100644 --- a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -903,7 +903,6 @@ "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", - DEBUG, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; diff --git a/tools/bindings-generator b/tools/bindings-generator index 3dd232b790..250673608e 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 3dd232b790e85b2cc4a0a0a0e2fb1fc103f57249 +Subproject commit 250673608e23c9644b96a8e9ef886ab4db96aaf7 From 5e02b7f20a66f7a4e40dc207e1fa869859b3b72f Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Sat, 28 Nov 2015 14:28:44 +0800 Subject: [PATCH 175/192] Update CHANGELOG --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c2dc465d84..a662f1b716 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,7 +9,8 @@ cocos2d-x-3.10 December ? 2015 [REFINE] UI: Rewrite Scale9Sprite and improve the scale9sprite performance and reduce memory consumption. [REFINE] 3D: Change char* to string in Terrain. [REFINE] Editor: Merge Studio ActionTimeLine change back into engine. -[REFINe] Mac: Make engine compatible for 32bit Mac. +[REFINE] Mac: Make engine compatible for 32bit Mac. +[REFINE] Audio: AudioEngine on Linux replace the original simple AudioEngine with a new version of FMOD. [FIX] Core: Fix premultiplyAlpha for mipmaps and compressed textures. [FIX] UI: Fix Scale9sprite rendering error when content size smaller than the sum of leftInset and rightInset. From 3510228659b5b2a0be9e5b0f448ac9af96185402 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sat, 28 Nov 2015 06:29:01 +0000 Subject: [PATCH 176/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 47 ++++++++++++++--------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 4a42163666..eea90890f9 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -20,7 +20,7 @@ "cmake/Modules/CocosUsePrebuiltLibs.cmake", "cmake/Modules/FindCURL.cmake", "cmake/Modules/FindChipmunk.cmake", - "cmake/Modules/FindFMODEX.cmake", + "cmake/Modules/FindFMOD.cmake", "cmake/Modules/FindFontconfig.cmake", "cmake/Modules/FindFreetype.cmake", "cmake/Modules/FindGLFW3.cmake", @@ -289,10 +289,9 @@ "cocos/audio/ios/SimpleAudioEngine.mm", "cocos/audio/ios/SimpleAudioEngine_objc.h", "cocos/audio/ios/SimpleAudioEngine_objc.m", - "cocos/audio/linux/AudioPlayer.h", - "cocos/audio/linux/FmodAudioPlayer.cpp", - "cocos/audio/linux/FmodAudioPlayer.h", - "cocos/audio/linux/SimpleAudioEngineFMOD.cpp", + "cocos/audio/linux/AudioEngine-linux.cpp", + "cocos/audio/linux/AudioEngine-linux.h", + "cocos/audio/linux/SimpleAudioEngine.cpp", "cocos/audio/mac/CDAudioManager.h", "cocos/audio/mac/CDAudioManager.m", "cocos/audio/mac/CDConfig.h", @@ -2344,6 +2343,8 @@ "external/curl/include/ios/curl/stdcheaders.h", "external/curl/include/ios/curl/typecheck-gcc.h", "external/curl/include/mac/curl/curl.h", + "external/curl/include/mac/curl/curlbuild-32.h", + "external/curl/include/mac/curl/curlbuild-64.h", "external/curl/include/mac/curl/curlbuild.h", "external/curl/include/mac/curl/curlrules.h", "external/curl/include/mac/curl/curlver.h", @@ -2973,30 +2974,18 @@ "external/json/reader.h", "external/json/stringbuffer.h", "external/json/writer.h", - "external/linux-specific/fmod/include/32-bit/fmod.h", - "external/linux-specific/fmod/include/32-bit/fmod.hpp", - "external/linux-specific/fmod/include/32-bit/fmod_codec.h", - "external/linux-specific/fmod/include/32-bit/fmod_dsp.h", - "external/linux-specific/fmod/include/32-bit/fmod_errors.h", - "external/linux-specific/fmod/include/32-bit/fmod_memoryinfo.h", - "external/linux-specific/fmod/include/32-bit/fmod_output.h", - "external/linux-specific/fmod/include/32-bit/fmodlinux.h", - "external/linux-specific/fmod/include/64-bit/fmod.h", - "external/linux-specific/fmod/include/64-bit/fmod.hpp", - "external/linux-specific/fmod/include/64-bit/fmod_codec.h", - "external/linux-specific/fmod/include/64-bit/fmod_dsp.h", - "external/linux-specific/fmod/include/64-bit/fmod_errors.h", - "external/linux-specific/fmod/include/64-bit/fmod_memoryinfo.h", - "external/linux-specific/fmod/include/64-bit/fmod_output.h", - "external/linux-specific/fmod/include/64-bit/fmodlinux.h", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodex-4.36.01.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodex.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodexL-4.36.01.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodexL.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodex64-4.38.00.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodex64.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodexL64-4.38.00.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodexL64.so", + "external/linux-specific/fmod/include/fmod.h", + "external/linux-specific/fmod/include/fmod.hpp", + "external/linux-specific/fmod/include/fmod_codec.h", + "external/linux-specific/fmod/include/fmod_common.h", + "external/linux-specific/fmod/include/fmod_dsp.h", + "external/linux-specific/fmod/include/fmod_dsp_effects.h", + "external/linux-specific/fmod/include/fmod_errors.h", + "external/linux-specific/fmod/include/fmod_output.h", + "external/linux-specific/fmod/prebuilt/32-bit/libfmod.so", + "external/linux-specific/fmod/prebuilt/32-bit/libfmodL.so", + "external/linux-specific/fmod/prebuilt/64-bit/libfmod.so", + "external/linux-specific/fmod/prebuilt/64-bit/libfmodL.so", "external/png/include/android/png.h", "external/png/include/android/pngconf.h", "external/png/include/android/pnglibconf.h", From 4fbe8a62bf9de5c0c3f483cb2f3d0bcfe0064a82 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Sat, 28 Nov 2015 14:29:40 +0800 Subject: [PATCH 177/192] Update CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a662f1b716..da54434abb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,7 +10,7 @@ cocos2d-x-3.10 December ? 2015 [REFINE] 3D: Change char* to string in Terrain. [REFINE] Editor: Merge Studio ActionTimeLine change back into engine. [REFINE] Mac: Make engine compatible for 32bit Mac. -[REFINE] Audio: AudioEngine on Linux replace the original simple AudioEngine with a new version of FMOD. +[REFINE] Audio: AudioEngine on Linux replace the original SimpleAudioEngine with a new version of FMOD, now AudioEngine support all platforms! [FIX] Core: Fix premultiplyAlpha for mipmaps and compressed textures. [FIX] UI: Fix Scale9sprite rendering error when content size smaller than the sum of leftInset and rightInset. From a839e8d3074f87607c0295d40928564dc5cf1b04 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sat, 28 Nov 2015 06:30:10 +0000 Subject: [PATCH 178/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 47 ++++++++++++++--------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 4a42163666..eea90890f9 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -20,7 +20,7 @@ "cmake/Modules/CocosUsePrebuiltLibs.cmake", "cmake/Modules/FindCURL.cmake", "cmake/Modules/FindChipmunk.cmake", - "cmake/Modules/FindFMODEX.cmake", + "cmake/Modules/FindFMOD.cmake", "cmake/Modules/FindFontconfig.cmake", "cmake/Modules/FindFreetype.cmake", "cmake/Modules/FindGLFW3.cmake", @@ -289,10 +289,9 @@ "cocos/audio/ios/SimpleAudioEngine.mm", "cocos/audio/ios/SimpleAudioEngine_objc.h", "cocos/audio/ios/SimpleAudioEngine_objc.m", - "cocos/audio/linux/AudioPlayer.h", - "cocos/audio/linux/FmodAudioPlayer.cpp", - "cocos/audio/linux/FmodAudioPlayer.h", - "cocos/audio/linux/SimpleAudioEngineFMOD.cpp", + "cocos/audio/linux/AudioEngine-linux.cpp", + "cocos/audio/linux/AudioEngine-linux.h", + "cocos/audio/linux/SimpleAudioEngine.cpp", "cocos/audio/mac/CDAudioManager.h", "cocos/audio/mac/CDAudioManager.m", "cocos/audio/mac/CDConfig.h", @@ -2344,6 +2343,8 @@ "external/curl/include/ios/curl/stdcheaders.h", "external/curl/include/ios/curl/typecheck-gcc.h", "external/curl/include/mac/curl/curl.h", + "external/curl/include/mac/curl/curlbuild-32.h", + "external/curl/include/mac/curl/curlbuild-64.h", "external/curl/include/mac/curl/curlbuild.h", "external/curl/include/mac/curl/curlrules.h", "external/curl/include/mac/curl/curlver.h", @@ -2973,30 +2974,18 @@ "external/json/reader.h", "external/json/stringbuffer.h", "external/json/writer.h", - "external/linux-specific/fmod/include/32-bit/fmod.h", - "external/linux-specific/fmod/include/32-bit/fmod.hpp", - "external/linux-specific/fmod/include/32-bit/fmod_codec.h", - "external/linux-specific/fmod/include/32-bit/fmod_dsp.h", - "external/linux-specific/fmod/include/32-bit/fmod_errors.h", - "external/linux-specific/fmod/include/32-bit/fmod_memoryinfo.h", - "external/linux-specific/fmod/include/32-bit/fmod_output.h", - "external/linux-specific/fmod/include/32-bit/fmodlinux.h", - "external/linux-specific/fmod/include/64-bit/fmod.h", - "external/linux-specific/fmod/include/64-bit/fmod.hpp", - "external/linux-specific/fmod/include/64-bit/fmod_codec.h", - "external/linux-specific/fmod/include/64-bit/fmod_dsp.h", - "external/linux-specific/fmod/include/64-bit/fmod_errors.h", - "external/linux-specific/fmod/include/64-bit/fmod_memoryinfo.h", - "external/linux-specific/fmod/include/64-bit/fmod_output.h", - "external/linux-specific/fmod/include/64-bit/fmodlinux.h", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodex-4.36.01.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodex.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodexL-4.36.01.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodexL.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodex64-4.38.00.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodex64.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodexL64-4.38.00.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodexL64.so", + "external/linux-specific/fmod/include/fmod.h", + "external/linux-specific/fmod/include/fmod.hpp", + "external/linux-specific/fmod/include/fmod_codec.h", + "external/linux-specific/fmod/include/fmod_common.h", + "external/linux-specific/fmod/include/fmod_dsp.h", + "external/linux-specific/fmod/include/fmod_dsp_effects.h", + "external/linux-specific/fmod/include/fmod_errors.h", + "external/linux-specific/fmod/include/fmod_output.h", + "external/linux-specific/fmod/prebuilt/32-bit/libfmod.so", + "external/linux-specific/fmod/prebuilt/32-bit/libfmodL.so", + "external/linux-specific/fmod/prebuilt/64-bit/libfmod.so", + "external/linux-specific/fmod/prebuilt/64-bit/libfmodL.so", "external/png/include/android/png.h", "external/png/include/android/pngconf.h", "external/png/include/android/pnglibconf.h", From 467177f45c12d99888d63b4d390fda06dde7dff9 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sat, 28 Nov 2015 06:31:21 +0000 Subject: [PATCH 179/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 47 ++++++++++++++--------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 4a42163666..eea90890f9 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -20,7 +20,7 @@ "cmake/Modules/CocosUsePrebuiltLibs.cmake", "cmake/Modules/FindCURL.cmake", "cmake/Modules/FindChipmunk.cmake", - "cmake/Modules/FindFMODEX.cmake", + "cmake/Modules/FindFMOD.cmake", "cmake/Modules/FindFontconfig.cmake", "cmake/Modules/FindFreetype.cmake", "cmake/Modules/FindGLFW3.cmake", @@ -289,10 +289,9 @@ "cocos/audio/ios/SimpleAudioEngine.mm", "cocos/audio/ios/SimpleAudioEngine_objc.h", "cocos/audio/ios/SimpleAudioEngine_objc.m", - "cocos/audio/linux/AudioPlayer.h", - "cocos/audio/linux/FmodAudioPlayer.cpp", - "cocos/audio/linux/FmodAudioPlayer.h", - "cocos/audio/linux/SimpleAudioEngineFMOD.cpp", + "cocos/audio/linux/AudioEngine-linux.cpp", + "cocos/audio/linux/AudioEngine-linux.h", + "cocos/audio/linux/SimpleAudioEngine.cpp", "cocos/audio/mac/CDAudioManager.h", "cocos/audio/mac/CDAudioManager.m", "cocos/audio/mac/CDConfig.h", @@ -2344,6 +2343,8 @@ "external/curl/include/ios/curl/stdcheaders.h", "external/curl/include/ios/curl/typecheck-gcc.h", "external/curl/include/mac/curl/curl.h", + "external/curl/include/mac/curl/curlbuild-32.h", + "external/curl/include/mac/curl/curlbuild-64.h", "external/curl/include/mac/curl/curlbuild.h", "external/curl/include/mac/curl/curlrules.h", "external/curl/include/mac/curl/curlver.h", @@ -2973,30 +2974,18 @@ "external/json/reader.h", "external/json/stringbuffer.h", "external/json/writer.h", - "external/linux-specific/fmod/include/32-bit/fmod.h", - "external/linux-specific/fmod/include/32-bit/fmod.hpp", - "external/linux-specific/fmod/include/32-bit/fmod_codec.h", - "external/linux-specific/fmod/include/32-bit/fmod_dsp.h", - "external/linux-specific/fmod/include/32-bit/fmod_errors.h", - "external/linux-specific/fmod/include/32-bit/fmod_memoryinfo.h", - "external/linux-specific/fmod/include/32-bit/fmod_output.h", - "external/linux-specific/fmod/include/32-bit/fmodlinux.h", - "external/linux-specific/fmod/include/64-bit/fmod.h", - "external/linux-specific/fmod/include/64-bit/fmod.hpp", - "external/linux-specific/fmod/include/64-bit/fmod_codec.h", - "external/linux-specific/fmod/include/64-bit/fmod_dsp.h", - "external/linux-specific/fmod/include/64-bit/fmod_errors.h", - "external/linux-specific/fmod/include/64-bit/fmod_memoryinfo.h", - "external/linux-specific/fmod/include/64-bit/fmod_output.h", - "external/linux-specific/fmod/include/64-bit/fmodlinux.h", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodex-4.36.01.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodex.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodexL-4.36.01.so", - "external/linux-specific/fmod/prebuilt/32-bit/libfmodexL.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodex64-4.38.00.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodex64.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodexL64-4.38.00.so", - "external/linux-specific/fmod/prebuilt/64-bit/libfmodexL64.so", + "external/linux-specific/fmod/include/fmod.h", + "external/linux-specific/fmod/include/fmod.hpp", + "external/linux-specific/fmod/include/fmod_codec.h", + "external/linux-specific/fmod/include/fmod_common.h", + "external/linux-specific/fmod/include/fmod_dsp.h", + "external/linux-specific/fmod/include/fmod_dsp_effects.h", + "external/linux-specific/fmod/include/fmod_errors.h", + "external/linux-specific/fmod/include/fmod_output.h", + "external/linux-specific/fmod/prebuilt/32-bit/libfmod.so", + "external/linux-specific/fmod/prebuilt/32-bit/libfmodL.so", + "external/linux-specific/fmod/prebuilt/64-bit/libfmod.so", + "external/linux-specific/fmod/prebuilt/64-bit/libfmodL.so", "external/png/include/android/png.h", "external/png/include/android/pngconf.h", "external/png/include/android/pnglibconf.h", From 60624b8fd5dbfb63725fe7dd0209fd0720e08428 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Sat, 28 Nov 2015 15:37:58 +0800 Subject: [PATCH 180/192] fix Keyboard fails to hide on iOS. ticket: https://github.com/cocos2d/cocos2d-x/issues/14477 --- cocos/platform/ios/CCEAGLView-ios.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/platform/ios/CCEAGLView-ios.mm b/cocos/platform/ios/CCEAGLView-ios.mm index 334fd30e88..b35d39fd90 100644 --- a/cocos/platform/ios/CCEAGLView-ios.mm +++ b/cocos/platform/ios/CCEAGLView-ios.mm @@ -377,9 +377,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. for(UIView* view in subviews) { - if([view isKindOfClass:NSClassFromString(@"CCCustomUITextField")] || - [view isKindOfClass:NSClassFromString(@"CCUISingleLineTextField")] || - [view isKindOfClass:NSClassFromString(@"CCUIMultilineTextField")]) + if([view isKindOfClass:NSClassFromString(@"UITextView")] || + [view isKindOfClass:NSClassFromString(@"UITextField")]) { if ([view isFirstResponder]) { From e1751db19530d9ac32af70daa8e25ca4c08c798b Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Sat, 28 Nov 2015 15:41:42 +0800 Subject: [PATCH 181/192] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index da54434abb..5046e3c79b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ cocos2d-x-3.10 December ? 2015 [FIX] UI: Fix EditBox editBoxEditingDidEnd may use the original text after change the text of EditBox in user script. [FIX] Audio: Fix `FinishCallback` never be called in Windows. [FIX] UI: Fix Layout stencil clipping nested with Clipping Node rendering issue. +[FIX] UI: Keyboard doesn't hide when click the screen outside of EditBox on iOS platform. cocos2d-x-3.9 November.09 2015 From cbbfc69ad41cf307e53c4fe91ca9e6e022e7bee0 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 30 Nov 2015 11:19:02 +0800 Subject: [PATCH 182/192] Add missing studio change for Director::drawScene --- cocos/base/CCDirector.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 5df9c10929..ca55688779 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -328,6 +328,9 @@ void Director::drawScene() { calculateMPF(); } + + if (_textureCache != nullptr) + _textureCache->setDirty(false); } void Director::calculateDeltaTime() From e0349ae9756dfe1427ad92fe4304d17d961da1ed Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 30 Nov 2015 14:48:19 +0800 Subject: [PATCH 183/192] update sprite 3d test --- cocos/3d/CCMesh.cpp | 34 ++++++--- cocos/3d/CCMesh.h | 2 +- .../Classes/Sprite3DTest/Sprite3DTest.cpp | 70 +++++++++++++++++++ .../Classes/Sprite3DTest/Sprite3DTest.h | 16 +++++ 4 files changed, 112 insertions(+), 10 deletions(-) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 30d3547e02..2bf29c3d30 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -339,6 +339,7 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u if (isTransparent) flags |= Node::FLAGS_RENDER_AS_3D; + this->checkTexture(); _meshCommand.init(globalZ, _material, @@ -662,22 +663,37 @@ GLuint Mesh::getIndexBuffer() const return _meshIndexData->getIndexBuffer()->getVBO(); } -GLuint Mesh::getTextureName() +void Mesh::checkTexture() { + Texture2D* cacheTex = nullptr; if (TextureCache::getInstance()->isDirty()) { - Texture2D* cacheTex = TextureCache::getInstance()->getTextureForKey(_texFile); - _texture = cacheTex; + cacheTex = TextureCache::getInstance()->getTextureForKey(_texFile); + if (cacheTex == nullptr) + { + cacheTex = getDummyTexture(); + } } - - if (_texture == nullptr || !_texture->isValid()) + else if (_texture != nullptr && !_texture->isValid()) { - _texture = nullptr; - Texture2D* dummyTex = getDummyTexture(); - return dummyTex->getName(); + cacheTex = getDummyTexture(); } - return _texture->getName(); + if (cacheTex != nullptr && _texture != cacheTex) + { + CC_SAFE_RETAIN(cacheTex); + CC_SAFE_RELEASE(_texture); + _texture = cacheTex; + + if (_material) { + auto technique = _material->_currentTechnique; + for (auto& pass : technique->_passes) + { + pass->setTexture(_texture); + } + } + bindMeshCommand(); + } } NS_CC_END diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index 964850e0e9..0338c906ad 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -194,7 +194,7 @@ public: */ void setForce2DQueue(bool force2D) { _force2DQueue = force2D; } - GLuint getTextureName(); + void checkTexture(); CC_CONSTRUCTOR_ACCESS: diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 27dfb2a546..c7a500aaec 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -67,6 +67,7 @@ Sprite3DTests::Sprite3DTests() ADD_TEST_CASE(CameraBackgroundClearTest); ADD_TEST_CASE(Sprite3DVertexColorTest); ADD_TEST_CASE(MotionStreak3DTest); + ADD_TEST_CASE(Sprite3DPropertyTest); }; //------------------------------------------------------------------ @@ -2512,3 +2513,72 @@ void MotionStreak3DTest::update(float delta) _streak->setPosition3D(_sprite->getPosition3D()); _streak->setSweepAxis(Vec3(cosf(angle), 0, sinf(angle))); } + +Sprite3DPropertyTest::Sprite3DPropertyTest() +{ + auto s = Director::getInstance()->getWinSize(); + + auto camera = Camera::createPerspective(40, s.width / s.height, 0.01f, 1000.f); + camera->setCameraFlag(CameraFlag::USER1); + camera->setPosition3D(Vec3(0.f, 50.f, 200.f)); + camera->lookAt(Vec3(0.f, 0.f, 0.f)); + addChild(camera); + + _sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + _sprite->setPosition(20.f, 0.f); + _sprite->setRotation3D(Vec3(0, 180, 0)); + _meshTex = _sprite->getMesh()->getTexture(); + addChild(_sprite); + + setCameraMask(2); + + //auto listener = EventListenerTouchAllAtOnce::create(); + ////listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DReskinTest::onTouchesEnded, this); + //_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); + + TTFConfig ttfConfig("fonts/arial.ttf", 20); + + auto label1 = Label::createWithTTF(ttfConfig, "Print Mesh Name"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(Sprite3DPropertyTest::printMeshName, this)); + auto label2 = Label::createWithTTF(ttfConfig, "Remove Used Texture"); + auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(Sprite3DPropertyTest::removeUsedTexture, this)); + + item1->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 4)); + item2->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 5)); + + auto pMenu1 = Menu::create(item1, item2, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); + + scheduleUpdate(); +} +std::string Sprite3DPropertyTest::title() const +{ + return "Sprite3DPropertyTest Test"; +} +std::string Sprite3DPropertyTest::subtitle() const +{ + return ""; +} + +void Sprite3DPropertyTest::update(float delta) +{ + +} +void Sprite3DPropertyTest::printMeshName(cocos2d::Ref* sender) +{ + CCLOG("MeshName Begin\n"); + Vector meshes =_sprite->getMeshes(); + for each (Mesh* mesh in meshes) + { + CCLOG("MeshName: %s \n", mesh->getName().c_str()); + } + CCLOG("MeshName End\n"); +} +void Sprite3DPropertyTest::removeUsedTexture(cocos2d::Ref* sender) +{ + if (_meshTex != nullptr) + { + TextureCache::getInstance()->removeTexture(_meshTex); + } +} \ No newline at end of file diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index f24691cd21..f8dbf0889c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -584,4 +584,20 @@ protected: cocos2d::MotionStreak3D* _streak; }; +class Sprite3DPropertyTest : public Sprite3DTestDemo +{ +public: + CREATE_FUNC(Sprite3DPropertyTest); + Sprite3DPropertyTest(); + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual void update(float delta) override; + + void printMeshName(cocos2d::Ref* sender); + void removeUsedTexture(cocos2d::Ref* sender); +protected: + cocos2d::Sprite3D* _sprite; + cocos2d::Texture2D* _meshTex; +}; + #endif From 4d379ed9bd18f75857eb822ad630fca1efa5aeb1 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 30 Nov 2015 14:53:37 +0800 Subject: [PATCH 184/192] revert ccplane --- cocos/3d/CCPlane.cpp | 13 ------------- cocos/3d/CCPlane.h | 5 ----- 2 files changed, 18 deletions(-) diff --git a/cocos/3d/CCPlane.cpp b/cocos/3d/CCPlane.cpp index 3fa0b7f8b9..722ed2e91d 100755 --- a/cocos/3d/CCPlane.cpp +++ b/cocos/3d/CCPlane.cpp @@ -92,17 +92,4 @@ PointSide Plane::getSide(const Vec3& point) const return PointSide::IN_PLANE; } -PointSide Plane::getSide(const Vec3& point, const Vec3& tolerance) const -{ - float dist = dist2Plane(point); - float maxAbsDist = fabs(_normal.x * tolerance.x) + fabs(_normal.y * tolerance.y) + fabs(_normal.z * tolerance.z); - - if (dist > maxAbsDist) - return PointSide::FRONT_PLANE; - else if (dist < -maxAbsDist) - return PointSide::BEHIND_PLANE; - else - return PointSide::IN_PLANE; -} - NS_CC_END diff --git a/cocos/3d/CCPlane.h b/cocos/3d/CCPlane.h index 87509b32f3..cc1baf822c 100755 --- a/cocos/3d/CCPlane.h +++ b/cocos/3d/CCPlane.h @@ -100,11 +100,6 @@ public: */ PointSide getSide(const Vec3& point) const; - /** - * Return the side where the point is. - */ - PointSide getSide(const Vec3& point, const Vec3& tolerance) const; - protected: Vec3 _normal; // the normal line of the plane float _dist; // original displacement of the normal From 17bdfb4050a2f3bcc46b650b891451ad481b388c Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 30 Nov 2015 15:20:57 +0800 Subject: [PATCH 185/192] Fix android compilation issue --- .../manual/platform/android/CCJavascriptJavaBridge.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp index 96f459af4d..8b65563ebf 100644 --- a/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp +++ b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp @@ -302,7 +302,9 @@ JS_BINDED_CONSTRUCTOR_IMPL(JavascriptJavaBridge) js_proxy_t *p; jsval out; - JSObject *obj = JS_NewObject(cx, &JavascriptJavaBridge::js_class, JS::RootedObject(cx, JavascriptJavaBridge::js_proto), JS::RootedObject(cx, JavascriptJavaBridge::js_parent)); + JS::RootedObject proto(cx, JavascriptJavaBridge::js_proto); + JS::RootedObject parentProto(cx, JavascriptJavaBridge::js_parent); + JS::RootedObject obj(cx, JS_NewObject(cx, &JavascriptJavaBridge::js_class, proto, parentProto)); if (obj) { JS_SetPrivate(obj, jsj); @@ -310,7 +312,7 @@ JS_BINDED_CONSTRUCTOR_IMPL(JavascriptJavaBridge) } args.rval().set(out); - p =jsb_new_proxy(jsj, obj); + p = jsb_new_proxy(jsj, obj); JS::AddNamedObjectRoot(cx, &p->obj, "JavascriptJavaBridge"); return true; From 34da2aabb2a6ee8a9090ab76441a8e6ab420ce0c Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 30 Nov 2015 17:34:49 +0800 Subject: [PATCH 186/192] fix compile error --- tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index c7a500aaec..98b6e87529 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -2567,13 +2567,13 @@ void Sprite3DPropertyTest::update(float delta) } void Sprite3DPropertyTest::printMeshName(cocos2d::Ref* sender) { - CCLOG("MeshName Begin\n"); + CCLOG("MeshName Begin"); Vector meshes =_sprite->getMeshes(); - for each (Mesh* mesh in meshes) + for(Mesh* mesh : meshes) { - CCLOG("MeshName: %s \n", mesh->getName().c_str()); + CCLOG("MeshName: %s ", mesh->getName().c_str()); } - CCLOG("MeshName End\n"); + CCLOG("MeshName End"); } void Sprite3DPropertyTest::removeUsedTexture(cocos2d::Ref* sender) { From 08837955a7c22a01d04a6b05c38b32f820dd9baf Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 30 Nov 2015 23:54:42 +0800 Subject: [PATCH 187/192] Skip Useless MenuItemToggle::initWithCallback to fix windows compilation issue --- tools/tojs/cocos2dx.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index d4981d6f76..8ac971c563 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -50,6 +50,7 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat Director::[getAccelerometer getProjection getFrustum getRenderer getConsole getCocos2dThreadId], Layer.*::[didAccelerate keyPressed keyReleased], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], + MenuItemToggle::[initWithCallback], Copying::[*], LabelProtocol::[*], LabelTextFormatProtocol::[*], From e891b03eeead17b805ca9d4ec12e7c1fe171a2f3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 1 Dec 2015 04:32:19 +0000 Subject: [PATCH 188/192] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 10 + .../auto/api/jsb_cocos2dx_ui_auto_api.js | 90 + .../js-bindings/auto/jsb_cocos2dx_3d_auto.cpp | 353 +- .../auto/jsb_cocos2dx_3d_extension_auto.cpp | 54 +- .../auto/jsb_cocos2dx_audioengine_auto.cpp | 76 +- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 7182 +++++------------ .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 1 + .../auto/jsb_cocos2dx_builder_auto.cpp | 126 +- .../jsb_cocos2dx_experimental_video_auto.cpp | 28 +- ...jsb_cocos2dx_experimental_webView_auto.cpp | 28 +- .../auto/jsb_cocos2dx_extension_auto.cpp | 576 +- .../auto/jsb_cocos2dx_navmesh_auto.cpp | 85 +- .../auto/jsb_cocos2dx_physics3d_auto.cpp | 378 +- .../auto/jsb_cocos2dx_spine_auto.cpp | 130 +- .../auto/jsb_cocos2dx_studio_auto.cpp | 1242 +-- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 1465 ++-- .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 9 + 17 files changed, 3820 insertions(+), 8013 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 6d0eca5575..7f5fbcb0f2 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -13513,6 +13513,16 @@ isSelected : function ( return false; }, +/** + * @method setCallback + * @param {function} arg0 + */ +setCallback : function ( +func +) +{ +}, + /** * @method unselected */ diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index a1ac1bd1b4..900ebe9f42 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -778,6 +778,16 @@ getCallbackType : function ( return ; }, +/** + * @method addTouchEventListener + * @param {function} arg0 + */ +addTouchEventListener : function ( +func +) +{ +}, + /** * @method getTouchEndPosition * @return {vec2_object} @@ -2007,6 +2017,16 @@ texturerestype */ ccui.CheckBox = { +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method create * @param {String|String} str @@ -2055,6 +2075,16 @@ CheckBox : function ( */ ccui.RadioButton = { +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method create * @param {String|String} str @@ -2153,6 +2183,16 @@ int { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method removeAllRadioButtons */ @@ -3117,6 +3157,16 @@ float { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method setScrollBarAutoHideTime * @param {float} arg0 @@ -3561,6 +3611,16 @@ bool { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method doLayout */ @@ -3899,6 +3959,16 @@ texturerestype { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method setMaxPercent * @param {int} arg0 @@ -4521,6 +4591,16 @@ textvalignment { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method didNotSelectSelf */ @@ -5001,6 +5081,16 @@ widget { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method setCurrentPageIndex * @param {long} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp index f5e50cb934..cb5b5f16bb 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -200,8 +200,8 @@ bool js_cocos2dx_3d_Animation3D_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -248,30 +248,17 @@ void js_register_cocos2dx_3d_Animation3D(JSContext *cx, JS::HandleObject global) jsb_cocos2d_Animation3D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Animation3D_class, js_cocos2dx_3d_Animation3D_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, "Animation3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Animation3D_class; - p->proto = jsb_cocos2d_Animation3D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animation3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Animation3D_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Animate3D_class; @@ -390,7 +377,7 @@ bool js_cocos2dx_3d_Animate3D_initWithFrames(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -454,7 +441,7 @@ bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_init : Invalid Native Object"); @@ -465,7 +452,7 @@ bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -492,7 +479,7 @@ bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -577,7 +564,7 @@ bool js_cocos2dx_3d_Animate3D_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -611,7 +598,7 @@ bool js_cocos2dx_3d_Animate3D_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -660,7 +647,7 @@ bool js_cocos2dx_3d_Animate3D_createWithFrames(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -690,7 +677,7 @@ bool js_cocos2dx_3d_Animate3D_createWithFrames(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -748,8 +735,8 @@ bool js_cocos2dx_3d_Animate3D_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -807,32 +794,20 @@ void js_register_cocos2dx_3d_Animate3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Animate3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Animate3D_class, js_cocos2dx_3d_Animate3D_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, "Animate3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Animate3D_class; - p->proto = jsb_cocos2d_Animate3D_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animate3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Animate3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_TextureCube_class; @@ -907,8 +882,8 @@ bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -952,32 +927,20 @@ void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Texture2D_prototype); jsb_cocos2d_TextureCube_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Texture2D_prototype), + parent_proto, jsb_cocos2d_TextureCube_class, js_cocos2dx_3d_TextureCube_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, "TextureCube", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TextureCube_class; - p->proto = jsb_cocos2d_TextureCube_prototype; - p->parentProto = jsb_cocos2d_Texture2D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TextureCube_prototype); + jsb_register_class(cx, jsb_cocos2d_TextureCube_class, proto, parent_proto); } JSClass *jsb_cocos2d_AttachNode_class; @@ -993,7 +956,7 @@ bool js_cocos2dx_3d_AttachNode_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1032,8 +995,8 @@ bool js_cocos2dx_3d_AttachNode_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1076,32 +1039,20 @@ void js_register_cocos2dx_3d_AttachNode(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_AttachNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_AttachNode_class, js_cocos2dx_3d_AttachNode_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, "AttachNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_AttachNode_class; - p->proto = jsb_cocos2d_AttachNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AttachNode_prototype); + jsb_register_class(cx, jsb_cocos2d_AttachNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_BillBoard_class; @@ -1288,7 +1239,7 @@ bool js_cocos2dx_3d_BillBoard_createWithTexture(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1314,7 +1265,7 @@ bool js_cocos2dx_3d_BillBoard_createWithTexture(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1354,8 +1305,8 @@ bool js_cocos2dx_3d_BillBoard_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1401,32 +1352,20 @@ void js_register_cocos2dx_3d_BillBoard(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite_prototype); jsb_cocos2d_BillBoard_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Sprite_prototype), + parent_proto, jsb_cocos2d_BillBoard_class, js_cocos2dx_3d_BillBoard_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, "BillBoard", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_BillBoard_class; - p->proto = jsb_cocos2d_BillBoard_prototype; - p->parentProto = jsb_cocos2d_Sprite_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BillBoard_prototype); + jsb_register_class(cx, jsb_cocos2d_BillBoard_class, proto, parent_proto); } JSClass *jsb_cocos2d_Mesh_class; @@ -1439,7 +1378,7 @@ bool js_cocos2dx_3d_Mesh_setTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setTexture : Invalid Native Object"); @@ -1450,7 +1389,7 @@ bool js_cocos2dx_3d_Mesh_setTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1583,7 +1522,7 @@ bool js_cocos2dx_3d_Mesh_setMaterial(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1809,7 +1748,7 @@ bool js_cocos2dx_3d_Mesh_setMeshIndexData(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MeshIndexData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1913,7 +1852,7 @@ bool js_cocos2dx_3d_Mesh_setSkin(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MeshSkin*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1977,7 +1916,7 @@ bool js_cocos2dx_3d_Mesh_setGLProgramState(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2027,8 +1966,8 @@ bool js_cocos2dx_3d_Mesh_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2094,30 +2033,17 @@ void js_register_cocos2dx_3d_Mesh(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Mesh_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Mesh_class, js_cocos2dx_3d_Mesh_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, "Mesh", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Mesh_class; - p->proto = jsb_cocos2d_Mesh_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Mesh_prototype); + jsb_register_class(cx, jsb_cocos2d_Mesh_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Skeleton3D_class; @@ -2153,7 +2079,7 @@ bool js_cocos2dx_3d_Skeleton3D_addBone(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2302,7 +2228,7 @@ bool js_cocos2dx_3d_Skeleton3D_getBoneIndex(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2352,8 +2278,8 @@ bool js_cocos2dx_3d_Skeleton3D_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2402,30 +2328,17 @@ void js_register_cocos2dx_3d_Skeleton3D(JSContext *cx, JS::HandleObject global) jsb_cocos2d_Skeleton3D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Skeleton3D_class, js_cocos2dx_3d_Skeleton3D_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, "Skeleton3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Skeleton3D_class; - p->proto = jsb_cocos2d_Skeleton3D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Skeleton3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Skeleton3D_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Skybox_class; @@ -2493,7 +2406,7 @@ bool js_cocos2dx_3d_Skybox_setTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2582,8 +2495,8 @@ bool js_cocos2dx_3d_Skybox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2629,32 +2542,20 @@ void js_register_cocos2dx_3d_Skybox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Skybox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Skybox_class, js_cocos2dx_3d_Skybox_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, "Skybox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Skybox_class; - p->proto = jsb_cocos2d_Skybox_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Skybox_prototype); + jsb_register_class(cx, jsb_cocos2d_Skybox_class, proto, parent_proto); } JSClass *jsb_cocos2d_Sprite3D_class; @@ -2687,7 +2588,7 @@ bool js_cocos2dx_3d_Sprite3D_setTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setTexture : Invalid Native Object"); @@ -2698,7 +2599,7 @@ bool js_cocos2dx_3d_Sprite3D_setTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2860,7 +2761,7 @@ bool js_cocos2dx_3d_Sprite3D_addMesh(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Mesh*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2897,7 +2798,7 @@ bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setMaterial : Invalid Native Object"); @@ -2908,7 +2809,7 @@ bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2930,7 +2831,7 @@ bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3088,7 +2989,7 @@ bool js_cocos2dx_3d_Sprite3D_createNode(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3555,8 +3456,8 @@ bool js_cocos2dx_3d_Sprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -3648,32 +3549,20 @@ void js_register_cocos2dx_3d_Sprite3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Sprite3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Sprite3D_class, js_cocos2dx_3d_Sprite3D_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, "Sprite3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Sprite3D_class; - p->proto = jsb_cocos2d_Sprite3D_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sprite3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Sprite3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { jsb.Sprite3D.extend = cc.Class.extend; })()"); } @@ -3785,30 +3674,17 @@ void js_register_cocos2dx_3d_Sprite3DCache(JSContext *cx, JS::HandleObject globa jsb_cocos2d_Sprite3DCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Sprite3DCache_class, empty_constructor, 0, 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, "Sprite3DCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Sprite3DCache_class; - p->proto = jsb_cocos2d_Sprite3DCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sprite3DCache_prototype); + jsb_register_class(cx, jsb_cocos2d_Sprite3DCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Terrain_class; @@ -3953,7 +3829,7 @@ bool js_cocos2dx_3d_Terrain_setAlphaMap(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4052,7 +3928,7 @@ bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getHeight : Invalid Native Object"); @@ -4079,7 +3955,7 @@ bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4122,7 +3998,7 @@ bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4212,7 +4088,7 @@ bool js_cocos2dx_3d_Terrain_getIntersectionPoint(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); @@ -4404,8 +4280,8 @@ bool js_cocos2dx_3d_Terrain_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -4468,32 +4344,20 @@ void js_register_cocos2dx_3d_Terrain(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Terrain_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Terrain_class, js_cocos2dx_3d_Terrain_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, "Terrain", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Terrain_class; - p->proto = jsb_cocos2d_Terrain_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Terrain_prototype); + jsb_register_class(cx, jsb_cocos2d_Terrain_class, proto, parent_proto); } JSClass *jsb_cocos2d_Bundle3D_class; @@ -4687,7 +4551,7 @@ bool js_cocos2dx_3d_Bundle3D_destroyBundle(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bundle3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4761,8 +4625,8 @@ bool js_cocos2dx_3d_Bundle3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -4777,7 +4641,9 @@ void js_cocos2d_Bundle3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Bundle3D)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; - jsproxy = jsb_get_js_proxy(obj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { cocos2d::Bundle3D *nobj = static_cast(jsproxy->ptr); nproxy = jsb_get_native_proxy(jsproxy->ptr); @@ -4827,30 +4693,17 @@ void js_register_cocos2dx_3d_Bundle3D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Bundle3D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Bundle3D_class, js_cocos2dx_3d_Bundle3D_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, "Bundle3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Bundle3D_class; - p->proto = jsb_cocos2d_Bundle3D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Bundle3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Bundle3D_class, proto, JS::NullPtr()); } void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp index d87d9dc80b..447025172b 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp @@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -312,8 +312,8 @@ bool js_cocos2dx_3d_extension_ParticleSystem3D_constructor(JSContext *cx, uint32 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -367,32 +367,20 @@ void js_register_cocos2dx_3d_extension_ParticleSystem3D(JSContext *cx, JS::Handl JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParticleSystem3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParticleSystem3D_class, js_cocos2dx_3d_extension_ParticleSystem3D_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, "ParticleSystem3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleSystem3D_class; - p->proto = jsb_cocos2d_ParticleSystem3D_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSystem3D_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSystem3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_PUParticleSystem3D_class; @@ -777,7 +765,7 @@ bool js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PUParticleSystem3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1145,8 +1133,8 @@ bool js_cocos2dx_3d_extension_PUParticleSystem3D_constructor(JSContext *cx, uint CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1223,32 +1211,20 @@ void js_register_cocos2dx_3d_extension_PUParticleSystem3D(JSContext *cx, JS::Han JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystem3D_prototype); jsb_cocos2d_PUParticleSystem3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystem3D_prototype), + parent_proto, jsb_cocos2d_PUParticleSystem3D_class, js_cocos2dx_3d_extension_PUParticleSystem3D_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, "PUParticleSystem3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_PUParticleSystem3D_class; - p->proto = jsb_cocos2d_PUParticleSystem3D_prototype; - p->parentProto = jsb_cocos2d_ParticleSystem3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PUParticleSystem3D_prototype); + jsb_register_class(cx, jsb_cocos2d_PUParticleSystem3D_class, proto, parent_proto); } void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp index 9cf3a8b792..3c20615156 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -48,7 +48,8 @@ JSObject *jsb_cocos2d_experimental_AudioProfile_prototype; bool js_cocos2dx_audioengine_AudioProfile_get_name(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_get_name : Invalid Native Object"); @@ -59,7 +60,8 @@ bool js_cocos2dx_audioengine_AudioProfile_get_name(JSContext *cx, uint32_t argc, bool js_cocos2dx_audioengine_AudioProfile_set_name(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_set_name : Invalid Native Object"); @@ -73,7 +75,8 @@ bool js_cocos2dx_audioengine_AudioProfile_set_name(JSContext *cx, uint32_t argc, bool js_cocos2dx_audioengine_AudioProfile_get_maxInstances(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_get_maxInstances : Invalid Native Object"); @@ -84,7 +87,8 @@ bool js_cocos2dx_audioengine_AudioProfile_get_maxInstances(JSContext *cx, uint32 bool js_cocos2dx_audioengine_AudioProfile_set_maxInstances(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_set_maxInstances : Invalid Native Object"); @@ -98,7 +102,8 @@ bool js_cocos2dx_audioengine_AudioProfile_set_maxInstances(JSContext *cx, uint32 bool js_cocos2dx_audioengine_AudioProfile_get_minDelay(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_get_minDelay : Invalid Native Object"); @@ -109,7 +114,8 @@ bool js_cocos2dx_audioengine_AudioProfile_get_minDelay(JSContext *cx, uint32_t a bool js_cocos2dx_audioengine_AudioProfile_set_minDelay(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_set_minDelay : Invalid Native Object"); @@ -132,8 +138,8 @@ bool js_cocos2dx_audioengine_AudioProfile_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -148,7 +154,9 @@ void js_cocos2d_experimental_AudioProfile_finalize(JSFreeOp *fop, JSObject *obj) CCLOGINFO("jsbindings: finalizing JS object %p (AudioProfile)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; - jsproxy = jsb_get_js_proxy(obj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { cocos2d::experimental::AudioProfile *nobj = static_cast(jsproxy->ptr); nproxy = jsb_get_native_proxy(jsproxy->ptr); @@ -189,30 +197,17 @@ void js_register_cocos2dx_audioengine_AudioProfile(JSContext *cx, JS::HandleObje jsb_cocos2d_experimental_AudioProfile_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_experimental_AudioProfile_class, js_cocos2dx_audioengine_AudioProfile_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, "AudioProfile", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_experimental_AudioProfile_class; - p->proto = jsb_cocos2d_experimental_AudioProfile_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_AudioProfile_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_AudioProfile_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_experimental_AudioEngine_class; @@ -462,7 +457,8 @@ bool js_cocos2dx_audioengine_AudioEngine_preload(JSContext *cx, uint32_t argc, j do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](bool larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -551,7 +547,7 @@ bool js_cocos2dx_audioengine_AudioEngine_play2d(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (const cocos2d::experimental::AudioProfile*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -685,7 +681,8 @@ bool js_cocos2dx_audioengine_AudioEngine_setFinishCallback(JSContext *cx, uint32 do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0, const std::basic_string & larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -818,30 +815,17 @@ void js_register_cocos2dx_audioengine_AudioEngine(JSContext *cx, JS::HandleObjec jsb_cocos2d_experimental_AudioEngine_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_experimental_AudioEngine_class, empty_constructor, 0, 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, "AudioEngine", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_experimental_AudioEngine_class; - p->proto = jsb_cocos2d_experimental_AudioEngine_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_AudioEngine_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_AudioEngine_class, proto, JS::NullPtr()); } void register_all_cocos2dx_audioengine(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 226143358d..4cf53c35bc 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -23,8 +23,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -116,7 +116,7 @@ bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_initWithImage : Invalid Native Object"); @@ -127,7 +127,7 @@ bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -151,7 +151,7 @@ bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -182,7 +182,7 @@ bool js_cocos2dx_Texture2D_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -304,7 +304,7 @@ bool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getBitsPerPixelForFormat : Invalid Native Object"); @@ -359,7 +359,7 @@ bool js_cocos2dx_Texture2D_initWithString(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_initWithString : Invalid Native Object"); @@ -758,8 +758,8 @@ bool js_cocos2dx_Texture2D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -829,30 +829,17 @@ void js_register_cocos2dx_Texture2D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Texture2D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Texture2D_class, js_cocos2dx_Texture2D_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, "Texture2D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Texture2D_class; - p->proto = jsb_cocos2d_Texture2D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Texture2D_prototype); + jsb_register_class(cx, jsb_cocos2d_Texture2D_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Touch_class; @@ -1042,8 +1029,8 @@ bool js_cocos2dx_Touch_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1092,30 +1079,17 @@ void js_register_cocos2dx_Touch(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Touch_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Touch_class, js_cocos2dx_Touch_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, "Touch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Touch_class; - p->proto = jsb_cocos2d_Touch_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Touch_prototype); + jsb_register_class(cx, jsb_cocos2d_Touch_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Event_class; @@ -1217,8 +1191,8 @@ bool js_cocos2dx_Event_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1262,30 +1236,17 @@ void js_register_cocos2dx_Event(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Event_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Event_class, js_cocos2dx_Event_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, "Event", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Event_class; - p->proto = jsb_cocos2d_Event_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Event_prototype); + jsb_register_class(cx, jsb_cocos2d_Event_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventTouch_class; @@ -1345,8 +1306,8 @@ bool js_cocos2dx_EventTouch_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1388,32 +1349,20 @@ void js_register_cocos2dx_EventTouch(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventTouch_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventTouch_class, js_cocos2dx_EventTouch_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, "EventTouch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventTouch_class; - p->proto = jsb_cocos2d_EventTouch_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventTouch_prototype); + jsb_register_class(cx, jsb_cocos2d_EventTouch_class, proto, parent_proto); } JSClass *jsb_cocos2d_ComponentContainer_class; @@ -1446,7 +1395,7 @@ bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_remove : Invalid Native Object"); @@ -1457,7 +1406,7 @@ bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1517,7 +1466,7 @@ bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1616,30 +1565,17 @@ void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject glo jsb_cocos2d_ComponentContainer_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ComponentContainer_class, empty_constructor, 0, 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, "ComponentContainer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ComponentContainer_class; - p->proto = jsb_cocos2d_ComponentContainer_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ComponentContainer_prototype); + jsb_register_class(cx, jsb_cocos2d_ComponentContainer_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Component_class; @@ -1760,7 +1696,7 @@ bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1829,8 +1765,8 @@ bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1897,30 +1833,17 @@ void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Component_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), 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 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)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Component_prototype); + jsb_register_class(cx, jsb_cocos2d_Component_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.Component.extend = cc.Class.extend; })()"); } @@ -1934,7 +1857,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_addChild : Invalid Native Object"); @@ -1945,7 +1868,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1967,7 +1890,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1986,7 +1909,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -2011,7 +1934,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -2039,7 +1962,7 @@ bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeComponent : Invalid Native Object"); @@ -2050,7 +1973,7 @@ bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2094,7 +2017,7 @@ bool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2198,7 +2121,7 @@ bool js_cocos2dx_Node_getChildren(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getChildren : Invalid Native Object"); @@ -2238,7 +2161,8 @@ bool js_cocos2dx_Node_setOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp) do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2478,7 +2402,8 @@ bool js_cocos2dx_Node_setonEnterTransitionDidFinishCallback(JSContext *cx, uint3 do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2654,7 +2579,7 @@ bool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -2671,7 +2596,7 @@ bool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -2770,7 +2695,7 @@ bool js_cocos2dx_Node_setGLProgramState(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2797,7 +2722,8 @@ bool js_cocos2dx_Node_setOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2876,7 +2802,8 @@ bool js_cocos2dx_Node_setonExitTransitionDidStartCallback(JSContext *cx, uint32_ do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2916,7 +2843,7 @@ bool js_cocos2dx_Node_convertTouchToNodeSpace(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2939,7 +2866,7 @@ bool js_cocos2dx_Node_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeAllChildrenWithCleanup : Invalid Native Object"); @@ -3050,7 +2977,7 @@ bool js_cocos2dx_Node_setParent(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -3107,7 +3034,7 @@ bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getNodeToParentAffineTransform : Invalid Native Object"); @@ -3118,7 +3045,7 @@ bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -3159,7 +3086,7 @@ bool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3246,7 +3173,7 @@ bool js_cocos2dx_Node_reorderChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -3456,7 +3383,7 @@ bool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getNodeToParentTransform : Invalid Native Object"); @@ -3467,7 +3394,7 @@ bool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -3530,7 +3457,7 @@ bool js_cocos2dx_Node_addComponent(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3560,7 +3487,7 @@ bool js_cocos2dx_Node_runAction(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3590,7 +3517,7 @@ bool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_visit : Invalid Native Object"); @@ -3609,7 +3536,7 @@ bool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3644,7 +3571,7 @@ bool js_cocos2dx_Node_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3826,7 +3753,7 @@ bool js_cocos2dx_Node_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scheduler*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4064,7 +3991,7 @@ bool js_cocos2dx_Node_getScheduler(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getScheduler : Invalid Native Object"); @@ -4137,7 +4064,7 @@ bool js_cocos2dx_Node_setActionManager(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionManager*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4158,7 +4085,7 @@ bool js_cocos2dx_Node_getPosition(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getPosition : Invalid Native Object"); @@ -4216,7 +4143,7 @@ bool js_cocos2dx_Node_getParent(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getParent : Invalid Native Object"); @@ -4464,7 +4391,7 @@ bool js_cocos2dx_Node_setScale(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_setScale : Invalid Native Object"); @@ -4776,7 +4703,7 @@ bool js_cocos2dx_Node_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventDispatcher*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4815,7 +4742,7 @@ bool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_draw : Invalid Native Object"); @@ -4834,7 +4761,7 @@ bool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4869,7 +4796,7 @@ bool js_cocos2dx_Node_setUserObject(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4898,7 +4825,8 @@ bool js_cocos2dx_Node_enumerateChildren(JSContext *cx, uint32_t argc, jsval *vp) do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Node* larg0) -> bool { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -4961,7 +4889,7 @@ bool js_cocos2dx_Node_removeFromParentAndCleanup(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeFromParentAndCleanup : Invalid Native Object"); @@ -5208,7 +5136,7 @@ bool js_cocos2dx_Node_stopAction(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5229,7 +5157,7 @@ bool js_cocos2dx_Node_getActionManager(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getActionManager : Invalid Native Object"); @@ -5307,8 +5235,8 @@ bool js_cocos2dx_Node_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5504,30 +5432,17 @@ void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Node_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Node_class, js_cocos2dx_Node_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, "Node", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Node_class; - p->proto = jsb_cocos2d_Node_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Node_prototype); + jsb_register_class(cx, jsb_cocos2d_Node_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.Node.extend = cc.Class.extend; })()"); } @@ -5550,8 +5465,8 @@ bool js_cocos2dx___NodeRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5608,32 +5523,20 @@ void js_register_cocos2dx___NodeRGBA(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d___NodeRGBA_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d___NodeRGBA_class, js_cocos2dx___NodeRGBA_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, "NodeRGBA", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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___NodeRGBA_class; - p->proto = jsb_cocos2d___NodeRGBA_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d___NodeRGBA_prototype); + jsb_register_class(cx, jsb_cocos2d___NodeRGBA_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.NodeRGBA.extend = cc.Class.extend; })()"); } @@ -5670,7 +5573,7 @@ bool js_cocos2dx_Scene_render(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5718,7 +5621,7 @@ bool js_cocos2dx_Scene_onProjectionChanged(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventCustom*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5841,8 +5744,8 @@ bool js_cocos2dx_Scene_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5909,32 +5812,20 @@ void js_register_cocos2dx_Scene(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Scene_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Scene_class, js_cocos2dx_Scene_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, "Scene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Scene_class; - p->proto = jsb_cocos2d_Scene_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Scene_prototype); + jsb_register_class(cx, jsb_cocos2d_Scene_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Scene.extend = cc.Class.extend; })()"); } @@ -6574,30 +6465,17 @@ void js_register_cocos2dx_GLView(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_GLView_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLView_class, empty_constructor, 0, 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, "GLView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_GLView_class; - p->proto = jsb_cocos2d_GLView_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLView_prototype); + jsb_register_class(cx, jsb_cocos2d_GLView_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Director_class; @@ -6633,7 +6511,7 @@ bool js_cocos2dx_Director_setEventDispatcher(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventDispatcher*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6751,7 +6629,7 @@ bool js_cocos2dx_Director_setActionManager(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionManager*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7121,7 +6999,7 @@ bool js_cocos2dx_Director_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scheduler*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7343,7 +7221,7 @@ bool js_cocos2dx_Director_setOpenGLView(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7427,7 +7305,7 @@ bool js_cocos2dx_Director_runWithScene(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7455,7 +7333,7 @@ bool js_cocos2dx_Director_setNotificationNode(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -7712,7 +7590,7 @@ bool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7821,7 +7699,7 @@ bool js_cocos2dx_Director_replaceScene(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7997,30 +7875,17 @@ void js_register_cocos2dx_Director(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Director_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Director_class, empty_constructor, 0, 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, "Director", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Director_class; - p->proto = jsb_cocos2d_Director_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Director_prototype); + jsb_register_class(cx, jsb_cocos2d_Director_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Scheduler_class; @@ -8119,7 +7984,8 @@ bool js_cocos2dx_Scheduler_performFunctionInCocosThread(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -8195,8 +8061,8 @@ bool js_cocos2dx_Scheduler_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -8243,30 +8109,17 @@ void js_register_cocos2dx_Scheduler(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Scheduler_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Scheduler_class, js_cocos2dx_Scheduler_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, "Scheduler", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Scheduler_class; - p->proto = jsb_cocos2d_Scheduler_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Scheduler_prototype); + jsb_register_class(cx, jsb_cocos2d_Scheduler_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_AsyncTaskPool_class; @@ -8360,30 +8213,17 @@ void js_register_cocos2dx_AsyncTaskPool(JSContext *cx, JS::HandleObject global) jsb_cocos2d_AsyncTaskPool_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_AsyncTaskPool_class, empty_constructor, 0, 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, "AsyncTaskPool", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_AsyncTaskPool_class; - p->proto = jsb_cocos2d_AsyncTaskPool_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AsyncTaskPool_prototype); + jsb_register_class(cx, jsb_cocos2d_AsyncTaskPool_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Action_class; @@ -8403,7 +8243,7 @@ bool js_cocos2dx_Action_startWithTarget(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -8431,7 +8271,7 @@ bool js_cocos2dx_Action_setOriginalTarget(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -8666,7 +8506,7 @@ bool js_cocos2dx_Action_setTarget(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -8768,30 +8608,17 @@ void js_register_cocos2dx_Action(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Action_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Action_class, empty_constructor, 0, 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, "Action", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Action_class; - p->proto = jsb_cocos2d_Action_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Action_prototype); + jsb_register_class(cx, jsb_cocos2d_Action_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_FiniteTimeAction_class; @@ -8867,32 +8694,20 @@ void js_register_cocos2dx_FiniteTimeAction(JSContext *cx, JS::HandleObject globa JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocos2d_FiniteTimeAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocos2d_FiniteTimeAction_class, empty_constructor, 0, 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, "FiniteTimeAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FiniteTimeAction_class; - p->proto = jsb_cocos2d_FiniteTimeAction_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FiniteTimeAction_prototype); + jsb_register_class(cx, jsb_cocos2d_FiniteTimeAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_Speed_class; @@ -8912,7 +8727,7 @@ bool js_cocos2dx_Speed_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8979,7 +8794,7 @@ bool js_cocos2dx_Speed_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9032,7 +8847,7 @@ bool js_cocos2dx_Speed_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9072,8 +8887,8 @@ bool js_cocos2dx_Speed_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9121,32 +8936,20 @@ void js_register_cocos2dx_Speed(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocos2d_Speed_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocos2d_Speed_class, js_cocos2dx_Speed_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, "Speed", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Speed_class; - p->proto = jsb_cocos2d_Speed_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Speed_prototype); + jsb_register_class(cx, jsb_cocos2d_Speed_class, proto, parent_proto); } JSClass *jsb_cocos2d_Follow_class; @@ -9186,7 +8989,7 @@ bool js_cocos2dx_Follow_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -9205,7 +9008,7 @@ bool js_cocos2dx_Follow_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -9250,7 +9053,7 @@ bool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -9276,7 +9079,7 @@ bool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -9316,8 +9119,8 @@ bool js_cocos2dx_Follow_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9380,32 +9183,20 @@ void js_register_cocos2dx_Follow(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocos2d_Follow_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocos2d_Follow_class, js_cocos2dx_Follow_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, "Follow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Follow_class; - p->proto = jsb_cocos2d_Follow_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Follow_prototype); + jsb_register_class(cx, jsb_cocos2d_Follow_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Follow.extend = cc.Class.extend; })()"); } @@ -9768,8 +9559,8 @@ bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9827,30 +9618,17 @@ void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Image_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Image_class, js_cocos2dx_Image_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, "Image", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Image_class; - p->proto = jsb_cocos2d_Image_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Image_prototype); + jsb_register_class(cx, jsb_cocos2d_Image_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_GLProgramState_class; @@ -9863,7 +9641,7 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformCallback : Invalid Native Object"); @@ -9876,7 +9654,8 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -9919,7 +9698,8 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -10003,7 +9783,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec2(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec2 : Invalid Native Object"); @@ -10045,7 +9825,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec3 : Invalid Native Object"); @@ -10095,7 +9875,8 @@ bool js_cocos2dx_GLProgramState_setVertexAttribCallback(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::VertexAttrib* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -10209,7 +9990,7 @@ bool js_cocos2dx_GLProgramState_setNodeBinding(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -10230,7 +10011,7 @@ bool js_cocos2dx_GLProgramState_setUniformInt(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformInt : Invalid Native Object"); @@ -10294,7 +10075,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec2v(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec2v : Invalid Native Object"); @@ -10417,7 +10198,7 @@ bool js_cocos2dx_GLProgramState_setGLProgram(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10438,7 +10219,7 @@ bool js_cocos2dx_GLProgramState_setUniformFloatv(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformFloatv : Invalid Native Object"); @@ -10513,7 +10294,7 @@ bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformTexture : Invalid Native Object"); @@ -10541,7 +10322,7 @@ bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -10563,7 +10344,7 @@ bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -10615,7 +10396,7 @@ bool js_cocos2dx_GLProgramState_setUniformFloat(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformFloat : Invalid Native Object"); @@ -10657,7 +10438,7 @@ bool js_cocos2dx_GLProgramState_setUniformMat4(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformMat4 : Invalid Native Object"); @@ -10699,7 +10480,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec3v : Invalid Native Object"); @@ -10716,7 +10497,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -10741,7 +10522,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -10784,7 +10565,7 @@ bool js_cocos2dx_GLProgramState_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10842,7 +10623,7 @@ bool js_cocos2dx_GLProgramState_getOrCreateWithGLProgram(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10955,30 +10736,17 @@ void js_register_cocos2dx_GLProgramState(JSContext *cx, JS::HandleObject global) jsb_cocos2d_GLProgramState_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLProgramState_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "GLProgramState", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_GLProgramState_class; - p->proto = jsb_cocos2d_GLProgramState_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLProgramState_prototype); + jsb_register_class(cx, jsb_cocos2d_GLProgramState_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_SpriteFrame_class; @@ -10998,7 +10766,7 @@ bool js_cocos2dx_SpriteFrame_setTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11160,7 +10928,7 @@ bool js_cocos2dx_SpriteFrame_initWithTextureFilename(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_initWithTextureFilename : Invalid Native Object"); @@ -11234,7 +11002,7 @@ bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_initWithTexture : Invalid Native Object"); @@ -11245,7 +11013,7 @@ bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11277,7 +11045,7 @@ bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11526,7 +11294,7 @@ bool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11566,7 +11334,7 @@ bool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11608,8 +11376,8 @@ bool js_cocos2dx_SpriteFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -11689,30 +11457,17 @@ void js_register_cocos2dx_SpriteFrame(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_SpriteFrame_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_SpriteFrame_class, js_cocos2dx_SpriteFrame_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, "SpriteFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SpriteFrame_class; - p->proto = jsb_cocos2d_SpriteFrame_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpriteFrame_prototype); + jsb_register_class(cx, jsb_cocos2d_SpriteFrame_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.SpriteFrame.extend = cc.Class.extend; })()"); } @@ -11733,7 +11488,7 @@ bool js_cocos2dx_AnimationFrame_setSpriteFrame(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11754,7 +11509,7 @@ bool js_cocos2dx_AnimationFrame_getUserInfo(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_getUserInfo : Invalid Native Object"); @@ -11905,7 +11660,7 @@ bool js_cocos2dx_AnimationFrame_initWithSpriteFrame(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11935,7 +11690,7 @@ bool js_cocos2dx_AnimationFrame_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11976,8 +11731,8 @@ bool js_cocos2dx_AnimationFrame_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -12045,30 +11800,17 @@ void js_register_cocos2dx_AnimationFrame(JSContext *cx, JS::HandleObject global) jsb_cocos2d_AnimationFrame_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_AnimationFrame_class, js_cocos2dx_AnimationFrame_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, "AnimationFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_AnimationFrame_class; - p->proto = jsb_cocos2d_AnimationFrame_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AnimationFrame_prototype); + jsb_register_class(cx, jsb_cocos2d_AnimationFrame_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.AnimationFrame.extend = cc.Class.extend; })()"); } @@ -12107,7 +11849,7 @@ bool js_cocos2dx_Animation_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12443,7 +12185,7 @@ bool js_cocos2dx_Animation_addSpriteFrameWithTexture(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12611,8 +12353,8 @@ bool js_cocos2dx_Animation_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -12690,30 +12432,17 @@ void js_register_cocos2dx_Animation(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Animation_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Animation_class, js_cocos2dx_Animation_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, "Animation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Animation_class; - p->proto = jsb_cocos2d_Animation_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animation_prototype); + jsb_register_class(cx, jsb_cocos2d_Animation_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.Animation.extend = cc.Class.extend; })()"); } @@ -12832,32 +12561,20 @@ void js_register_cocos2dx_ActionInterval(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FiniteTimeAction_prototype); jsb_cocos2d_ActionInterval_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FiniteTimeAction_prototype), + parent_proto, jsb_cocos2d_ActionInterval_class, empty_constructor, 0, 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, "ActionInterval", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ActionInterval_class; - p->proto = jsb_cocos2d_ActionInterval_prototype; - p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionInterval_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionInterval_class, proto, parent_proto); } JSClass *jsb_cocos2d_Sequence_class; @@ -12878,7 +12595,7 @@ bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12887,7 +12604,7 @@ bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -12919,8 +12636,8 @@ bool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -12978,32 +12695,20 @@ void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Sequence_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Sequence_class, js_cocos2dx_Sequence_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, "Sequence", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Sequence_class; - p->proto = jsb_cocos2d_Sequence_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sequence_prototype); + jsb_register_class(cx, jsb_cocos2d_Sequence_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Sequence.extend = cc.Class.extend; })()"); } @@ -13024,7 +12729,7 @@ bool js_cocos2dx_Repeat_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13053,7 +12758,7 @@ bool js_cocos2dx_Repeat_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13106,7 +12811,7 @@ bool js_cocos2dx_Repeat_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13146,8 +12851,8 @@ bool js_cocos2dx_Repeat_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13210,32 +12915,20 @@ void js_register_cocos2dx_Repeat(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Repeat_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Repeat_class, js_cocos2dx_Repeat_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, "Repeat", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Repeat_class; - p->proto = jsb_cocos2d_Repeat_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Repeat_prototype); + jsb_register_class(cx, jsb_cocos2d_Repeat_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Repeat.extend = cc.Class.extend; })()"); } @@ -13256,7 +12949,7 @@ bool js_cocos2dx_RepeatForever_setInnerAction(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13284,7 +12977,7 @@ bool js_cocos2dx_RepeatForever_initWithAction(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13335,7 +13028,7 @@ bool js_cocos2dx_RepeatForever_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13374,8 +13067,8 @@ bool js_cocos2dx_RepeatForever_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13438,32 +13131,20 @@ void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_RepeatForever_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_RepeatForever_class, js_cocos2dx_RepeatForever_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, "RepeatForever", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_RepeatForever_class; - p->proto = jsb_cocos2d_RepeatForever_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RepeatForever_prototype); + jsb_register_class(cx, jsb_cocos2d_RepeatForever_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RepeatForever.extend = cc.Class.extend; })()"); } @@ -13485,7 +13166,7 @@ bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13494,7 +13175,7 @@ bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -13526,8 +13207,8 @@ bool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13585,32 +13266,20 @@ void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Spawn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Spawn_class, js_cocos2dx_Spawn_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, "Spawn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Spawn_class; - p->proto = jsb_cocos2d_Spawn_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Spawn_prototype); + jsb_register_class(cx, jsb_cocos2d_Spawn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Spawn.extend = cc.Class.extend; })()"); } @@ -13624,7 +13293,7 @@ bool js_cocos2dx_RotateTo_initWithDuration(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RotateTo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RotateTo_initWithDuration : Invalid Native Object"); @@ -13761,8 +13430,8 @@ bool js_cocos2dx_RotateTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13823,32 +13492,20 @@ void js_register_cocos2dx_RotateTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_RotateTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_RotateTo_class, js_cocos2dx_RotateTo_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, "RotateTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_RotateTo_class; - p->proto = jsb_cocos2d_RotateTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RotateTo_prototype); + jsb_register_class(cx, jsb_cocos2d_RotateTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RotateTo.extend = cc.Class.extend; })()"); } @@ -13862,7 +13519,7 @@ bool js_cocos2dx_RotateBy_initWithDuration(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RotateBy *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RotateBy_initWithDuration : Invalid Native Object"); @@ -14015,8 +13672,8 @@ bool js_cocos2dx_RotateBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14077,32 +13734,20 @@ void js_register_cocos2dx_RotateBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_RotateBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_RotateBy_class, js_cocos2dx_RotateBy_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, "RotateBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_RotateBy_class; - p->proto = jsb_cocos2d_RotateBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RotateBy_prototype); + jsb_register_class(cx, jsb_cocos2d_RotateBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RotateBy.extend = cc.Class.extend; })()"); } @@ -14116,7 +13761,7 @@ bool js_cocos2dx_MoveBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::MoveBy *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MoveBy_initWithDuration : Invalid Native Object"); @@ -14224,8 +13869,8 @@ bool js_cocos2dx_MoveBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14286,32 +13931,20 @@ void js_register_cocos2dx_MoveBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_MoveBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_MoveBy_class, js_cocos2dx_MoveBy_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, "MoveBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MoveBy_class; - p->proto = jsb_cocos2d_MoveBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MoveBy_prototype); + jsb_register_class(cx, jsb_cocos2d_MoveBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MoveBy.extend = cc.Class.extend; })()"); } @@ -14325,7 +13958,7 @@ bool js_cocos2dx_MoveTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::MoveTo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MoveTo_initWithDuration : Invalid Native Object"); @@ -14433,8 +14066,8 @@ bool js_cocos2dx_MoveTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14495,32 +14128,20 @@ void js_register_cocos2dx_MoveTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MoveBy_prototype); jsb_cocos2d_MoveTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MoveBy_prototype), + parent_proto, jsb_cocos2d_MoveTo_class, js_cocos2dx_MoveTo_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, "MoveTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MoveTo_class; - p->proto = jsb_cocos2d_MoveTo_prototype; - p->parentProto = jsb_cocos2d_MoveBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MoveTo_prototype); + jsb_register_class(cx, jsb_cocos2d_MoveTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MoveTo.extend = cc.Class.extend; })()"); } @@ -14598,8 +14219,8 @@ bool js_cocos2dx_SkewTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14660,32 +14281,20 @@ void js_register_cocos2dx_SkewTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_SkewTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_SkewTo_class, js_cocos2dx_SkewTo_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, "SkewTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SkewTo_class; - p->proto = jsb_cocos2d_SkewTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SkewTo_prototype); + jsb_register_class(cx, jsb_cocos2d_SkewTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.SkewTo.extend = cc.Class.extend; })()"); } @@ -14763,8 +14372,8 @@ bool js_cocos2dx_SkewBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14825,32 +14434,20 @@ void js_register_cocos2dx_SkewBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_SkewTo_prototype); jsb_cocos2d_SkewBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_SkewTo_prototype), + parent_proto, jsb_cocos2d_SkewBy_class, js_cocos2dx_SkewBy_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, "SkewBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SkewBy_class; - p->proto = jsb_cocos2d_SkewBy_prototype; - p->parentProto = jsb_cocos2d_SkewTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SkewBy_prototype); + jsb_register_class(cx, jsb_cocos2d_SkewBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.SkewBy.extend = cc.Class.extend; })()"); } @@ -14932,8 +14529,8 @@ bool js_cocos2dx_JumpBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14994,32 +14591,20 @@ void js_register_cocos2dx_JumpBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_JumpBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_JumpBy_class, js_cocos2dx_JumpBy_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, "JumpBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_JumpBy_class; - p->proto = jsb_cocos2d_JumpBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_JumpBy_prototype); + jsb_register_class(cx, jsb_cocos2d_JumpBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.JumpBy.extend = cc.Class.extend; })()"); } @@ -15101,8 +14686,8 @@ bool js_cocos2dx_JumpTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -15163,32 +14748,20 @@ void js_register_cocos2dx_JumpTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_JumpBy_prototype); jsb_cocos2d_JumpTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_JumpBy_prototype), + parent_proto, jsb_cocos2d_JumpTo_class, js_cocos2dx_JumpTo_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, "JumpTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_JumpTo_class; - p->proto = jsb_cocos2d_JumpTo_prototype; - p->parentProto = jsb_cocos2d_JumpBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_JumpTo_prototype); + jsb_register_class(cx, jsb_cocos2d_JumpTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.JumpTo.extend = cc.Class.extend; })()"); } @@ -15211,8 +14784,8 @@ bool js_cocos2dx_BezierBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -15269,32 +14842,20 @@ void js_register_cocos2dx_BezierBy(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_BezierBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_BezierBy_class, js_cocos2dx_BezierBy_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, "BezierBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_BezierBy_class; - p->proto = jsb_cocos2d_BezierBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BezierBy_prototype); + jsb_register_class(cx, jsb_cocos2d_BezierBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.BezierBy.extend = cc.Class.extend; })()"); } @@ -15317,8 +14878,8 @@ bool js_cocos2dx_BezierTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -15375,32 +14936,20 @@ void js_register_cocos2dx_BezierTo(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BezierBy_prototype); jsb_cocos2d_BezierTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BezierBy_prototype), + parent_proto, jsb_cocos2d_BezierTo_class, js_cocos2dx_BezierTo_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, "BezierTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_BezierTo_class; - p->proto = jsb_cocos2d_BezierTo_prototype; - p->parentProto = jsb_cocos2d_BezierBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BezierTo_prototype); + jsb_register_class(cx, jsb_cocos2d_BezierTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.BezierTo.extend = cc.Class.extend; })()"); } @@ -15414,7 +14963,7 @@ bool js_cocos2dx_ScaleTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ScaleTo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ScaleTo_initWithDuration : Invalid Native Object"); @@ -15579,8 +15128,8 @@ bool js_cocos2dx_ScaleTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -15641,32 +15190,20 @@ void js_register_cocos2dx_ScaleTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ScaleTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ScaleTo_class, js_cocos2dx_ScaleTo_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, "ScaleTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ScaleTo_class; - p->proto = jsb_cocos2d_ScaleTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ScaleTo_prototype); + jsb_register_class(cx, jsb_cocos2d_ScaleTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ScaleTo.extend = cc.Class.extend; })()"); } @@ -15774,8 +15311,8 @@ bool js_cocos2dx_ScaleBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -15835,32 +15372,20 @@ void js_register_cocos2dx_ScaleBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ScaleTo_prototype); jsb_cocos2d_ScaleBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ScaleTo_prototype), + parent_proto, jsb_cocos2d_ScaleBy_class, js_cocos2dx_ScaleBy_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, "ScaleBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ScaleBy_class; - p->proto = jsb_cocos2d_ScaleBy_prototype; - p->parentProto = jsb_cocos2d_ScaleTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ScaleBy_prototype); + jsb_register_class(cx, jsb_cocos2d_ScaleBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ScaleBy.extend = cc.Class.extend; })()"); } @@ -15934,8 +15459,8 @@ bool js_cocos2dx_Blink_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -15996,32 +15521,20 @@ void js_register_cocos2dx_Blink(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Blink_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Blink_class, js_cocos2dx_Blink_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, "Blink", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Blink_class; - p->proto = jsb_cocos2d_Blink_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Blink_prototype); + jsb_register_class(cx, jsb_cocos2d_Blink_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Blink.extend = cc.Class.extend; })()"); } @@ -16095,8 +15608,8 @@ bool js_cocos2dx_FadeTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16157,32 +15670,20 @@ void js_register_cocos2dx_FadeTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_FadeTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_FadeTo_class, js_cocos2dx_FadeTo_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, "FadeTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FadeTo_class; - p->proto = jsb_cocos2d_FadeTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeTo_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeTo.extend = cc.Class.extend; })()"); } @@ -16203,7 +15704,7 @@ bool js_cocos2dx_FadeIn_setReverseAction(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FadeTo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16258,8 +15759,8 @@ bool js_cocos2dx_FadeIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16320,32 +15821,20 @@ void js_register_cocos2dx_FadeIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeTo_prototype); jsb_cocos2d_FadeIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeTo_prototype), + parent_proto, jsb_cocos2d_FadeIn_class, js_cocos2dx_FadeIn_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, "FadeIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FadeIn_class; - p->proto = jsb_cocos2d_FadeIn_prototype; - p->parentProto = jsb_cocos2d_FadeTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeIn_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeIn.extend = cc.Class.extend; })()"); } @@ -16366,7 +15855,7 @@ bool js_cocos2dx_FadeOut_setReverseAction(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FadeTo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16421,8 +15910,8 @@ bool js_cocos2dx_FadeOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16483,32 +15972,20 @@ void js_register_cocos2dx_FadeOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeTo_prototype); jsb_cocos2d_FadeOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeTo_prototype), + parent_proto, jsb_cocos2d_FadeOut_class, js_cocos2dx_FadeOut_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, "FadeOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FadeOut_class; - p->proto = jsb_cocos2d_FadeOut_prototype; - p->parentProto = jsb_cocos2d_FadeTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOut_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOut.extend = cc.Class.extend; })()"); } @@ -16618,8 +16095,8 @@ bool js_cocos2dx_TintTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16680,32 +16157,20 @@ void js_register_cocos2dx_TintTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_TintTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_TintTo_class, js_cocos2dx_TintTo_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, "TintTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TintTo_class; - p->proto = jsb_cocos2d_TintTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TintTo_prototype); + jsb_register_class(cx, jsb_cocos2d_TintTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TintTo.extend = cc.Class.extend; })()"); } @@ -16787,8 +16252,8 @@ bool js_cocos2dx_TintBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16849,32 +16314,20 @@ void js_register_cocos2dx_TintBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_TintBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_TintBy_class, js_cocos2dx_TintBy_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, "TintBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TintBy_class; - p->proto = jsb_cocos2d_TintBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TintBy_prototype); + jsb_register_class(cx, jsb_cocos2d_TintBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TintBy.extend = cc.Class.extend; })()"); } @@ -16922,8 +16375,8 @@ bool js_cocos2dx_DelayTime_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16983,32 +16436,20 @@ void js_register_cocos2dx_DelayTime(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_DelayTime_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_DelayTime_class, js_cocos2dx_DelayTime_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, "DelayTime", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_DelayTime_class; - p->proto = jsb_cocos2d_DelayTime_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_DelayTime_prototype); + jsb_register_class(cx, jsb_cocos2d_DelayTime_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.DelayTime.extend = cc.Class.extend; })()"); } @@ -17029,7 +16470,7 @@ bool js_cocos2dx_ReverseTime_initWithAction(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17055,7 +16496,7 @@ bool js_cocos2dx_ReverseTime_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17094,8 +16535,8 @@ bool js_cocos2dx_ReverseTime_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -17156,32 +16597,20 @@ void js_register_cocos2dx_ReverseTime(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ReverseTime_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ReverseTime_class, js_cocos2dx_ReverseTime_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, "ReverseTime", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ReverseTime_class; - p->proto = jsb_cocos2d_ReverseTime_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ReverseTime_prototype); + jsb_register_class(cx, jsb_cocos2d_ReverseTime_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ReverseTime.extend = cc.Class.extend; })()"); } @@ -17202,7 +16631,7 @@ bool js_cocos2dx_Animate_initWithAnimation(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17225,7 +16654,7 @@ bool js_cocos2dx_Animate_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Animate *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animate_getAnimation : Invalid Native Object"); @@ -17298,7 +16727,7 @@ bool js_cocos2dx_Animate_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17322,7 +16751,7 @@ bool js_cocos2dx_Animate_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17361,8 +16790,8 @@ bool js_cocos2dx_Animate_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -17426,32 +16855,20 @@ void js_register_cocos2dx_Animate(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Animate_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Animate_class, js_cocos2dx_Animate_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, "Animate", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Animate_class; - p->proto = jsb_cocos2d_Animate_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animate_prototype); + jsb_register_class(cx, jsb_cocos2d_Animate_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Animate.extend = cc.Class.extend; })()"); } @@ -17465,7 +16882,7 @@ bool js_cocos2dx_TargetedAction_getForcedTarget(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TargetedAction *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TargetedAction_getForcedTarget : Invalid Native Object"); @@ -17521,7 +16938,7 @@ bool js_cocos2dx_TargetedAction_initWithTarget(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -17530,7 +16947,7 @@ bool js_cocos2dx_TargetedAction_initWithTarget(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -17560,7 +16977,7 @@ bool js_cocos2dx_TargetedAction_setForcedTarget(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -17585,7 +17002,7 @@ bool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -17594,7 +17011,7 @@ bool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -17633,8 +17050,8 @@ bool js_cocos2dx_TargetedAction_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -17697,32 +17114,20 @@ void js_register_cocos2dx_TargetedAction(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_TargetedAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_TargetedAction_class, js_cocos2dx_TargetedAction_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, "TargetedAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TargetedAction_class; - p->proto = jsb_cocos2d_TargetedAction_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TargetedAction_prototype); + jsb_register_class(cx, jsb_cocos2d_TargetedAction_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TargetedAction.extend = cc.Class.extend; })()"); } @@ -17748,7 +17153,8 @@ bool js_cocos2dx_ActionFloat_initWithDuration(JSContext *cx, uint32_t argc, jsva do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](float larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -17793,7 +17199,8 @@ bool js_cocos2dx_ActionFloat_create(JSContext *cx, uint32_t argc, jsval *vp) do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](float larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -17846,8 +17253,8 @@ bool js_cocos2dx_ActionFloat_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -17908,32 +17315,20 @@ void js_register_cocos2dx_ActionFloat(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionFloat_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionFloat_class, js_cocos2dx_ActionFloat_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, "ActionFloat", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ActionFloat_class; - p->proto = jsb_cocos2d_ActionFloat_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionFloat_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionFloat_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ActionFloat.extend = cc.Class.extend; })()"); } @@ -18449,30 +17844,17 @@ void js_register_cocos2dx_Configuration(JSContext *cx, JS::HandleObject global) jsb_cocos2d_Configuration_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Configuration_class, empty_constructor, 0, 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, "Configuration", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Configuration_class; - p->proto = jsb_cocos2d_Configuration_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Configuration_prototype); + jsb_register_class(cx, jsb_cocos2d_Configuration_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Properties_class; @@ -18589,7 +17971,7 @@ bool js_cocos2dx_Properties_getNamespace(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Properties *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Properties_getNamespace : Invalid Native Object"); @@ -18713,7 +18095,7 @@ bool js_cocos2dx_Properties_getMat4(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Mat4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -18879,7 +18261,7 @@ bool js_cocos2dx_Properties_getColor(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Properties *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Properties_getColor : Invalid Native Object"); @@ -18893,7 +18275,7 @@ bool js_cocos2dx_Properties_getColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -18917,7 +18299,7 @@ bool js_cocos2dx_Properties_getColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19033,7 +18415,7 @@ bool js_cocos2dx_Properties_getVec3(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19089,7 +18471,7 @@ bool js_cocos2dx_Properties_getVec4(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19168,7 +18550,7 @@ bool js_cocos2dx_Properties_getQuaternionFromAxisAngle(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Quaternion*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19199,7 +18581,7 @@ bool js_cocos2dx_Properties_parseColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19223,7 +18605,7 @@ bool js_cocos2dx_Properties_parseColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19251,7 +18633,7 @@ bool js_cocos2dx_Properties_parseVec3(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19279,7 +18661,7 @@ bool js_cocos2dx_Properties_parseAxisAngle(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Quaternion*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19352,7 +18734,7 @@ bool js_cocos2dx_Properties_parseVec4(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19428,30 +18810,17 @@ void js_register_cocos2dx_Properties(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Properties_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Properties_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Properties", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Properties_class; - p->proto = jsb_cocos2d_Properties_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Properties_prototype); + jsb_register_class(cx, jsb_cocos2d_Properties_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_FileUtils_class; @@ -19552,7 +18921,7 @@ bool js_cocos2dx_FileUtils_renameFile(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_renameFile : Invalid Native Object"); @@ -20214,7 +19583,7 @@ bool js_cocos2dx_FileUtils_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FileUtils*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20316,30 +19685,17 @@ void js_register_cocos2dx_FileUtils(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FileUtils_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_FileUtils_class, empty_constructor, 0, 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, "FileUtils", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FileUtils_class; - p->proto = jsb_cocos2d_FileUtils_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FileUtils_prototype); + jsb_register_class(cx, jsb_cocos2d_FileUtils_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventAcceleration_class; @@ -20364,8 +19720,8 @@ bool js_cocos2dx_EventAcceleration_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -20405,32 +19761,20 @@ void js_register_cocos2dx_EventAcceleration(JSContext *cx, JS::HandleObject glob JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventAcceleration_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventAcceleration_class, js_cocos2dx_EventAcceleration_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, "EventAcceleration", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventAcceleration_class; - p->proto = jsb_cocos2d_EventAcceleration_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventAcceleration_prototype); + jsb_register_class(cx, jsb_cocos2d_EventAcceleration_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventCustom_class; @@ -20473,8 +19817,8 @@ bool js_cocos2dx_EventCustom_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -20515,32 +19859,20 @@ void js_register_cocos2dx_EventCustom(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventCustom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventCustom_class, js_cocos2dx_EventCustom_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, "EventCustom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventCustom_class; - p->proto = jsb_cocos2d_EventCustom_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventCustom_prototype); + jsb_register_class(cx, jsb_cocos2d_EventCustom_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListener_class; @@ -20661,30 +19993,17 @@ void js_register_cocos2dx_EventListener(JSContext *cx, JS::HandleObject global) jsb_cocos2d_EventListener_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_EventListener_class, empty_constructor, 0, 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, "EventListener", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListener_class; - p->proto = jsb_cocos2d_EventListener_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListener_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListener_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventDispatcher_class; @@ -20741,7 +20060,7 @@ bool js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(JSContex 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20750,7 +20069,7 @@ bool js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(JSContex if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -20779,7 +20098,8 @@ bool js_cocos2dx_EventDispatcher_addCustomEventListener(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::EventCustom* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -20838,7 +20158,7 @@ bool js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority(JSContext *cx 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20860,7 +20180,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, ui JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_removeEventListenersForTarget : Invalid Native Object"); @@ -20871,7 +20191,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -20890,7 +20210,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -20932,7 +20252,7 @@ bool js_cocos2dx_EventDispatcher_resumeEventListenersForTarget(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -20949,7 +20269,7 @@ bool js_cocos2dx_EventDispatcher_resumeEventListenersForTarget(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -20979,7 +20299,7 @@ bool js_cocos2dx_EventDispatcher_setPriority(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21008,7 +20328,7 @@ bool js_cocos2dx_EventDispatcher_dispatchEvent(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Event*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21036,7 +20356,7 @@ bool js_cocos2dx_EventDispatcher_pauseEventListenersForTarget(JSContext *cx, uin 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -21053,7 +20373,7 @@ bool js_cocos2dx_EventDispatcher_pauseEventListenersForTarget(JSContext *cx, uin 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -21102,7 +20422,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListener(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21150,8 +20470,8 @@ bool js_cocos2dx_EventDispatcher_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -21204,30 +20524,17 @@ void js_register_cocos2dx_EventDispatcher(JSContext *cx, JS::HandleObject global jsb_cocos2d_EventDispatcher_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_EventDispatcher_class, js_cocos2dx_EventDispatcher_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, "EventDispatcher", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventDispatcher_class; - p->proto = jsb_cocos2d_EventDispatcher_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventDispatcher_prototype); + jsb_register_class(cx, jsb_cocos2d_EventDispatcher_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventFocus_class; @@ -21243,7 +20550,7 @@ bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21252,7 +20559,7 @@ bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -21270,8 +20577,8 @@ bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -21311,32 +20618,20 @@ void js_register_cocos2dx_EventFocus(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventFocus_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventFocus_class, js_cocos2dx_EventFocus_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, "EventFocus", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventFocus_class; - p->proto = jsb_cocos2d_EventFocus_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventFocus_prototype); + jsb_register_class(cx, jsb_cocos2d_EventFocus_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerAcceleration_class; @@ -21355,7 +20650,8 @@ bool js_cocos2dx_EventListenerAcceleration_init(JSContext *cx, uint32_t argc, js do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -21402,7 +20698,8 @@ bool js_cocos2dx_EventListenerAcceleration_create(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -21463,8 +20760,8 @@ bool js_cocos2dx_EventListenerAcceleration_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -21508,32 +20805,20 @@ void js_register_cocos2dx_EventListenerAcceleration(JSContext *cx, JS::HandleObj JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerAcceleration_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerAcceleration_class, js_cocos2dx_EventListenerAcceleration_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, "EventListenerAcceleration", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListenerAcceleration_class; - p->proto = jsb_cocos2d_EventListenerAcceleration_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerAcceleration_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerAcceleration_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerCustom_class; @@ -21550,7 +20835,8 @@ bool js_cocos2dx_EventListenerCustom_create(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::EventCustom* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -21610,8 +20896,8 @@ bool js_cocos2dx_EventListenerCustom_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -21654,32 +20940,20 @@ void js_register_cocos2dx_EventListenerCustom(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerCustom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerCustom_class, js_cocos2dx_EventListenerCustom_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, "EventListenerCustom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListenerCustom_class; - p->proto = jsb_cocos2d_EventListenerCustom_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerCustom_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerCustom_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerFocus_class; @@ -21719,8 +20993,8 @@ bool js_cocos2dx_EventListenerFocus_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -21761,32 +21035,20 @@ void js_register_cocos2dx_EventListenerFocus(JSContext *cx, JS::HandleObject glo JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerFocus_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerFocus_class, js_cocos2dx_EventListenerFocus_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, "EventListenerFocus", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListenerFocus_class; - p->proto = jsb_cocos2d_EventListenerFocus_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerFocus_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerFocus_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerKeyboard_class; @@ -21826,8 +21088,8 @@ bool js_cocos2dx_EventListenerKeyboard_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -21868,32 +21130,20 @@ void js_register_cocos2dx_EventListenerKeyboard(JSContext *cx, JS::HandleObject JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerKeyboard_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerKeyboard_class, js_cocos2dx_EventListenerKeyboard_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, "EventListenerKeyboard", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListenerKeyboard_class; - p->proto = jsb_cocos2d_EventListenerKeyboard_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerKeyboard_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerKeyboard_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventMouse_class; @@ -22198,8 +21448,8 @@ bool js_cocos2dx_EventMouse_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -22254,32 +21504,20 @@ void js_register_cocos2dx_EventMouse(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventMouse_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventMouse_class, js_cocos2dx_EventMouse_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, "EventMouse", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventMouse_class; - p->proto = jsb_cocos2d_EventMouse_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventMouse_prototype); + jsb_register_class(cx, jsb_cocos2d_EventMouse_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerMouse_class; @@ -22319,8 +21557,8 @@ bool js_cocos2dx_EventListenerMouse_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -22361,32 +21599,20 @@ void js_register_cocos2dx_EventListenerMouse(JSContext *cx, JS::HandleObject glo JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerMouse_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerMouse_class, js_cocos2dx_EventListenerMouse_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, "EventListenerMouse", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListenerMouse_class; - p->proto = jsb_cocos2d_EventListenerMouse_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerMouse_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerMouse_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerTouchOneByOne_class; @@ -22464,8 +21690,8 @@ bool js_cocos2dx_EventListenerTouchOneByOne_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -22508,32 +21734,20 @@ void js_register_cocos2dx_EventListenerTouchOneByOne(JSContext *cx, JS::HandleOb JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerTouchOneByOne_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerTouchOneByOne_class, js_cocos2dx_EventListenerTouchOneByOne_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, "EventListenerTouchOneByOne", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListenerTouchOneByOne_class; - p->proto = jsb_cocos2d_EventListenerTouchOneByOne_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerTouchOneByOne_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerTouchOneByOne_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerTouchAllAtOnce_class; @@ -22573,8 +21787,8 @@ bool js_cocos2dx_EventListenerTouchAllAtOnce_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -22615,32 +21829,20 @@ void js_register_cocos2dx_EventListenerTouchAllAtOnce(JSContext *cx, JS::HandleO JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerTouchAllAtOnce_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerTouchAllAtOnce_class, js_cocos2dx_EventListenerTouchAllAtOnce_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, "EventListenerTouchAllAtOnce", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EventListenerTouchAllAtOnce_class; - p->proto = jsb_cocos2d_EventListenerTouchAllAtOnce_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerTouchAllAtOnce_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerTouchAllAtOnce_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionCamera_class; @@ -22653,7 +21855,7 @@ bool js_cocos2dx_ActionCamera_setEye(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_setEye : Invalid Native Object"); @@ -22798,8 +22000,8 @@ bool js_cocos2dx_ActionCamera_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -22862,32 +22064,20 @@ void js_register_cocos2dx_ActionCamera(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionCamera_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionCamera_class, js_cocos2dx_ActionCamera_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, "ActionCamera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ActionCamera_class; - p->proto = jsb_cocos2d_ActionCamera_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionCamera_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionCamera_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ActionCamera.extend = cc.Class.extend; })()"); } @@ -23008,8 +22198,8 @@ bool js_cocos2dx_OrbitCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -23071,32 +22261,20 @@ void js_register_cocos2dx_OrbitCamera(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionCamera_prototype); jsb_cocos2d_OrbitCamera_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionCamera_prototype), + parent_proto, jsb_cocos2d_OrbitCamera_class, js_cocos2dx_OrbitCamera_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, "OrbitCamera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_OrbitCamera_class; - p->proto = jsb_cocos2d_OrbitCamera_prototype; - p->parentProto = jsb_cocos2d_ActionCamera_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_OrbitCamera_prototype); + jsb_register_class(cx, jsb_cocos2d_OrbitCamera_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.OrbitCamera.extend = cc.Class.extend; })()"); } @@ -23164,8 +22342,8 @@ bool js_cocos2dx_CardinalSplineTo_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -23207,32 +22385,20 @@ void js_register_cocos2dx_CardinalSplineTo(JSContext *cx, JS::HandleObject globa JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_CardinalSplineTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_CardinalSplineTo_class, js_cocos2dx_CardinalSplineTo_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, "CardinalSplineTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CardinalSplineTo_class; - p->proto = jsb_cocos2d_CardinalSplineTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CardinalSplineTo_prototype); + jsb_register_class(cx, jsb_cocos2d_CardinalSplineTo_class, proto, parent_proto); } JSClass *jsb_cocos2d_CardinalSplineBy_class; @@ -23254,8 +22420,8 @@ bool js_cocos2dx_CardinalSplineBy_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -23295,32 +22461,20 @@ void js_register_cocos2dx_CardinalSplineBy(JSContext *cx, JS::HandleObject globa JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CardinalSplineTo_prototype); jsb_cocos2d_CardinalSplineBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CardinalSplineTo_prototype), + parent_proto, jsb_cocos2d_CardinalSplineBy_class, js_cocos2dx_CardinalSplineBy_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, "CardinalSplineBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CardinalSplineBy_class; - p->proto = jsb_cocos2d_CardinalSplineBy_prototype; - p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CardinalSplineBy_prototype); + jsb_register_class(cx, jsb_cocos2d_CardinalSplineBy_class, proto, parent_proto); } JSClass *jsb_cocos2d_CatmullRomTo_class; @@ -23356,32 +22510,20 @@ void js_register_cocos2dx_CatmullRomTo(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CardinalSplineTo_prototype); jsb_cocos2d_CatmullRomTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CardinalSplineTo_prototype), + parent_proto, jsb_cocos2d_CatmullRomTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CatmullRomTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CatmullRomTo_class; - p->proto = jsb_cocos2d_CatmullRomTo_prototype; - p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CatmullRomTo_prototype); + jsb_register_class(cx, jsb_cocos2d_CatmullRomTo_class, proto, parent_proto); } JSClass *jsb_cocos2d_CatmullRomBy_class; @@ -23417,32 +22559,20 @@ void js_register_cocos2dx_CatmullRomBy(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CardinalSplineBy_prototype); jsb_cocos2d_CatmullRomBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CardinalSplineBy_prototype), + parent_proto, jsb_cocos2d_CatmullRomBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CatmullRomBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CatmullRomBy_class; - p->proto = jsb_cocos2d_CatmullRomBy_prototype; - p->parentProto = jsb_cocos2d_CardinalSplineBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CatmullRomBy_prototype); + jsb_register_class(cx, jsb_cocos2d_CatmullRomBy_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionEase_class; @@ -23462,7 +22592,7 @@ bool js_cocos2dx_ActionEase_initWithAction(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23535,32 +22665,20 @@ void js_register_cocos2dx_ActionEase(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionEase_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionEase_class, empty_constructor, 0, 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, "ActionEase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ActionEase_class; - p->proto = jsb_cocos2d_ActionEase_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionEase_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionEase_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseRateAction_class; @@ -23601,7 +22719,7 @@ bool js_cocos2dx_EaseRateAction_initWithAction(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23647,7 +22765,7 @@ bool js_cocos2dx_EaseRateAction_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23707,32 +22825,20 @@ void js_register_cocos2dx_EaseRateAction(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseRateAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseRateAction_class, empty_constructor, 0, 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, "EaseRateAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseRateAction_class; - p->proto = jsb_cocos2d_EaseRateAction_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseRateAction_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseRateAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseIn_class; @@ -23749,7 +22855,7 @@ bool js_cocos2dx_EaseIn_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23789,8 +22895,8 @@ bool js_cocos2dx_EaseIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -23850,32 +22956,20 @@ void js_register_cocos2dx_EaseIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseRateAction_prototype); jsb_cocos2d_EaseIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + parent_proto, jsb_cocos2d_EaseIn_class, js_cocos2dx_EaseIn_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, "EaseIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseIn_class; - p->proto = jsb_cocos2d_EaseIn_prototype; - p->parentProto = jsb_cocos2d_EaseRateAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseIn.extend = cc.Class.extend; })()"); } @@ -23893,7 +22987,7 @@ bool js_cocos2dx_EaseOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23933,8 +23027,8 @@ bool js_cocos2dx_EaseOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -23994,32 +23088,20 @@ void js_register_cocos2dx_EaseOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseRateAction_prototype); jsb_cocos2d_EaseOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + parent_proto, jsb_cocos2d_EaseOut_class, js_cocos2dx_EaseOut_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, "EaseOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseOut_class; - p->proto = jsb_cocos2d_EaseOut_prototype; - p->parentProto = jsb_cocos2d_EaseRateAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseOut.extend = cc.Class.extend; })()"); } @@ -24037,7 +23119,7 @@ bool js_cocos2dx_EaseInOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24077,8 +23159,8 @@ bool js_cocos2dx_EaseInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -24138,32 +23220,20 @@ void js_register_cocos2dx_EaseInOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseRateAction_prototype); jsb_cocos2d_EaseInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + parent_proto, jsb_cocos2d_EaseInOut_class, js_cocos2dx_EaseInOut_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, "EaseInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseInOut_class; - p->proto = jsb_cocos2d_EaseInOut_prototype; - p->parentProto = jsb_cocos2d_EaseRateAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseInOut.extend = cc.Class.extend; })()"); } @@ -24180,7 +23250,7 @@ bool js_cocos2dx_EaseExponentialIn_create(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24219,8 +23289,8 @@ bool js_cocos2dx_EaseExponentialIn_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -24280,32 +23350,20 @@ void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseExponentialIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseExponentialIn_class, js_cocos2dx_EaseExponentialIn_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, "EaseExponentialIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseExponentialIn_class; - p->proto = jsb_cocos2d_EaseExponentialIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseExponentialIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseExponentialIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseExponentialIn.extend = cc.Class.extend; })()"); } @@ -24322,7 +23380,7 @@ bool js_cocos2dx_EaseExponentialOut_create(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24361,8 +23419,8 @@ bool js_cocos2dx_EaseExponentialOut_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -24422,32 +23480,20 @@ void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseExponentialOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseExponentialOut_class, js_cocos2dx_EaseExponentialOut_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, "EaseExponentialOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseExponentialOut_class; - p->proto = jsb_cocos2d_EaseExponentialOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseExponentialOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseExponentialOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseExponentialOut.extend = cc.Class.extend; })()"); } @@ -24464,7 +23510,7 @@ bool js_cocos2dx_EaseExponentialInOut_create(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24503,8 +23549,8 @@ bool js_cocos2dx_EaseExponentialInOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -24564,32 +23610,20 @@ void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseExponentialInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseExponentialInOut_class, js_cocos2dx_EaseExponentialInOut_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, "EaseExponentialInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseExponentialInOut_class; - p->proto = jsb_cocos2d_EaseExponentialInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseExponentialInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseExponentialInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseExponentialInOut.extend = cc.Class.extend; })()"); } @@ -24606,7 +23640,7 @@ bool js_cocos2dx_EaseSineIn_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24645,8 +23679,8 @@ bool js_cocos2dx_EaseSineIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -24706,32 +23740,20 @@ void js_register_cocos2dx_EaseSineIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseSineIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseSineIn_class, js_cocos2dx_EaseSineIn_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, "EaseSineIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseSineIn_class; - p->proto = jsb_cocos2d_EaseSineIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseSineIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseSineIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseSineIn.extend = cc.Class.extend; })()"); } @@ -24748,7 +23770,7 @@ bool js_cocos2dx_EaseSineOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24787,8 +23809,8 @@ bool js_cocos2dx_EaseSineOut_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -24848,32 +23870,20 @@ void js_register_cocos2dx_EaseSineOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseSineOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseSineOut_class, js_cocos2dx_EaseSineOut_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, "EaseSineOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseSineOut_class; - p->proto = jsb_cocos2d_EaseSineOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseSineOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseSineOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseSineOut.extend = cc.Class.extend; })()"); } @@ -24890,7 +23900,7 @@ bool js_cocos2dx_EaseSineInOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24929,8 +23939,8 @@ bool js_cocos2dx_EaseSineInOut_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -24990,32 +24000,20 @@ void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseSineInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseSineInOut_class, js_cocos2dx_EaseSineInOut_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, "EaseSineInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseSineInOut_class; - p->proto = jsb_cocos2d_EaseSineInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseSineInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseSineInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseSineInOut.extend = cc.Class.extend; })()"); } @@ -25056,7 +24054,7 @@ bool js_cocos2dx_EaseElastic_initWithAction(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25075,7 +24073,7 @@ bool js_cocos2dx_EaseElastic_initWithAction(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25143,32 +24141,20 @@ void js_register_cocos2dx_EaseElastic(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseElastic_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseElastic_class, empty_constructor, 0, 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, "EaseElastic", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseElastic_class; - p->proto = jsb_cocos2d_EaseElastic_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElastic_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElastic_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseElasticIn_class; @@ -25186,7 +24172,7 @@ bool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25214,7 +24200,7 @@ bool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25256,8 +24242,8 @@ bool js_cocos2dx_EaseElasticIn_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -25317,32 +24303,20 @@ void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseElastic_prototype); jsb_cocos2d_EaseElasticIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + parent_proto, jsb_cocos2d_EaseElasticIn_class, js_cocos2dx_EaseElasticIn_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, "EaseElasticIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseElasticIn_class; - p->proto = jsb_cocos2d_EaseElasticIn_prototype; - p->parentProto = jsb_cocos2d_EaseElastic_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElasticIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElasticIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseElasticIn.extend = cc.Class.extend; })()"); } @@ -25361,7 +24335,7 @@ bool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25389,7 +24363,7 @@ bool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25431,8 +24405,8 @@ bool js_cocos2dx_EaseElasticOut_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -25492,32 +24466,20 @@ void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseElastic_prototype); jsb_cocos2d_EaseElasticOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + parent_proto, jsb_cocos2d_EaseElasticOut_class, js_cocos2dx_EaseElasticOut_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, "EaseElasticOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseElasticOut_class; - p->proto = jsb_cocos2d_EaseElasticOut_prototype; - p->parentProto = jsb_cocos2d_EaseElastic_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElasticOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElasticOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseElasticOut.extend = cc.Class.extend; })()"); } @@ -25536,7 +24498,7 @@ bool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25564,7 +24526,7 @@ bool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25606,8 +24568,8 @@ bool js_cocos2dx_EaseElasticInOut_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -25667,32 +24629,20 @@ void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseElastic_prototype); jsb_cocos2d_EaseElasticInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + parent_proto, jsb_cocos2d_EaseElasticInOut_class, js_cocos2dx_EaseElasticInOut_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, "EaseElasticInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseElasticInOut_class; - p->proto = jsb_cocos2d_EaseElasticInOut_prototype; - p->parentProto = jsb_cocos2d_EaseElastic_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElasticInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElasticInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseElasticInOut.extend = cc.Class.extend; })()"); } @@ -25729,32 +24679,20 @@ void js_register_cocos2dx_EaseBounce(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBounce_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBounce_class, empty_constructor, 0, 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, "EaseBounce", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBounce_class; - p->proto = jsb_cocos2d_EaseBounce_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounce_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounce_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseBounceIn_class; @@ -25770,7 +24708,7 @@ bool js_cocos2dx_EaseBounceIn_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25809,8 +24747,8 @@ bool js_cocos2dx_EaseBounceIn_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -25870,32 +24808,20 @@ void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseBounce_prototype); jsb_cocos2d_EaseBounceIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + parent_proto, jsb_cocos2d_EaseBounceIn_class, js_cocos2dx_EaseBounceIn_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, "EaseBounceIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBounceIn_class; - p->proto = jsb_cocos2d_EaseBounceIn_prototype; - p->parentProto = jsb_cocos2d_EaseBounce_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounceIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounceIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBounceIn.extend = cc.Class.extend; })()"); } @@ -25912,7 +24838,7 @@ bool js_cocos2dx_EaseBounceOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25951,8 +24877,8 @@ bool js_cocos2dx_EaseBounceOut_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -26012,32 +24938,20 @@ void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseBounce_prototype); jsb_cocos2d_EaseBounceOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + parent_proto, jsb_cocos2d_EaseBounceOut_class, js_cocos2dx_EaseBounceOut_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, "EaseBounceOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBounceOut_class; - p->proto = jsb_cocos2d_EaseBounceOut_prototype; - p->parentProto = jsb_cocos2d_EaseBounce_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounceOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounceOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBounceOut.extend = cc.Class.extend; })()"); } @@ -26054,7 +24968,7 @@ bool js_cocos2dx_EaseBounceInOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26093,8 +25007,8 @@ bool js_cocos2dx_EaseBounceInOut_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -26154,32 +25068,20 @@ void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseBounce_prototype); jsb_cocos2d_EaseBounceInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + parent_proto, jsb_cocos2d_EaseBounceInOut_class, js_cocos2dx_EaseBounceInOut_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, "EaseBounceInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBounceInOut_class; - p->proto = jsb_cocos2d_EaseBounceInOut_prototype; - p->parentProto = jsb_cocos2d_EaseBounce_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounceInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounceInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBounceInOut.extend = cc.Class.extend; })()"); } @@ -26196,7 +25098,7 @@ bool js_cocos2dx_EaseBackIn_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26235,8 +25137,8 @@ bool js_cocos2dx_EaseBackIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -26296,32 +25198,20 @@ void js_register_cocos2dx_EaseBackIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBackIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBackIn_class, js_cocos2dx_EaseBackIn_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, "EaseBackIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBackIn_class; - p->proto = jsb_cocos2d_EaseBackIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBackIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBackIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBackIn.extend = cc.Class.extend; })()"); } @@ -26338,7 +25228,7 @@ bool js_cocos2dx_EaseBackOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26377,8 +25267,8 @@ bool js_cocos2dx_EaseBackOut_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -26438,32 +25328,20 @@ void js_register_cocos2dx_EaseBackOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBackOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBackOut_class, js_cocos2dx_EaseBackOut_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, "EaseBackOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBackOut_class; - p->proto = jsb_cocos2d_EaseBackOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBackOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBackOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBackOut.extend = cc.Class.extend; })()"); } @@ -26480,7 +25358,7 @@ bool js_cocos2dx_EaseBackInOut_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26519,8 +25397,8 @@ bool js_cocos2dx_EaseBackInOut_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -26580,32 +25458,20 @@ void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBackInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBackInOut_class, js_cocos2dx_EaseBackInOut_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, "EaseBackInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBackInOut_class; - p->proto = jsb_cocos2d_EaseBackInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBackInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBackInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBackInOut.extend = cc.Class.extend; })()"); } @@ -26648,7 +25514,7 @@ bool js_cocos2dx_EaseBezierAction_create(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26687,8 +25553,8 @@ bool js_cocos2dx_EaseBezierAction_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -26749,32 +25615,20 @@ void js_register_cocos2dx_EaseBezierAction(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBezierAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBezierAction_class, js_cocos2dx_EaseBezierAction_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, "EaseBezierAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseBezierAction_class; - p->proto = jsb_cocos2d_EaseBezierAction_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBezierAction_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBezierAction_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBezierAction.extend = cc.Class.extend; })()"); } @@ -26791,7 +25645,7 @@ bool js_cocos2dx_EaseQuadraticActionIn_create(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26830,8 +25684,8 @@ bool js_cocos2dx_EaseQuadraticActionIn_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -26891,32 +25745,20 @@ void js_register_cocos2dx_EaseQuadraticActionIn(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuadraticActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuadraticActionIn_class, js_cocos2dx_EaseQuadraticActionIn_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, "EaseQuadraticActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuadraticActionIn_class; - p->proto = jsb_cocos2d_EaseQuadraticActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuadraticActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuadraticActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuadraticActionIn.extend = cc.Class.extend; })()"); } @@ -26933,7 +25775,7 @@ bool js_cocos2dx_EaseQuadraticActionOut_create(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26972,8 +25814,8 @@ bool js_cocos2dx_EaseQuadraticActionOut_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -27033,32 +25875,20 @@ void js_register_cocos2dx_EaseQuadraticActionOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuadraticActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuadraticActionOut_class, js_cocos2dx_EaseQuadraticActionOut_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, "EaseQuadraticActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuadraticActionOut_class; - p->proto = jsb_cocos2d_EaseQuadraticActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuadraticActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuadraticActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuadraticActionOut.extend = cc.Class.extend; })()"); } @@ -27075,7 +25905,7 @@ bool js_cocos2dx_EaseQuadraticActionInOut_create(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27114,8 +25944,8 @@ bool js_cocos2dx_EaseQuadraticActionInOut_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -27175,32 +26005,20 @@ void js_register_cocos2dx_EaseQuadraticActionInOut(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuadraticActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuadraticActionInOut_class, js_cocos2dx_EaseQuadraticActionInOut_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, "EaseQuadraticActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuadraticActionInOut_class; - p->proto = jsb_cocos2d_EaseQuadraticActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuadraticActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuadraticActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuadraticActionInOut.extend = cc.Class.extend; })()"); } @@ -27217,7 +26035,7 @@ bool js_cocos2dx_EaseQuarticActionIn_create(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27256,8 +26074,8 @@ bool js_cocos2dx_EaseQuarticActionIn_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -27317,32 +26135,20 @@ void js_register_cocos2dx_EaseQuarticActionIn(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuarticActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuarticActionIn_class, js_cocos2dx_EaseQuarticActionIn_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, "EaseQuarticActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuarticActionIn_class; - p->proto = jsb_cocos2d_EaseQuarticActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuarticActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuarticActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuarticActionIn.extend = cc.Class.extend; })()"); } @@ -27359,7 +26165,7 @@ bool js_cocos2dx_EaseQuarticActionOut_create(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27398,8 +26204,8 @@ bool js_cocos2dx_EaseQuarticActionOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -27459,32 +26265,20 @@ void js_register_cocos2dx_EaseQuarticActionOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuarticActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuarticActionOut_class, js_cocos2dx_EaseQuarticActionOut_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, "EaseQuarticActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuarticActionOut_class; - p->proto = jsb_cocos2d_EaseQuarticActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuarticActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuarticActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuarticActionOut.extend = cc.Class.extend; })()"); } @@ -27501,7 +26295,7 @@ bool js_cocos2dx_EaseQuarticActionInOut_create(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27540,8 +26334,8 @@ bool js_cocos2dx_EaseQuarticActionInOut_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -27601,32 +26395,20 @@ void js_register_cocos2dx_EaseQuarticActionInOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuarticActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuarticActionInOut_class, js_cocos2dx_EaseQuarticActionInOut_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, "EaseQuarticActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuarticActionInOut_class; - p->proto = jsb_cocos2d_EaseQuarticActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuarticActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuarticActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuarticActionInOut.extend = cc.Class.extend; })()"); } @@ -27643,7 +26425,7 @@ bool js_cocos2dx_EaseQuinticActionIn_create(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27682,8 +26464,8 @@ bool js_cocos2dx_EaseQuinticActionIn_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -27743,32 +26525,20 @@ void js_register_cocos2dx_EaseQuinticActionIn(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuinticActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuinticActionIn_class, js_cocos2dx_EaseQuinticActionIn_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, "EaseQuinticActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuinticActionIn_class; - p->proto = jsb_cocos2d_EaseQuinticActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuinticActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuinticActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuinticActionIn.extend = cc.Class.extend; })()"); } @@ -27785,7 +26555,7 @@ bool js_cocos2dx_EaseQuinticActionOut_create(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27824,8 +26594,8 @@ bool js_cocos2dx_EaseQuinticActionOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -27885,32 +26655,20 @@ void js_register_cocos2dx_EaseQuinticActionOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuinticActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuinticActionOut_class, js_cocos2dx_EaseQuinticActionOut_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, "EaseQuinticActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuinticActionOut_class; - p->proto = jsb_cocos2d_EaseQuinticActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuinticActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuinticActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuinticActionOut.extend = cc.Class.extend; })()"); } @@ -27927,7 +26685,7 @@ bool js_cocos2dx_EaseQuinticActionInOut_create(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27966,8 +26724,8 @@ bool js_cocos2dx_EaseQuinticActionInOut_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -28027,32 +26785,20 @@ void js_register_cocos2dx_EaseQuinticActionInOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuinticActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuinticActionInOut_class, js_cocos2dx_EaseQuinticActionInOut_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, "EaseQuinticActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseQuinticActionInOut_class; - p->proto = jsb_cocos2d_EaseQuinticActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuinticActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuinticActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuinticActionInOut.extend = cc.Class.extend; })()"); } @@ -28069,7 +26815,7 @@ bool js_cocos2dx_EaseCircleActionIn_create(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28108,8 +26854,8 @@ bool js_cocos2dx_EaseCircleActionIn_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -28169,32 +26915,20 @@ void js_register_cocos2dx_EaseCircleActionIn(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCircleActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCircleActionIn_class, js_cocos2dx_EaseCircleActionIn_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, "EaseCircleActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseCircleActionIn_class; - p->proto = jsb_cocos2d_EaseCircleActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCircleActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCircleActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCircleActionIn.extend = cc.Class.extend; })()"); } @@ -28211,7 +26945,7 @@ bool js_cocos2dx_EaseCircleActionOut_create(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28250,8 +26984,8 @@ bool js_cocos2dx_EaseCircleActionOut_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -28311,32 +27045,20 @@ void js_register_cocos2dx_EaseCircleActionOut(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCircleActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCircleActionOut_class, js_cocos2dx_EaseCircleActionOut_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, "EaseCircleActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseCircleActionOut_class; - p->proto = jsb_cocos2d_EaseCircleActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCircleActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCircleActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCircleActionOut.extend = cc.Class.extend; })()"); } @@ -28353,7 +27075,7 @@ bool js_cocos2dx_EaseCircleActionInOut_create(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28392,8 +27114,8 @@ bool js_cocos2dx_EaseCircleActionInOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -28453,32 +27175,20 @@ void js_register_cocos2dx_EaseCircleActionInOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCircleActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCircleActionInOut_class, js_cocos2dx_EaseCircleActionInOut_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, "EaseCircleActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseCircleActionInOut_class; - p->proto = jsb_cocos2d_EaseCircleActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCircleActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCircleActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCircleActionInOut.extend = cc.Class.extend; })()"); } @@ -28495,7 +27205,7 @@ bool js_cocos2dx_EaseCubicActionIn_create(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28534,8 +27244,8 @@ bool js_cocos2dx_EaseCubicActionIn_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -28595,32 +27305,20 @@ void js_register_cocos2dx_EaseCubicActionIn(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCubicActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCubicActionIn_class, js_cocos2dx_EaseCubicActionIn_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, "EaseCubicActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseCubicActionIn_class; - p->proto = jsb_cocos2d_EaseCubicActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCubicActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCubicActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCubicActionIn.extend = cc.Class.extend; })()"); } @@ -28637,7 +27335,7 @@ bool js_cocos2dx_EaseCubicActionOut_create(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28676,8 +27374,8 @@ bool js_cocos2dx_EaseCubicActionOut_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -28737,32 +27435,20 @@ void js_register_cocos2dx_EaseCubicActionOut(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCubicActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCubicActionOut_class, js_cocos2dx_EaseCubicActionOut_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, "EaseCubicActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseCubicActionOut_class; - p->proto = jsb_cocos2d_EaseCubicActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCubicActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCubicActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCubicActionOut.extend = cc.Class.extend; })()"); } @@ -28779,7 +27465,7 @@ bool js_cocos2dx_EaseCubicActionInOut_create(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28818,8 +27504,8 @@ bool js_cocos2dx_EaseCubicActionInOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -28879,32 +27565,20 @@ void js_register_cocos2dx_EaseCubicActionInOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCubicActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCubicActionInOut_class, js_cocos2dx_EaseCubicActionInOut_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, "EaseCubicActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_EaseCubicActionInOut_class; - p->proto = jsb_cocos2d_EaseCubicActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCubicActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCubicActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCubicActionInOut.extend = cc.Class.extend; })()"); } @@ -28941,32 +27615,20 @@ void js_register_cocos2dx_ActionInstant(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FiniteTimeAction_prototype); jsb_cocos2d_ActionInstant_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FiniteTimeAction_prototype), + parent_proto, jsb_cocos2d_ActionInstant_class, empty_constructor, 0, 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, "ActionInstant", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ActionInstant_class; - p->proto = jsb_cocos2d_ActionInstant_prototype; - p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionInstant_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionInstant_class, proto, parent_proto); } JSClass *jsb_cocos2d_Show_class; @@ -29009,8 +27671,8 @@ bool js_cocos2dx_Show_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -29070,32 +27732,20 @@ void js_register_cocos2dx_Show(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_Show_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_Show_class, js_cocos2dx_Show_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, "Show", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Show_class; - p->proto = jsb_cocos2d_Show_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Show_prototype); + jsb_register_class(cx, jsb_cocos2d_Show_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Show.extend = cc.Class.extend; })()"); } @@ -29139,8 +27789,8 @@ bool js_cocos2dx_Hide_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -29200,32 +27850,20 @@ void js_register_cocos2dx_Hide(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_Hide_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_Hide_class, js_cocos2dx_Hide_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, "Hide", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Hide_class; - p->proto = jsb_cocos2d_Hide_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Hide_prototype); + jsb_register_class(cx, jsb_cocos2d_Hide_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Hide.extend = cc.Class.extend; })()"); } @@ -29269,8 +27907,8 @@ bool js_cocos2dx_ToggleVisibility_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -29313,32 +27951,20 @@ void js_register_cocos2dx_ToggleVisibility(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_ToggleVisibility_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_ToggleVisibility_class, js_cocos2dx_ToggleVisibility_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, "ToggleVisibility", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ToggleVisibility_class; - p->proto = jsb_cocos2d_ToggleVisibility_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ToggleVisibility_prototype); + jsb_register_class(cx, jsb_cocos2d_ToggleVisibility_class, proto, parent_proto); } JSClass *jsb_cocos2d_RemoveSelf_class; @@ -29421,8 +28047,8 @@ bool js_cocos2dx_RemoveSelf_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -29466,32 +28092,20 @@ void js_register_cocos2dx_RemoveSelf(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_RemoveSelf_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_RemoveSelf_class, js_cocos2dx_RemoveSelf_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, "RemoveSelf", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_RemoveSelf_class; - p->proto = jsb_cocos2d_RemoveSelf_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RemoveSelf_prototype); + jsb_register_class(cx, jsb_cocos2d_RemoveSelf_class, proto, parent_proto); } JSClass *jsb_cocos2d_FlipX_class; @@ -29560,8 +28174,8 @@ bool js_cocos2dx_FlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -29622,32 +28236,20 @@ void js_register_cocos2dx_FlipX(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_FlipX_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_FlipX_class, js_cocos2dx_FlipX_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, "FlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FlipX_class; - p->proto = jsb_cocos2d_FlipX_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipX_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipX_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipX.extend = cc.Class.extend; })()"); } @@ -29717,8 +28319,8 @@ bool js_cocos2dx_FlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -29779,32 +28381,20 @@ void js_register_cocos2dx_FlipY(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_FlipY_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_FlipY_class, js_cocos2dx_FlipY_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, "FlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FlipY_class; - p->proto = jsb_cocos2d_FlipY_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipY_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipY_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipY.extend = cc.Class.extend; })()"); } @@ -29874,8 +28464,8 @@ bool js_cocos2dx_Place_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -29936,32 +28526,20 @@ void js_register_cocos2dx_Place(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_Place_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_Place_class, js_cocos2dx_Place_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, "Place", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Place_class; - p->proto = jsb_cocos2d_Place_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Place_prototype); + jsb_register_class(cx, jsb_cocos2d_Place_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Place.extend = cc.Class.extend; })()"); } @@ -30000,8 +28578,8 @@ bool js_cocos2dx_CallFunc_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -30059,32 +28637,20 @@ void js_register_cocos2dx_CallFunc(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_CallFunc_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_CallFunc_class, js_cocos2dx_CallFunc_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, "_CallFunc", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CallFunc_class; - p->proto = jsb_cocos2d_CallFunc_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CallFunc_prototype); + jsb_register_class(cx, jsb_cocos2d_CallFunc_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc._CallFunc.extend = cc.Class.extend; })()"); } @@ -30107,8 +28673,8 @@ bool js_cocos2dx_CallFuncN_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -30165,32 +28731,20 @@ void js_register_cocos2dx_CallFuncN(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CallFunc_prototype); jsb_cocos2d_CallFuncN_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CallFunc_prototype), + parent_proto, jsb_cocos2d_CallFuncN_class, js_cocos2dx_CallFuncN_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, "CallFunc", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CallFuncN_class; - p->proto = jsb_cocos2d_CallFuncN_prototype; - p->parentProto = jsb_cocos2d_CallFunc_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CallFuncN_prototype); + jsb_register_class(cx, jsb_cocos2d_CallFuncN_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.CallFunc.extend = cc.Class.extend; })()"); } @@ -30278,32 +28832,20 @@ void js_register_cocos2dx_GridAction(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_GridAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_GridAction_class, empty_constructor, 0, 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, "GridAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_GridAction_class; - p->proto = jsb_cocos2d_GridAction_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GridAction_prototype); + jsb_register_class(cx, jsb_cocos2d_GridAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_Grid3DAction_class; @@ -30358,32 +28900,20 @@ void js_register_cocos2dx_Grid3DAction(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridAction_prototype); jsb_cocos2d_Grid3DAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridAction_prototype), + parent_proto, jsb_cocos2d_Grid3DAction_class, empty_constructor, 0, 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, "Grid3DAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Grid3DAction_class; - p->proto = jsb_cocos2d_Grid3DAction_prototype; - p->parentProto = jsb_cocos2d_GridAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Grid3DAction_prototype); + jsb_register_class(cx, jsb_cocos2d_Grid3DAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_TiledGrid3DAction_class; @@ -30419,32 +28949,20 @@ void js_register_cocos2dx_TiledGrid3DAction(JSContext *cx, JS::HandleObject glob JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridAction_prototype); jsb_cocos2d_TiledGrid3DAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridAction_prototype), + parent_proto, jsb_cocos2d_TiledGrid3DAction_class, empty_constructor, 0, 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, "TiledGrid3DAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TiledGrid3DAction_class; - p->proto = jsb_cocos2d_TiledGrid3DAction_prototype; - p->parentProto = jsb_cocos2d_GridAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); + jsb_register_class(cx, jsb_cocos2d_TiledGrid3DAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_StopGrid_class; @@ -30487,8 +29005,8 @@ bool js_cocos2dx_StopGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -30531,32 +29049,20 @@ void js_register_cocos2dx_StopGrid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_StopGrid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_StopGrid_class, js_cocos2dx_StopGrid_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, "StopGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_StopGrid_class; - p->proto = jsb_cocos2d_StopGrid_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_StopGrid_prototype); + jsb_register_class(cx, jsb_cocos2d_StopGrid_class, proto, parent_proto); } JSClass *jsb_cocos2d_ReuseGrid_class; @@ -30625,8 +29131,8 @@ bool js_cocos2dx_ReuseGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -30670,32 +29176,20 @@ void js_register_cocos2dx_ReuseGrid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_ReuseGrid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_ReuseGrid_class, js_cocos2dx_ReuseGrid_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, "ReuseGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ReuseGrid_class; - p->proto = jsb_cocos2d_ReuseGrid_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ReuseGrid_prototype); + jsb_register_class(cx, jsb_cocos2d_ReuseGrid_class, proto, parent_proto); } JSClass *jsb_cocos2d_Waves3D_class; @@ -30852,8 +29346,8 @@ bool js_cocos2dx_Waves3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -30901,32 +29395,20 @@ void js_register_cocos2dx_Waves3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Waves3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Waves3D_class, js_cocos2dx_Waves3D_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, "Waves3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Waves3D_class; - p->proto = jsb_cocos2d_Waves3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Waves3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Waves3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_FlipX3D_class; @@ -31019,8 +29501,8 @@ bool js_cocos2dx_FlipX3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -31082,32 +29564,20 @@ void js_register_cocos2dx_FlipX3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_FlipX3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_FlipX3D_class, js_cocos2dx_FlipX3D_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, "FlipX3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FlipX3D_class; - p->proto = jsb_cocos2d_FlipX3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipX3D_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipX3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipX3D.extend = cc.Class.extend; })()"); } @@ -31155,8 +29625,8 @@ bool js_cocos2dx_FlipY3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -31216,32 +29686,20 @@ void js_register_cocos2dx_FlipY3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FlipX3D_prototype); jsb_cocos2d_FlipY3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FlipX3D_prototype), + parent_proto, jsb_cocos2d_FlipY3D_class, js_cocos2dx_FlipY3D_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, "FlipY3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FlipY3D_class; - p->proto = jsb_cocos2d_FlipY3D_prototype; - p->parentProto = jsb_cocos2d_FlipX3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipY3D_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipY3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipY3D.extend = cc.Class.extend; })()"); } @@ -31419,8 +29877,8 @@ bool js_cocos2dx_Lens3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -31469,32 +29927,20 @@ void js_register_cocos2dx_Lens3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Lens3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Lens3D_class, js_cocos2dx_Lens3D_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, "Lens3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Lens3D_class; - p->proto = jsb_cocos2d_Lens3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Lens3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Lens3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Ripple3D_class; @@ -31697,8 +30143,8 @@ bool js_cocos2dx_Ripple3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -31748,32 +30194,20 @@ void js_register_cocos2dx_Ripple3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Ripple3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Ripple3D_class, js_cocos2dx_Ripple3D_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, "Ripple3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Ripple3D_class; - p->proto = jsb_cocos2d_Ripple3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Ripple3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Ripple3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Shaky3D_class; @@ -31854,8 +30288,8 @@ bool js_cocos2dx_Shaky3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -31899,32 +30333,20 @@ void js_register_cocos2dx_Shaky3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Shaky3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Shaky3D_class, js_cocos2dx_Shaky3D_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, "Shaky3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Shaky3D_class; - p->proto = jsb_cocos2d_Shaky3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Shaky3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Shaky3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Liquid_class; @@ -32081,8 +30503,8 @@ bool js_cocos2dx_Liquid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -32130,32 +30552,20 @@ void js_register_cocos2dx_Liquid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Liquid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Liquid_class, js_cocos2dx_Liquid_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, "Liquid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Liquid_class; - p->proto = jsb_cocos2d_Liquid_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Liquid_prototype); + jsb_register_class(cx, jsb_cocos2d_Liquid_class, proto, parent_proto); } JSClass *jsb_cocos2d_Waves_class; @@ -32320,8 +30730,8 @@ bool js_cocos2dx_Waves_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -32369,32 +30779,20 @@ void js_register_cocos2dx_Waves(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Waves_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Waves_class, js_cocos2dx_Waves_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, "Waves", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Waves_class; - p->proto = jsb_cocos2d_Waves_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Waves_prototype); + jsb_register_class(cx, jsb_cocos2d_Waves_class, proto, parent_proto); } JSClass *jsb_cocos2d_Twirl_class; @@ -32593,8 +30991,8 @@ bool js_cocos2dx_Twirl_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -32644,32 +31042,20 @@ void js_register_cocos2dx_Twirl(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Twirl_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Twirl_class, js_cocos2dx_Twirl_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, "Twirl", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Twirl_class; - p->proto = jsb_cocos2d_Twirl_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Twirl_prototype); + jsb_register_class(cx, jsb_cocos2d_Twirl_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionManager_class; @@ -32691,7 +31077,7 @@ bool js_cocos2dx_ActionManager_getActionByTag(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (const cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32730,7 +31116,7 @@ bool js_cocos2dx_ActionManager_removeActionByTag(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32760,7 +31146,7 @@ bool js_cocos2dx_ActionManager_removeActionsByFlags(JSContext *cx, uint32_t argc if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32806,7 +31192,7 @@ bool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -32815,7 +31201,7 @@ bool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32844,7 +31230,7 @@ bool js_cocos2dx_ActionManager_resumeTarget(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -32892,7 +31278,7 @@ bool js_cocos2dx_ActionManager_pauseTarget(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -32920,7 +31306,7 @@ bool js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -32950,7 +31336,7 @@ bool js_cocos2dx_ActionManager_removeAllActionsFromTarget(JSContext *cx, uint32_ 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -32998,7 +31384,7 @@ bool js_cocos2dx_ActionManager_removeAction(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -33028,7 +31414,7 @@ bool js_cocos2dx_ActionManager_removeAllActionsByTag(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -33076,8 +31462,8 @@ bool js_cocos2dx_ActionManager_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -33148,30 +31534,17 @@ void js_register_cocos2dx_ActionManager(JSContext *cx, JS::HandleObject global) jsb_cocos2d_ActionManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ActionManager_class, js_cocos2dx_ActionManager_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, "ActionManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ActionManager_class; - p->proto = jsb_cocos2d_ActionManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionManager_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionManager_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.ActionManager.extend = cc.Class.extend; })()"); } @@ -33238,32 +31611,20 @@ void js_register_cocos2dx_PageTurn3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_PageTurn3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_PageTurn3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PageTurn3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_PageTurn3D_class; - p->proto = jsb_cocos2d_PageTurn3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PageTurn3D_prototype); + jsb_register_class(cx, jsb_cocos2d_PageTurn3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_ProgressTo_class; @@ -33336,8 +31697,8 @@ bool js_cocos2dx_ProgressTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -33398,32 +31759,20 @@ void js_register_cocos2dx_ProgressTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ProgressTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ProgressTo_class, js_cocos2dx_ProgressTo_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, "ProgressTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ProgressTo_class; - p->proto = jsb_cocos2d_ProgressTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProgressTo_prototype); + jsb_register_class(cx, jsb_cocos2d_ProgressTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ProgressTo.extend = cc.Class.extend; })()"); } @@ -33501,8 +31850,8 @@ bool js_cocos2dx_ProgressFromTo_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -33563,32 +31912,20 @@ void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ProgressFromTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ProgressFromTo_class, js_cocos2dx_ProgressFromTo_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, "ProgressFromTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ProgressFromTo_class; - p->proto = jsb_cocos2d_ProgressFromTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProgressFromTo_prototype); + jsb_register_class(cx, jsb_cocos2d_ProgressFromTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ProgressFromTo.extend = cc.Class.extend; })()"); } @@ -33670,8 +32007,8 @@ bool js_cocos2dx_ShakyTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -33715,32 +32052,20 @@ void js_register_cocos2dx_ShakyTiles3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_ShakyTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_ShakyTiles3D_class, js_cocos2dx_ShakyTiles3D_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, "ShakyTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ShakyTiles3D_class; - p->proto = jsb_cocos2d_ShakyTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ShakyTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_ShakyTiles3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_ShatteredTiles3D_class; @@ -33821,8 +32146,8 @@ bool js_cocos2dx_ShatteredTiles3D_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -33866,32 +32191,20 @@ void js_register_cocos2dx_ShatteredTiles3D(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_ShatteredTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_ShatteredTiles3D_class, js_cocos2dx_ShatteredTiles3D_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, "ShatteredTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ShatteredTiles3D_class; - p->proto = jsb_cocos2d_ShatteredTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ShatteredTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_ShatteredTiles3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_ShuffleTiles_class; @@ -34036,8 +32349,8 @@ bool js_cocos2dx_ShuffleTiles_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -34084,32 +32397,20 @@ void js_register_cocos2dx_ShuffleTiles(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_ShuffleTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_ShuffleTiles_class, js_cocos2dx_ShuffleTiles_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, "ShuffleTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ShuffleTiles_class; - p->proto = jsb_cocos2d_ShuffleTiles_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ShuffleTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_ShuffleTiles_class, proto, parent_proto); } JSClass *jsb_cocos2d_FadeOutTRTiles_class; @@ -34244,8 +32545,8 @@ bool js_cocos2dx_FadeOutTRTiles_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -34309,32 +32610,20 @@ void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_FadeOutTRTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_FadeOutTRTiles_class, js_cocos2dx_FadeOutTRTiles_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, "FadeOutTRTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FadeOutTRTiles_class; - p->proto = jsb_cocos2d_FadeOutTRTiles_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutTRTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutTRTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutTRTiles.extend = cc.Class.extend; })()"); } @@ -34384,8 +32673,8 @@ bool js_cocos2dx_FadeOutBLTiles_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -34445,32 +32734,20 @@ void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeOutTRTiles_prototype); jsb_cocos2d_FadeOutBLTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeOutTRTiles_prototype), + parent_proto, jsb_cocos2d_FadeOutBLTiles_class, js_cocos2dx_FadeOutBLTiles_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, "FadeOutBLTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FadeOutBLTiles_class; - p->proto = jsb_cocos2d_FadeOutBLTiles_prototype; - p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutBLTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutBLTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutBLTiles.extend = cc.Class.extend; })()"); } @@ -34520,8 +32797,8 @@ bool js_cocos2dx_FadeOutUpTiles_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -34581,32 +32858,20 @@ void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeOutTRTiles_prototype); jsb_cocos2d_FadeOutUpTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeOutTRTiles_prototype), + parent_proto, jsb_cocos2d_FadeOutUpTiles_class, js_cocos2dx_FadeOutUpTiles_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, "FadeOutUpTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FadeOutUpTiles_class; - p->proto = jsb_cocos2d_FadeOutUpTiles_prototype; - p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutUpTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutUpTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutUpTiles.extend = cc.Class.extend; })()"); } @@ -34656,8 +32921,8 @@ bool js_cocos2dx_FadeOutDownTiles_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -34717,32 +32982,20 @@ void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeOutUpTiles_prototype); jsb_cocos2d_FadeOutDownTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeOutUpTiles_prototype), + parent_proto, jsb_cocos2d_FadeOutDownTiles_class, js_cocos2dx_FadeOutDownTiles_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, "FadeOutDownTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_FadeOutDownTiles_class; - p->proto = jsb_cocos2d_FadeOutDownTiles_prototype; - p->parentProto = jsb_cocos2d_FadeOutUpTiles_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutDownTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutDownTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutDownTiles.extend = cc.Class.extend; })()"); } @@ -34910,8 +33163,8 @@ bool js_cocos2dx_TurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -34958,32 +33211,20 @@ void js_register_cocos2dx_TurnOffTiles(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_TurnOffTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_TurnOffTiles_class, js_cocos2dx_TurnOffTiles_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, "TurnOffTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TurnOffTiles_class; - p->proto = jsb_cocos2d_TurnOffTiles_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TurnOffTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_TurnOffTiles_class, proto, parent_proto); } JSClass *jsb_cocos2d_WavesTiles3D_class; @@ -35140,8 +33381,8 @@ bool js_cocos2dx_WavesTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -35189,32 +33430,20 @@ void js_register_cocos2dx_WavesTiles3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_WavesTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_WavesTiles3D_class, js_cocos2dx_WavesTiles3D_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, "WavesTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_WavesTiles3D_class; - p->proto = jsb_cocos2d_WavesTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_WavesTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_WavesTiles3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_JumpTiles3D_class; @@ -35371,8 +33600,8 @@ bool js_cocos2dx_JumpTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -35437,32 +33666,20 @@ void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_JumpTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_JumpTiles3D_class, js_cocos2dx_JumpTiles3D_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, "JumpTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_JumpTiles3D_class; - p->proto = jsb_cocos2d_JumpTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_JumpTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_JumpTiles3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.JumpTiles3D.extend = cc.Class.extend; })()"); } @@ -35536,8 +33753,8 @@ bool js_cocos2dx_SplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -35581,32 +33798,20 @@ void js_register_cocos2dx_SplitRows(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_SplitRows_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_SplitRows_class, js_cocos2dx_SplitRows_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, "SplitRows", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SplitRows_class; - p->proto = jsb_cocos2d_SplitRows_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SplitRows_prototype); + jsb_register_class(cx, jsb_cocos2d_SplitRows_class, proto, parent_proto); } JSClass *jsb_cocos2d_SplitCols_class; @@ -35679,8 +33884,8 @@ bool js_cocos2dx_SplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -35724,32 +33929,20 @@ void js_register_cocos2dx_SplitCols(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_SplitCols_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_SplitCols_class, js_cocos2dx_SplitCols_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, "SplitCols", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SplitCols_class; - p->proto = jsb_cocos2d_SplitCols_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SplitCols_prototype); + jsb_register_class(cx, jsb_cocos2d_SplitCols_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionTween_class; @@ -35848,32 +34041,20 @@ void js_register_cocos2dx_ActionTween(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionTween_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionTween_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionTween", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ActionTween_class; - p->proto = jsb_cocos2d_ActionTween_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionTween_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionTween_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ActionTween.extend = cc.Class.extend; })()"); } @@ -35963,7 +34144,7 @@ bool js_cocos2dx_AtlasNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36072,7 +34253,7 @@ bool js_cocos2dx_AtlasNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36103,7 +34284,7 @@ bool js_cocos2dx_AtlasNode_initWithTexture(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36189,8 +34370,8 @@ bool js_cocos2dx_AtlasNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -36244,32 +34425,20 @@ void js_register_cocos2dx_AtlasNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_AtlasNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_AtlasNode_class, js_cocos2dx_AtlasNode_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, "AtlasNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_AtlasNode_class; - p->proto = jsb_cocos2d_AtlasNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AtlasNode_prototype); + jsb_register_class(cx, jsb_cocos2d_AtlasNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_ClippingNode_class; @@ -36327,7 +34496,7 @@ bool js_cocos2dx_ClippingNode_setStencil(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -36434,7 +34603,7 @@ bool js_cocos2dx_ClippingNode_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -36490,8 +34659,8 @@ bool js_cocos2dx_ClippingNode_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -36541,32 +34710,20 @@ void js_register_cocos2dx_ClippingNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ClippingNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ClippingNode_class, js_cocos2dx_ClippingNode_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, "ClippingNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ClippingNode_class; - p->proto = jsb_cocos2d_ClippingNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ClippingNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ClippingNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_DrawNode_class; @@ -36603,7 +34760,7 @@ bool js_cocos2dx_DrawNode_drawPoints(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawPoints : Invalid Native Object"); @@ -36654,7 +34811,7 @@ bool js_cocos2dx_DrawNode_drawRect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawRect : Invalid Native Object"); @@ -36708,7 +34865,7 @@ bool js_cocos2dx_DrawNode_drawSolidCircle(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawSolidCircle : Invalid Native Object"); @@ -36877,7 +35034,7 @@ bool js_cocos2dx_DrawNode_drawCatmullRom(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PointArray*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36966,7 +35123,7 @@ bool js_cocos2dx_DrawNode_drawCircle(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawCircle : Invalid Native Object"); @@ -37182,7 +35339,7 @@ bool js_cocos2dx_DrawNode_drawCardinalSpline(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PointArray*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -37314,8 +35471,8 @@ bool js_cocos2dx_DrawNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -37398,32 +35555,20 @@ void js_register_cocos2dx_DrawNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_DrawNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_DrawNode_class, js_cocos2dx_DrawNode_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, "DrawNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_DrawNode_class; - p->proto = jsb_cocos2d_DrawNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_DrawNode_prototype); + jsb_register_class(cx, jsb_cocos2d_DrawNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.DrawNode.extend = cc.Class.extend; })()"); } @@ -37560,7 +35705,7 @@ bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Label *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_disableEffect : Invalid Native Object"); @@ -38049,7 +36194,7 @@ bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Label *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setCharMap : Invalid Native Object"); @@ -38060,7 +36205,7 @@ bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -38535,7 +36680,7 @@ bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Label *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setAlignment : Invalid Native Object"); @@ -38732,7 +36877,7 @@ bool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -38933,8 +37078,8 @@ bool js_cocos2dx_Label_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -39050,32 +37195,20 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Label_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Label_class, js_cocos2dx_Label_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, "Label", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Label_class; - p->proto = jsb_cocos2d_Label_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Label_prototype); + jsb_register_class(cx, jsb_cocos2d_Label_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Label.extend = cc.Class.extend; })()"); } @@ -39109,7 +37242,7 @@ bool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelAtlas_initWithString : Invalid Native Object"); @@ -39164,7 +37297,7 @@ bool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -39303,8 +37436,8 @@ bool js_cocos2dx_LabelAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -39367,32 +37500,20 @@ void js_register_cocos2dx_LabelAtlas(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_AtlasNode_prototype); jsb_cocos2d_LabelAtlas_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_AtlasNode_prototype), + parent_proto, jsb_cocos2d_LabelAtlas_class, js_cocos2dx_LabelAtlas_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, "LabelAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_LabelAtlas_class; - p->proto = jsb_cocos2d_LabelAtlas_prototype; - p->parentProto = jsb_cocos2d_AtlasNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LabelAtlas_prototype); + jsb_register_class(cx, jsb_cocos2d_LabelAtlas_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LabelAtlas.extend = cc.Class.extend; })()"); } @@ -39831,8 +37952,8 @@ bool js_cocos2dx_LabelBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -39903,32 +38024,20 @@ void js_register_cocos2dx_LabelBMFont(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_LabelBMFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_LabelBMFont_class, js_cocos2dx_LabelBMFont_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, "LabelBMFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_LabelBMFont_class; - p->proto = jsb_cocos2d_LabelBMFont_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LabelBMFont_prototype); + jsb_register_class(cx, jsb_cocos2d_LabelBMFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LabelBMFont.extend = cc.Class.extend; })()"); } @@ -40721,8 +38830,8 @@ bool js_cocos2dx_LabelTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -40808,32 +38917,20 @@ void js_register_cocos2dx_LabelTTF(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_LabelTTF_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_LabelTTF_class, js_cocos2dx_LabelTTF_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, "LabelTTF", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_LabelTTF_class; - p->proto = jsb_cocos2d_LabelTTF_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LabelTTF_prototype); + jsb_register_class(cx, jsb_cocos2d_LabelTTF_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LabelTTF.extend = cc.Class.extend; })()"); } @@ -40877,8 +38974,8 @@ bool js_cocos2dx_Layer_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -40938,32 +39035,20 @@ void js_register_cocos2dx_Layer(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Layer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Layer_class, js_cocos2dx_Layer_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, "Layer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Layer_class; - p->proto = jsb_cocos2d_Layer_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Layer_prototype); + jsb_register_class(cx, jsb_cocos2d_Layer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Layer.extend = cc.Class.extend; })()"); } @@ -41007,8 +39092,8 @@ bool js_cocos2dx___LayerRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -41051,32 +39136,20 @@ void js_register_cocos2dx___LayerRGBA(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d___LayerRGBA_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d___LayerRGBA_class, js_cocos2dx___LayerRGBA_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, "LayerRGBA", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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___LayerRGBA_class; - p->proto = jsb_cocos2d___LayerRGBA_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d___LayerRGBA_prototype); + jsb_register_class(cx, jsb_cocos2d___LayerRGBA_class, proto, parent_proto); } JSClass *jsb_cocos2d_LayerColor_class; @@ -41169,7 +39242,7 @@ bool js_cocos2dx_LayerColor_initWithColor(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_initWithColor : Invalid Native Object"); @@ -41314,8 +39387,8 @@ bool js_cocos2dx_LayerColor_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -41381,32 +39454,20 @@ void js_register_cocos2dx_LayerColor(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_LayerColor_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_LayerColor_class, js_cocos2dx_LayerColor_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, "LayerColor", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_LayerColor_class; - p->proto = jsb_cocos2d_LayerColor_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LayerColor_prototype); + jsb_register_class(cx, jsb_cocos2d_LayerColor_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LayerColor.extend = cc.Class.extend; })()"); } @@ -41592,7 +39653,7 @@ bool js_cocos2dx_LayerGradient_initWithColor(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_initWithColor : Invalid Native Object"); @@ -41779,8 +39840,8 @@ bool js_cocos2dx_LayerGradient_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -41853,32 +39914,20 @@ void js_register_cocos2dx_LayerGradient(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_LayerColor_prototype); jsb_cocos2d_LayerGradient_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_LayerColor_prototype), + parent_proto, jsb_cocos2d_LayerGradient_class, js_cocos2dx_LayerGradient_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, "LayerGradient", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_LayerGradient_class; - p->proto = jsb_cocos2d_LayerGradient_prototype; - p->parentProto = jsb_cocos2d_LayerColor_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LayerGradient_prototype); + jsb_register_class(cx, jsb_cocos2d_LayerGradient_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LayerGradient.extend = cc.Class.extend; })()"); } @@ -41941,7 +39990,7 @@ bool js_cocos2dx_LayerMultiplex_addLayer(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Layer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -41991,8 +40040,8 @@ bool js_cocos2dx_LayerMultiplex_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -42053,32 +40102,20 @@ void js_register_cocos2dx_LayerMultiplex(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_LayerMultiplex_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_LayerMultiplex_class, js_cocos2dx_LayerMultiplex_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, "LayerMultiplex", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_LayerMultiplex_class; - p->proto = jsb_cocos2d_LayerMultiplex_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LayerMultiplex_prototype); + jsb_register_class(cx, jsb_cocos2d_LayerMultiplex_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LayerMultiplex.extend = cc.Class.extend; })()"); } @@ -42134,7 +40171,8 @@ bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval * do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -42223,6 +40261,55 @@ bool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_MenuItem_isSelected : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_MenuItem_setCallback(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::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_setCallback : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + bool succeed = func->invoke(1, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItem_setCallback : Error processing arguments"); + cobj->setCallback(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_setCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -42273,8 +40360,8 @@ bool js_cocos2dx_MenuItem_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -42331,6 +40418,7 @@ void js_register_cocos2dx_MenuItem(JSContext *cx, JS::HandleObject global) { JS_FN("isEnabled", js_cocos2dx_MenuItem_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("selected", js_cocos2dx_MenuItem_selected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSelected", js_cocos2dx_MenuItem_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCallback", js_cocos2dx_MenuItem_setCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("unselected", js_cocos2dx_MenuItem_unselected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rect", js_cocos2dx_MenuItem_rect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_MenuItem_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -42339,32 +40427,20 @@ void js_register_cocos2dx_MenuItem(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_MenuItem_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_MenuItem_class, js_cocos2dx_MenuItem_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, "MenuItem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MenuItem_class; - p->proto = jsb_cocos2d_MenuItem_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItem_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItem_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItem.extend = cc.Class.extend; })()"); } @@ -42385,7 +40461,7 @@ bool js_cocos2dx_MenuItemLabel_setLabel(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -42452,7 +40528,7 @@ bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -42460,7 +40536,8 @@ bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -42558,8 +40635,8 @@ bool js_cocos2dx_MenuItemLabel_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -42622,32 +40699,20 @@ void js_register_cocos2dx_MenuItemLabel(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItem_prototype); jsb_cocos2d_MenuItemLabel_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + parent_proto, jsb_cocos2d_MenuItemLabel_class, js_cocos2dx_MenuItemLabel_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, "MenuItemLabel", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MenuItemLabel_class; - p->proto = jsb_cocos2d_MenuItemLabel_prototype; - p->parentProto = jsb_cocos2d_MenuItem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemLabel_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemLabel_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemLabel.extend = cc.Class.extend; })()"); } @@ -42677,7 +40742,8 @@ bool js_cocos2dx_MenuItemAtlasFont_initWithString(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(5)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(5))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(5))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -42730,8 +40796,8 @@ bool js_cocos2dx_MenuItemAtlasFont_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -42789,32 +40855,20 @@ void js_register_cocos2dx_MenuItemAtlasFont(JSContext *cx, JS::HandleObject glob JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItemLabel_prototype); jsb_cocos2d_MenuItemAtlasFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItemLabel_prototype), + parent_proto, jsb_cocos2d_MenuItemAtlasFont_class, js_cocos2dx_MenuItemAtlasFont_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, "MenuItemAtlasFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MenuItemAtlasFont_class; - p->proto = jsb_cocos2d_MenuItemAtlasFont_prototype; - p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemAtlasFont_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemAtlasFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemAtlasFont.extend = cc.Class.extend; })()"); } @@ -42894,7 +40948,8 @@ bool js_cocos2dx_MenuItemFont_initWithString(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -43025,8 +41080,8 @@ bool js_cocos2dx_MenuItemFont_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -43094,32 +41149,20 @@ void js_register_cocos2dx_MenuItemFont(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItemLabel_prototype); jsb_cocos2d_MenuItemFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItemLabel_prototype), + parent_proto, jsb_cocos2d_MenuItemFont_class, js_cocos2dx_MenuItemFont_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, "MenuItemFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MenuItemFont_class; - p->proto = jsb_cocos2d_MenuItemFont_prototype; - p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemFont_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemFont.extend = cc.Class.extend; })()"); } @@ -43176,7 +41219,7 @@ bool js_cocos2dx_MenuItemSprite_setNormalImage(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -43204,7 +41247,7 @@ bool js_cocos2dx_MenuItemSprite_setDisabledImage(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -43235,7 +41278,7 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -43244,7 +41287,7 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -43253,7 +41296,7 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -43261,7 +41304,8 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -43312,7 +41356,7 @@ bool js_cocos2dx_MenuItemSprite_setSelectedImage(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -43433,8 +41477,8 @@ bool js_cocos2dx_MenuItemSprite_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -43501,32 +41545,20 @@ void js_register_cocos2dx_MenuItemSprite(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItem_prototype); jsb_cocos2d_MenuItemSprite_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + parent_proto, jsb_cocos2d_MenuItemSprite_class, js_cocos2dx_MenuItemSprite_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, "MenuItemSprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MenuItemSprite_class; - p->proto = jsb_cocos2d_MenuItemSprite_prototype; - p->parentProto = jsb_cocos2d_MenuItem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemSprite_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemSprite_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemSprite.extend = cc.Class.extend; })()"); } @@ -43547,7 +41579,7 @@ bool js_cocos2dx_MenuItemImage_setDisabledSpriteFrame(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43575,7 +41607,7 @@ bool js_cocos2dx_MenuItemImage_setSelectedSpriteFrame(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43603,7 +41635,7 @@ bool js_cocos2dx_MenuItemImage_setNormalSpriteFrame(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43654,7 +41686,8 @@ bool js_cocos2dx_MenuItemImage_initWithNormalImage(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -43707,8 +41740,8 @@ bool js_cocos2dx_MenuItemImage_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -43770,32 +41803,20 @@ void js_register_cocos2dx_MenuItemImage(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItemSprite_prototype); jsb_cocos2d_MenuItemImage_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItemSprite_prototype), + parent_proto, jsb_cocos2d_MenuItemImage_class, js_cocos2dx_MenuItemImage_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, "MenuItemImage", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MenuItemImage_class; - p->proto = jsb_cocos2d_MenuItemImage_prototype; - p->parentProto = jsb_cocos2d_MenuItemSprite_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemImage_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemImage_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemImage.extend = cc.Class.extend; })()"); } @@ -43836,7 +41857,7 @@ bool js_cocos2dx_MenuItemToggle_initWithItem(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MenuItem*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43884,7 +41905,7 @@ bool js_cocos2dx_MenuItemToggle_addSubItem(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MenuItem*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43959,8 +41980,8 @@ bool js_cocos2dx_MenuItemToggle_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -44023,32 +42044,20 @@ void js_register_cocos2dx_MenuItemToggle(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItem_prototype); jsb_cocos2d_MenuItemToggle_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + parent_proto, jsb_cocos2d_MenuItemToggle_class, js_cocos2dx_MenuItemToggle_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, "MenuItemToggle", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MenuItemToggle_class; - p->proto = jsb_cocos2d_MenuItemToggle_prototype; - p->parentProto = jsb_cocos2d_MenuItem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemToggle_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemToggle_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemToggle.extend = cc.Class.extend; })()"); } @@ -44203,8 +42212,8 @@ bool js_cocos2dx_Menu_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -44268,32 +42277,20 @@ void js_register_cocos2dx_Menu(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_Menu_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_Menu_class, js_cocos2dx_Menu_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, "Menu", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Menu_class; - p->proto = jsb_cocos2d_Menu_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Menu_prototype); + jsb_register_class(cx, jsb_cocos2d_Menu_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Menu.extend = cc.Class.extend; })()"); } @@ -44330,7 +42327,7 @@ bool js_cocos2dx_MotionStreak_setTexture(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -44508,7 +42505,7 @@ bool js_cocos2dx_MotionStreak_initWithFade(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_initWithFade : Invalid Native Object"); @@ -44531,7 +42528,7 @@ bool js_cocos2dx_MotionStreak_initWithFade(JSContext *cx, uint32_t argc, jsval * if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -44637,7 +42634,7 @@ bool js_cocos2dx_MotionStreak_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -44708,8 +42705,8 @@ bool js_cocos2dx_MotionStreak_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -44782,32 +42779,20 @@ void js_register_cocos2dx_MotionStreak(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_MotionStreak_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_MotionStreak_class, js_cocos2dx_MotionStreak_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, "MotionStreak", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_MotionStreak_class; - p->proto = jsb_cocos2d_MotionStreak_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MotionStreak_prototype); + jsb_register_class(cx, jsb_cocos2d_MotionStreak_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MotionStreak.extend = cc.Class.extend; })()"); } @@ -44828,7 +42813,7 @@ bool js_cocos2dx_NodeGrid_setTarget(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -44849,7 +42834,7 @@ bool js_cocos2dx_NodeGrid_getGrid(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_NodeGrid_getGrid : Invalid Native Object"); @@ -44968,8 +42953,8 @@ bool js_cocos2dx_NodeGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -45015,32 +43000,20 @@ void js_register_cocos2dx_NodeGrid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_NodeGrid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_NodeGrid_class, js_cocos2dx_NodeGrid_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, "NodeGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_NodeGrid_class; - p->proto = jsb_cocos2d_NodeGrid_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NodeGrid_prototype); + jsb_register_class(cx, jsb_cocos2d_NodeGrid_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleBatchNode_class; @@ -45060,7 +43033,7 @@ bool js_cocos2dx_ParticleBatchNode_setTexture(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45089,7 +43062,7 @@ bool js_cocos2dx_ParticleBatchNode_initWithTexture(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45165,7 +43138,7 @@ bool js_cocos2dx_ParticleBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45301,7 +43274,7 @@ bool js_cocos2dx_ParticleBatchNode_insertChild(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ParticleSystem*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45392,7 +43365,7 @@ bool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45418,7 +43391,7 @@ bool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45458,8 +43431,8 @@ bool js_cocos2dx_ParticleBatchNode_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -45532,32 +43505,20 @@ void js_register_cocos2dx_ParticleBatchNode(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParticleBatchNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParticleBatchNode_class, js_cocos2dx_ParticleBatchNode_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, "ParticleBatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleBatchNode_class; - p->proto = jsb_cocos2d_ParticleBatchNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleBatchNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleBatchNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ParticleBatchNode.extend = cc.Class.extend; })()"); } @@ -45654,8 +43615,8 @@ bool js_cocos2dx_ParticleData_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -45670,7 +43631,9 @@ void js_cocos2d_ParticleData_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleData)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; - jsproxy = jsb_get_js_proxy(obj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { cocos2d::ParticleData *nobj = static_cast(jsproxy->ptr); nproxy = jsb_get_native_proxy(jsproxy->ptr); @@ -45712,30 +43675,17 @@ void js_register_cocos2dx_ParticleData(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ParticleData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ParticleData_class, js_cocos2dx_ParticleData_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, "ParticleData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleData_class; - p->proto = jsb_cocos2d_ParticleData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleData_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleData_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ParticleSystem_class; @@ -46281,7 +44231,7 @@ bool js_cocos2dx_ParticleSystem_setTexture(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -46969,7 +44919,7 @@ bool js_cocos2dx_ParticleSystem_setBatchNode(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ParticleBatchNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -47498,7 +45448,7 @@ bool js_cocos2dx_ParticleSystem_initWithDictionary(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_initWithDictionary : Invalid Native Object"); @@ -47712,8 +45662,8 @@ bool js_cocos2dx_ParticleSystem_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -47872,32 +45822,20 @@ void js_register_cocos2dx_ParticleSystem(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParticleSystem_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParticleSystem_class, js_cocos2dx_ParticleSystem_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, "ParticleSystem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleSystem_class; - p->proto = jsb_cocos2d_ParticleSystem_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSystem_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSystem_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ParticleSystem.extend = cc.Class.extend; })()"); } @@ -47918,7 +45856,7 @@ bool js_cocos2dx_ParticleSystemQuad_setDisplayFrame(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -47947,7 +45885,7 @@ bool js_cocos2dx_ParticleSystemQuad_setTextureWithRect(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -47976,7 +45914,7 @@ bool js_cocos2dx_ParticleSystemQuad_listenRendererRecreated(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventCustom*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -48095,8 +46033,8 @@ bool js_cocos2dx_ParticleSystemQuad_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -48143,32 +46081,20 @@ void js_register_cocos2dx_ParticleSystemQuad(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystem_prototype); jsb_cocos2d_ParticleSystemQuad_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystem_prototype), + parent_proto, jsb_cocos2d_ParticleSystemQuad_class, js_cocos2dx_ParticleSystemQuad_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, "ParticleSystem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleSystemQuad_class; - p->proto = jsb_cocos2d_ParticleSystemQuad_prototype; - p->parentProto = jsb_cocos2d_ParticleSystem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSystemQuad_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleFire_class; @@ -48236,8 +46162,8 @@ bool js_cocos2dx_ParticleFire_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -48281,32 +46207,20 @@ void js_register_cocos2dx_ParticleFire(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleFire_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleFire_class, js_cocos2dx_ParticleFire_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, "ParticleFire", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleFire_class; - p->proto = jsb_cocos2d_ParticleFire_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleFire_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleFire_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleFireworks_class; @@ -48414,8 +46328,8 @@ bool js_cocos2dx_ParticleFireworks_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -48461,32 +46375,20 @@ void js_register_cocos2dx_ParticleFireworks(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleFireworks_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleFireworks_class, js_cocos2dx_ParticleFireworks_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, "ParticleFireworks", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleFireworks_class; - p->proto = jsb_cocos2d_ParticleFireworks_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleFireworks_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleFireworks_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSun_class; @@ -48594,8 +46496,8 @@ bool js_cocos2dx_ParticleSun_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -48641,32 +46543,20 @@ void js_register_cocos2dx_ParticleSun(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSun_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSun_class, js_cocos2dx_ParticleSun_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, "ParticleSun", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleSun_class; - p->proto = jsb_cocos2d_ParticleSun_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSun_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSun_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleGalaxy_class; @@ -48774,8 +46664,8 @@ bool js_cocos2dx_ParticleGalaxy_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -48821,32 +46711,20 @@ void js_register_cocos2dx_ParticleGalaxy(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleGalaxy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleGalaxy_class, js_cocos2dx_ParticleGalaxy_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, "ParticleGalaxy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleGalaxy_class; - p->proto = jsb_cocos2d_ParticleGalaxy_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleGalaxy_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleGalaxy_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleFlower_class; @@ -48954,8 +46832,8 @@ bool js_cocos2dx_ParticleFlower_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -49001,32 +46879,20 @@ void js_register_cocos2dx_ParticleFlower(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleFlower_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleFlower_class, js_cocos2dx_ParticleFlower_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, "ParticleFlower", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleFlower_class; - p->proto = jsb_cocos2d_ParticleFlower_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleFlower_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleFlower_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleMeteor_class; @@ -49134,8 +47000,8 @@ bool js_cocos2dx_ParticleMeteor_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -49181,32 +47047,20 @@ void js_register_cocos2dx_ParticleMeteor(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleMeteor_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleMeteor_class, js_cocos2dx_ParticleMeteor_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, "ParticleMeteor", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleMeteor_class; - p->proto = jsb_cocos2d_ParticleMeteor_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleMeteor_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleMeteor_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSpiral_class; @@ -49314,8 +47168,8 @@ bool js_cocos2dx_ParticleSpiral_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -49361,32 +47215,20 @@ void js_register_cocos2dx_ParticleSpiral(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSpiral_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSpiral_class, js_cocos2dx_ParticleSpiral_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, "ParticleSpiral", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleSpiral_class; - p->proto = jsb_cocos2d_ParticleSpiral_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSpiral_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSpiral_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleExplosion_class; @@ -49494,8 +47336,8 @@ bool js_cocos2dx_ParticleExplosion_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -49541,32 +47383,20 @@ void js_register_cocos2dx_ParticleExplosion(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleExplosion_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleExplosion_class, js_cocos2dx_ParticleExplosion_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, "ParticleExplosion", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleExplosion_class; - p->proto = jsb_cocos2d_ParticleExplosion_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleExplosion_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleExplosion_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSmoke_class; @@ -49674,8 +47504,8 @@ bool js_cocos2dx_ParticleSmoke_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -49721,32 +47551,20 @@ void js_register_cocos2dx_ParticleSmoke(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSmoke_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSmoke_class, js_cocos2dx_ParticleSmoke_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, "ParticleSmoke", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleSmoke_class; - p->proto = jsb_cocos2d_ParticleSmoke_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSmoke_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSmoke_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSnow_class; @@ -49854,8 +47672,8 @@ bool js_cocos2dx_ParticleSnow_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -49901,32 +47719,20 @@ void js_register_cocos2dx_ParticleSnow(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSnow_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSnow_class, js_cocos2dx_ParticleSnow_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, "ParticleSnow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleSnow_class; - p->proto = jsb_cocos2d_ParticleSnow_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSnow_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSnow_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleRain_class; @@ -50034,8 +47840,8 @@ bool js_cocos2dx_ParticleRain_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -50081,32 +47887,20 @@ void js_register_cocos2dx_ParticleRain(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleRain_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleRain_class, js_cocos2dx_ParticleRain_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, "ParticleRain", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParticleRain_class; - p->proto = jsb_cocos2d_ParticleRain_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleRain_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleRain_class, proto, parent_proto); } JSClass *jsb_cocos2d_ProgressTimer_class; @@ -50126,7 +47920,7 @@ bool js_cocos2dx_ProgressTimer_initWithSprite(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50212,7 +48006,7 @@ bool js_cocos2dx_ProgressTimer_setSprite(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50314,7 +48108,7 @@ bool js_cocos2dx_ProgressTimer_setReverseDirection(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setReverseDirection : Invalid Native Object"); @@ -50409,7 +48203,7 @@ bool js_cocos2dx_ProgressTimer_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50448,8 +48242,8 @@ bool js_cocos2dx_ProgressTimer_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -50522,32 +48316,20 @@ void js_register_cocos2dx_ProgressTimer(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ProgressTimer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ProgressTimer_class, js_cocos2dx_ProgressTimer_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, "ProgressTimer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ProgressTimer_class; - p->proto = jsb_cocos2d_ProgressTimer_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProgressTimer_prototype); + jsb_register_class(cx, jsb_cocos2d_ProgressTimer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ProgressTimer.extend = cc.Class.extend; })()"); } @@ -50561,7 +48343,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_addProtectedChild : Invalid Native Object"); @@ -50572,7 +48354,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -50594,7 +48376,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -50613,7 +48395,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -50695,7 +48477,7 @@ bool js_cocos2dx_ProtectedNode_reorderProtectedChild(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -50805,7 +48587,7 @@ bool js_cocos2dx_ProtectedNode_removeProtectedChild(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -50822,7 +48604,7 @@ bool js_cocos2dx_ProtectedNode_removeProtectedChild(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -50890,8 +48672,8 @@ bool js_cocos2dx_ProtectedNode_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -50944,32 +48726,20 @@ void js_register_cocos2dx_ProtectedNode(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ProtectedNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ProtectedNode_class, js_cocos2dx_ProtectedNode_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, "ProtectedNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ProtectedNode_class; - p->proto = jsb_cocos2d_ProtectedNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProtectedNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ProtectedNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_Sprite_class; @@ -50982,7 +48752,7 @@ bool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setSpriteFrame : Invalid Native Object"); @@ -50993,7 +48763,7 @@ bool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51026,7 +48796,7 @@ bool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setTexture : Invalid Native Object"); @@ -51037,7 +48807,7 @@ bool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51175,7 +48945,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithTexture : Invalid Native Object"); @@ -51186,7 +48956,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51210,7 +48980,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51231,7 +49001,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51323,7 +49093,7 @@ bool js_cocos2dx_Sprite_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setTextureRect : Invalid Native Object"); @@ -51393,7 +49163,7 @@ bool js_cocos2dx_Sprite_isFrameDisplayed(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51441,7 +49211,7 @@ bool js_cocos2dx_Sprite_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteBatchNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51509,7 +49279,7 @@ bool js_cocos2dx_Sprite_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51649,7 +49419,7 @@ bool js_cocos2dx_Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithFile : Invalid Native Object"); @@ -51744,7 +49514,7 @@ bool js_cocos2dx_Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51832,8 +49602,8 @@ bool js_cocos2dx_Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -51922,32 +49692,20 @@ void js_register_cocos2dx_Sprite(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Sprite_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Sprite_class, js_cocos2dx_Sprite_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, "Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Sprite_class; - p->proto = jsb_cocos2d_Sprite_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sprite_prototype); + jsb_register_class(cx, jsb_cocos2d_Sprite_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Sprite.extend = cc.Class.extend; })()"); } @@ -52084,7 +49842,7 @@ bool js_cocos2dx_RenderTexture_setSprite(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -52260,7 +50018,7 @@ bool js_cocos2dx_RenderTexture_beginWithClear(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_beginWithClear : Invalid Native Object"); @@ -52488,7 +50246,7 @@ bool js_cocos2dx_RenderTexture_initWithWidthAndHeight(JSContext *cx, uint32_t ar JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_initWithWidthAndHeight : Invalid Native Object"); @@ -52637,8 +50395,8 @@ bool js_cocos2dx_RenderTexture_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -52721,32 +50479,20 @@ void js_register_cocos2dx_RenderTexture(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_RenderTexture_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_RenderTexture_class, js_cocos2dx_RenderTexture_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, "RenderTexture", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_RenderTexture_class; - p->proto = jsb_cocos2d_RenderTexture_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RenderTexture_prototype); + jsb_register_class(cx, jsb_cocos2d_RenderTexture_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RenderTexture.extend = cc.Class.extend; })()"); } @@ -52767,7 +50513,7 @@ bool js_cocos2dx_TransitionEaseScene_easeActionWithAction(JSContext *cx, uint32_ 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -52821,30 +50567,17 @@ void js_register_cocos2dx_TransitionEaseScene(JSContext *cx, JS::HandleObject gl jsb_cocos2d_TransitionEaseScene_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TransitionEaseScene_class, empty_constructor, 0, 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, "TransitionEaseScene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionEaseScene_class; - p->proto = jsb_cocos2d_TransitionEaseScene_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionEaseScene_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionEaseScene_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TransitionScene_class; @@ -52907,7 +50640,7 @@ bool js_cocos2dx_TransitionScene_initWithDuration(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -52969,7 +50702,7 @@ bool js_cocos2dx_TransitionScene_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53008,8 +50741,8 @@ bool js_cocos2dx_TransitionScene_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -53074,32 +50807,20 @@ void js_register_cocos2dx_TransitionScene(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Scene_prototype); jsb_cocos2d_TransitionScene_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Scene_prototype), + parent_proto, jsb_cocos2d_TransitionScene_class, js_cocos2dx_TransitionScene_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, "TransitionScene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionScene_class; - p->proto = jsb_cocos2d_TransitionScene_prototype; - p->parentProto = jsb_cocos2d_Scene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionScene_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionScene_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionScene.extend = cc.Class.extend; })()"); } @@ -53123,7 +50844,7 @@ bool js_cocos2dx_TransitionSceneOriented_initWithDuration(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53153,7 +50874,7 @@ bool js_cocos2dx_TransitionSceneOriented_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53193,8 +50914,8 @@ bool js_cocos2dx_TransitionSceneOriented_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -53255,32 +50976,20 @@ void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionSceneOriented_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionSceneOriented_class, js_cocos2dx_TransitionSceneOriented_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, "TransitionSceneOriented", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionSceneOriented_class; - p->proto = jsb_cocos2d_TransitionSceneOriented_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSceneOriented_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSceneOriented.extend = cc.Class.extend; })()"); } @@ -53299,7 +51008,7 @@ bool js_cocos2dx_TransitionRotoZoom_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53338,8 +51047,8 @@ bool js_cocos2dx_TransitionRotoZoom_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -53399,32 +51108,20 @@ void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionRotoZoom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionRotoZoom_class, js_cocos2dx_TransitionRotoZoom_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, "TransitionRotoZoom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionRotoZoom_class; - p->proto = jsb_cocos2d_TransitionRotoZoom_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionRotoZoom_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionRotoZoom_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionRotoZoom.extend = cc.Class.extend; })()"); } @@ -53443,7 +51140,7 @@ bool js_cocos2dx_TransitionJumpZoom_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53482,8 +51179,8 @@ bool js_cocos2dx_TransitionJumpZoom_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -53543,32 +51240,20 @@ void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionJumpZoom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionJumpZoom_class, js_cocos2dx_TransitionJumpZoom_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, "TransitionJumpZoom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionJumpZoom_class; - p->proto = jsb_cocos2d_TransitionJumpZoom_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionJumpZoom_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionJumpZoom_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionJumpZoom.extend = cc.Class.extend; })()"); } @@ -53614,7 +51299,7 @@ bool js_cocos2dx_TransitionMoveInL_easeActionWithAction(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -53649,7 +51334,7 @@ bool js_cocos2dx_TransitionMoveInL_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53688,8 +51373,8 @@ bool js_cocos2dx_TransitionMoveInL_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -53751,32 +51436,20 @@ void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionMoveInL_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInL_class, js_cocos2dx_TransitionMoveInL_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, "TransitionMoveInL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionMoveInL_class; - p->proto = jsb_cocos2d_TransitionMoveInL_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInL_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInL.extend = cc.Class.extend; })()"); } @@ -53795,7 +51468,7 @@ bool js_cocos2dx_TransitionMoveInR_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53834,8 +51507,8 @@ bool js_cocos2dx_TransitionMoveInR_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -53895,32 +51568,20 @@ void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); jsb_cocos2d_TransitionMoveInR_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInR_class, js_cocos2dx_TransitionMoveInR_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, "TransitionMoveInR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionMoveInR_class; - p->proto = jsb_cocos2d_TransitionMoveInR_prototype; - p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInR_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInR_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInR.extend = cc.Class.extend; })()"); } @@ -53939,7 +51600,7 @@ bool js_cocos2dx_TransitionMoveInT_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53978,8 +51639,8 @@ bool js_cocos2dx_TransitionMoveInT_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -54039,32 +51700,20 @@ void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); jsb_cocos2d_TransitionMoveInT_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInT_class, js_cocos2dx_TransitionMoveInT_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, "TransitionMoveInT", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionMoveInT_class; - p->proto = jsb_cocos2d_TransitionMoveInT_prototype; - p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInT_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInT_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInT.extend = cc.Class.extend; })()"); } @@ -54083,7 +51732,7 @@ bool js_cocos2dx_TransitionMoveInB_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54122,8 +51771,8 @@ bool js_cocos2dx_TransitionMoveInB_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -54183,32 +51832,20 @@ void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); jsb_cocos2d_TransitionMoveInB_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInB_class, js_cocos2dx_TransitionMoveInB_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, "TransitionMoveInB", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionMoveInB_class; - p->proto = jsb_cocos2d_TransitionMoveInB_prototype; - p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInB_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInB_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInB.extend = cc.Class.extend; })()"); } @@ -54254,7 +51891,7 @@ bool js_cocos2dx_TransitionSlideInL_easeActionWithAction(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -54289,7 +51926,7 @@ bool js_cocos2dx_TransitionSlideInL_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54328,8 +51965,8 @@ bool js_cocos2dx_TransitionSlideInL_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -54391,32 +52028,20 @@ void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionSlideInL_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInL_class, js_cocos2dx_TransitionSlideInL_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, "TransitionSlideInL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionSlideInL_class; - p->proto = jsb_cocos2d_TransitionSlideInL_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInL_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInL.extend = cc.Class.extend; })()"); } @@ -54435,7 +52060,7 @@ bool js_cocos2dx_TransitionSlideInR_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54474,8 +52099,8 @@ bool js_cocos2dx_TransitionSlideInR_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -54535,32 +52160,20 @@ void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); jsb_cocos2d_TransitionSlideInR_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInR_class, js_cocos2dx_TransitionSlideInR_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, "TransitionSlideInR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionSlideInR_class; - p->proto = jsb_cocos2d_TransitionSlideInR_prototype; - p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInR_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInR_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInR.extend = cc.Class.extend; })()"); } @@ -54579,7 +52192,7 @@ bool js_cocos2dx_TransitionSlideInB_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54618,8 +52231,8 @@ bool js_cocos2dx_TransitionSlideInB_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -54679,32 +52292,20 @@ void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); jsb_cocos2d_TransitionSlideInB_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInB_class, js_cocos2dx_TransitionSlideInB_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, "TransitionSlideInB", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionSlideInB_class; - p->proto = jsb_cocos2d_TransitionSlideInB_prototype; - p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInB_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInB_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInB.extend = cc.Class.extend; })()"); } @@ -54723,7 +52324,7 @@ bool js_cocos2dx_TransitionSlideInT_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54762,8 +52363,8 @@ bool js_cocos2dx_TransitionSlideInT_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -54823,32 +52424,20 @@ void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); jsb_cocos2d_TransitionSlideInT_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInT_class, js_cocos2dx_TransitionSlideInT_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, "TransitionSlideInT", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionSlideInT_class; - p->proto = jsb_cocos2d_TransitionSlideInT_prototype; - p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInT_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInT_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInT.extend = cc.Class.extend; })()"); } @@ -54869,7 +52458,7 @@ bool js_cocos2dx_TransitionShrinkGrow_easeActionWithAction(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -54904,7 +52493,7 @@ bool js_cocos2dx_TransitionShrinkGrow_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54943,8 +52532,8 @@ bool js_cocos2dx_TransitionShrinkGrow_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -55005,32 +52594,20 @@ void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionShrinkGrow_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionShrinkGrow_class, js_cocos2dx_TransitionShrinkGrow_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, "TransitionShrinkGrow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionShrinkGrow_class; - p->proto = jsb_cocos2d_TransitionShrinkGrow_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionShrinkGrow_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionShrinkGrow_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionShrinkGrow.extend = cc.Class.extend; })()"); } @@ -55052,7 +52629,7 @@ bool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55083,7 +52660,7 @@ bool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55125,8 +52702,8 @@ bool js_cocos2dx_TransitionFlipX_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -55186,32 +52763,20 @@ void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionFlipX_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionFlipX_class, js_cocos2dx_TransitionFlipX_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, "TransitionFlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFlipX_class; - p->proto = jsb_cocos2d_TransitionFlipX_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFlipX_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFlipX_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFlipX.extend = cc.Class.extend; })()"); } @@ -55233,7 +52798,7 @@ bool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55264,7 +52829,7 @@ bool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55306,8 +52871,8 @@ bool js_cocos2dx_TransitionFlipY_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -55367,32 +52932,20 @@ void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionFlipY_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionFlipY_class, js_cocos2dx_TransitionFlipY_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, "TransitionFlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFlipY_class; - p->proto = jsb_cocos2d_TransitionFlipY_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFlipY_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFlipY_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFlipY.extend = cc.Class.extend; })()"); } @@ -55414,7 +52967,7 @@ bool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55445,7 +52998,7 @@ bool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55487,8 +53040,8 @@ bool js_cocos2dx_TransitionFlipAngular_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -55548,32 +53101,20 @@ void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionFlipAngular_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionFlipAngular_class, js_cocos2dx_TransitionFlipAngular_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, "TransitionFlipAngular", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFlipAngular_class; - p->proto = jsb_cocos2d_TransitionFlipAngular_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFlipAngular_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFlipAngular_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFlipAngular.extend = cc.Class.extend; })()"); } @@ -55595,7 +53136,7 @@ bool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55626,7 +53167,7 @@ bool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55668,8 +53209,8 @@ bool js_cocos2dx_TransitionZoomFlipX_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -55729,32 +53270,20 @@ void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionZoomFlipX_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionZoomFlipX_class, js_cocos2dx_TransitionZoomFlipX_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, "TransitionZoomFlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionZoomFlipX_class; - p->proto = jsb_cocos2d_TransitionZoomFlipX_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionZoomFlipX_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionZoomFlipX_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipX.extend = cc.Class.extend; })()"); } @@ -55776,7 +53305,7 @@ bool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55807,7 +53336,7 @@ bool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55849,8 +53378,8 @@ bool js_cocos2dx_TransitionZoomFlipY_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -55910,32 +53439,20 @@ void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionZoomFlipY_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionZoomFlipY_class, js_cocos2dx_TransitionZoomFlipY_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, "TransitionZoomFlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionZoomFlipY_class; - p->proto = jsb_cocos2d_TransitionZoomFlipY_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionZoomFlipY_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionZoomFlipY_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipY.extend = cc.Class.extend; })()"); } @@ -55957,7 +53474,7 @@ bool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55988,7 +53505,7 @@ bool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56030,8 +53547,8 @@ bool js_cocos2dx_TransitionZoomFlipAngular_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -56091,32 +53608,20 @@ void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JS::HandleObj JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionZoomFlipAngular_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionZoomFlipAngular_class, js_cocos2dx_TransitionZoomFlipAngular_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, "TransitionZoomFlipAngular", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionZoomFlipAngular_class; - p->proto = jsb_cocos2d_TransitionZoomFlipAngular_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionZoomFlipAngular_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionZoomFlipAngular_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipAngular.extend = cc.Class.extend; })()"); } @@ -56130,7 +53635,7 @@ bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TransitionFade *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionFade_initWithDuration : Invalid Native Object"); @@ -56144,7 +53649,7 @@ bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56168,7 +53673,7 @@ bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56203,7 +53708,7 @@ bool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56234,7 +53739,7 @@ bool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56276,8 +53781,8 @@ bool js_cocos2dx_TransitionFade_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -56338,32 +53843,20 @@ void js_register_cocos2dx_TransitionFade(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionFade_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionFade_class, js_cocos2dx_TransitionFade_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, "TransitionFade", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFade_class; - p->proto = jsb_cocos2d_TransitionFade_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFade_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFade_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFade.extend = cc.Class.extend; })()"); } @@ -56382,7 +53875,7 @@ bool js_cocos2dx_TransitionCrossFade_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56421,8 +53914,8 @@ bool js_cocos2dx_TransitionCrossFade_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -56482,32 +53975,20 @@ void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionCrossFade_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionCrossFade_class, js_cocos2dx_TransitionCrossFade_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, "TransitionCrossFade", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionCrossFade_class; - p->proto = jsb_cocos2d_TransitionCrossFade_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionCrossFade_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionCrossFade_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionCrossFade.extend = cc.Class.extend; })()"); } @@ -56528,7 +54009,7 @@ bool js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction(JSContext *cx, uint 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -56563,7 +54044,7 @@ bool js_cocos2dx_TransitionTurnOffTiles_create(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56602,8 +54083,8 @@ bool js_cocos2dx_TransitionTurnOffTiles_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -56664,32 +54145,20 @@ void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionTurnOffTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionTurnOffTiles_class, js_cocos2dx_TransitionTurnOffTiles_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, "TransitionTurnOffTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionTurnOffTiles_class; - p->proto = jsb_cocos2d_TransitionTurnOffTiles_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionTurnOffTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionTurnOffTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionTurnOffTiles.extend = cc.Class.extend; })()"); } @@ -56735,7 +54204,7 @@ bool js_cocos2dx_TransitionSplitCols_easeActionWithAction(JSContext *cx, uint32_ 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -56770,7 +54239,7 @@ bool js_cocos2dx_TransitionSplitCols_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56809,8 +54278,8 @@ bool js_cocos2dx_TransitionSplitCols_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -56872,32 +54341,20 @@ void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionSplitCols_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionSplitCols_class, js_cocos2dx_TransitionSplitCols_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, "TransitionSplitCols", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionSplitCols_class; - p->proto = jsb_cocos2d_TransitionSplitCols_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSplitCols_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSplitCols_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSplitCols.extend = cc.Class.extend; })()"); } @@ -56916,7 +54373,7 @@ bool js_cocos2dx_TransitionSplitRows_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56955,8 +54412,8 @@ bool js_cocos2dx_TransitionSplitRows_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -57016,32 +54473,20 @@ void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSplitCols_prototype); jsb_cocos2d_TransitionSplitRows_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSplitCols_prototype), + parent_proto, jsb_cocos2d_TransitionSplitRows_class, js_cocos2dx_TransitionSplitRows_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, "TransitionSplitRows", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionSplitRows_class; - p->proto = jsb_cocos2d_TransitionSplitRows_prototype; - p->parentProto = jsb_cocos2d_TransitionSplitCols_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSplitRows_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSplitRows_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSplitRows.extend = cc.Class.extend; })()"); } @@ -57062,7 +54507,7 @@ bool js_cocos2dx_TransitionFadeTR_easeActionWithAction(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -57126,7 +54571,7 @@ bool js_cocos2dx_TransitionFadeTR_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57165,8 +54610,8 @@ bool js_cocos2dx_TransitionFadeTR_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -57228,32 +54673,20 @@ void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionFadeTR_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionFadeTR_class, js_cocos2dx_TransitionFadeTR_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, "TransitionFadeTR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFadeTR_class; - p->proto = jsb_cocos2d_TransitionFadeTR_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeTR_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeTR.extend = cc.Class.extend; })()"); } @@ -57272,7 +54705,7 @@ bool js_cocos2dx_TransitionFadeBL_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57311,8 +54744,8 @@ bool js_cocos2dx_TransitionFadeBL_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -57372,32 +54805,20 @@ void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); jsb_cocos2d_TransitionFadeBL_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + parent_proto, jsb_cocos2d_TransitionFadeBL_class, js_cocos2dx_TransitionFadeBL_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, "TransitionFadeBL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFadeBL_class; - p->proto = jsb_cocos2d_TransitionFadeBL_prototype; - p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeBL_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeBL_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeBL.extend = cc.Class.extend; })()"); } @@ -57416,7 +54837,7 @@ bool js_cocos2dx_TransitionFadeUp_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57455,8 +54876,8 @@ bool js_cocos2dx_TransitionFadeUp_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -57516,32 +54937,20 @@ void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); jsb_cocos2d_TransitionFadeUp_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + parent_proto, jsb_cocos2d_TransitionFadeUp_class, js_cocos2dx_TransitionFadeUp_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, "TransitionFadeUp", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFadeUp_class; - p->proto = jsb_cocos2d_TransitionFadeUp_prototype; - p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeUp_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeUp_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeUp.extend = cc.Class.extend; })()"); } @@ -57560,7 +54969,7 @@ bool js_cocos2dx_TransitionFadeDown_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57599,8 +55008,8 @@ bool js_cocos2dx_TransitionFadeDown_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -57660,32 +55069,20 @@ void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); jsb_cocos2d_TransitionFadeDown_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + parent_proto, jsb_cocos2d_TransitionFadeDown_class, js_cocos2dx_TransitionFadeDown_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, "TransitionFadeDown", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionFadeDown_class; - p->proto = jsb_cocos2d_TransitionFadeDown_prototype; - p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeDown_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeDown_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeDown.extend = cc.Class.extend; })()"); } @@ -57738,7 +55135,7 @@ bool js_cocos2dx_TransitionPageTurn_initWithDuration(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57768,7 +55165,7 @@ bool js_cocos2dx_TransitionPageTurn_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57808,8 +55205,8 @@ bool js_cocos2dx_TransitionPageTurn_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -57871,32 +55268,20 @@ void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionPageTurn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionPageTurn_class, js_cocos2dx_TransitionPageTurn_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, "TransitionPageTurn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionPageTurn_class; - p->proto = jsb_cocos2d_TransitionPageTurn_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionPageTurn_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionPageTurn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionPageTurn.extend = cc.Class.extend; })()"); } @@ -57915,7 +55300,7 @@ bool js_cocos2dx_TransitionProgress_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57954,8 +55339,8 @@ bool js_cocos2dx_TransitionProgress_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -58015,32 +55400,20 @@ void js_register_cocos2dx_TransitionProgress(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionProgress_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionProgress_class, js_cocos2dx_TransitionProgress_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, "TransitionProgress", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionProgress_class; - p->proto = jsb_cocos2d_TransitionProgress_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgress_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgress_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgress.extend = cc.Class.extend; })()"); } @@ -58059,7 +55432,7 @@ bool js_cocos2dx_TransitionProgressRadialCCW_create(JSContext *cx, uint32_t argc if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58098,8 +55471,8 @@ bool js_cocos2dx_TransitionProgressRadialCCW_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -58159,32 +55532,20 @@ void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JS::HandleO JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressRadialCCW_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressRadialCCW_class, js_cocos2dx_TransitionProgressRadialCCW_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, "TransitionProgressRadialCCW", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionProgressRadialCCW_class; - p->proto = jsb_cocos2d_TransitionProgressRadialCCW_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressRadialCCW_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressRadialCCW_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressRadialCCW.extend = cc.Class.extend; })()"); } @@ -58203,7 +55564,7 @@ bool js_cocos2dx_TransitionProgressRadialCW_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58242,8 +55603,8 @@ bool js_cocos2dx_TransitionProgressRadialCW_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -58303,32 +55664,20 @@ void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressRadialCW_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressRadialCW_class, js_cocos2dx_TransitionProgressRadialCW_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, "TransitionProgressRadialCW", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionProgressRadialCW_class; - p->proto = jsb_cocos2d_TransitionProgressRadialCW_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressRadialCW_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressRadialCW_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressRadialCW.extend = cc.Class.extend; })()"); } @@ -58347,7 +55696,7 @@ bool js_cocos2dx_TransitionProgressHorizontal_create(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58386,8 +55735,8 @@ bool js_cocos2dx_TransitionProgressHorizontal_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -58447,32 +55796,20 @@ void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JS::Handle JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressHorizontal_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressHorizontal_class, js_cocos2dx_TransitionProgressHorizontal_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, "TransitionProgressHorizontal", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionProgressHorizontal_class; - p->proto = jsb_cocos2d_TransitionProgressHorizontal_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressHorizontal_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressHorizontal_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressHorizontal.extend = cc.Class.extend; })()"); } @@ -58491,7 +55828,7 @@ bool js_cocos2dx_TransitionProgressVertical_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58530,8 +55867,8 @@ bool js_cocos2dx_TransitionProgressVertical_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -58591,32 +55928,20 @@ void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressVertical_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressVertical_class, js_cocos2dx_TransitionProgressVertical_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, "TransitionProgressVertical", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionProgressVertical_class; - p->proto = jsb_cocos2d_TransitionProgressVertical_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressVertical_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressVertical_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressVertical.extend = cc.Class.extend; })()"); } @@ -58635,7 +55960,7 @@ bool js_cocos2dx_TransitionProgressInOut_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58674,8 +55999,8 @@ bool js_cocos2dx_TransitionProgressInOut_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -58735,32 +56060,20 @@ void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressInOut_class, js_cocos2dx_TransitionProgressInOut_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, "TransitionProgressInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionProgressInOut_class; - p->proto = jsb_cocos2d_TransitionProgressInOut_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressInOut.extend = cc.Class.extend; })()"); } @@ -58779,7 +56092,7 @@ bool js_cocos2dx_TransitionProgressOutIn_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58818,8 +56131,8 @@ bool js_cocos2dx_TransitionProgressOutIn_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -58879,32 +56192,20 @@ void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressOutIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressOutIn_class, js_cocos2dx_TransitionProgressOutIn_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, "TransitionProgressOutIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TransitionProgressOutIn_class; - p->proto = jsb_cocos2d_TransitionProgressOutIn_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressOutIn_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressOutIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressOutIn.extend = cc.Class.extend; })()"); } @@ -58977,7 +56278,7 @@ bool js_cocos2dx_Camera_setBackgroundBrush(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CameraBackgroundBrush*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59293,7 +56594,7 @@ bool js_cocos2dx_Camera_setScene(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59455,7 +56756,7 @@ bool js_cocos2dx_Camera_setFrameBufferObject(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::experimental::FrameBuffer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59687,8 +56988,8 @@ bool js_cocos2dx_Camera_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -59766,32 +57067,20 @@ void js_register_cocos2dx_Camera(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Camera_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Camera_class, js_cocos2dx_Camera_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, "Camera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Camera_class; - p->proto = jsb_cocos2d_Camera_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Camera_prototype); + jsb_register_class(cx, jsb_cocos2d_Camera_class, proto, parent_proto); } JSClass *jsb_cocos2d_CameraBackgroundBrush_class; @@ -59829,7 +57118,7 @@ bool js_cocos2dx_CameraBackgroundBrush_drawBackground(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59999,8 +57288,8 @@ bool js_cocos2dx_CameraBackgroundBrush_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -60049,30 +57338,17 @@ void js_register_cocos2dx_CameraBackgroundBrush(JSContext *cx, JS::HandleObject jsb_cocos2d_CameraBackgroundBrush_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_CameraBackgroundBrush_class, js_cocos2dx_CameraBackgroundBrush_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, "CameraBackgroundBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CameraBackgroundBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundBrush_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundBrush_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_CameraBackgroundDepthBrush_class; @@ -60139,8 +57415,8 @@ bool js_cocos2dx_CameraBackgroundDepthBrush_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -60184,32 +57460,20 @@ void js_register_cocos2dx_CameraBackgroundDepthBrush(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CameraBackgroundBrush_prototype); jsb_cocos2d_CameraBackgroundDepthBrush_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundBrush_prototype), + parent_proto, jsb_cocos2d_CameraBackgroundDepthBrush_class, js_cocos2dx_CameraBackgroundDepthBrush_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, "CameraBackgroundDepthBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CameraBackgroundDepthBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundDepthBrush_prototype; - p->parentProto = jsb_cocos2d_CameraBackgroundBrush_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundDepthBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundDepthBrush_class, proto, parent_proto); } JSClass *jsb_cocos2d_CameraBackgroundColorBrush_class; @@ -60278,8 +57542,8 @@ bool js_cocos2dx_CameraBackgroundColorBrush_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -60323,32 +57587,20 @@ void js_register_cocos2dx_CameraBackgroundColorBrush(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CameraBackgroundDepthBrush_prototype); jsb_cocos2d_CameraBackgroundColorBrush_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundDepthBrush_prototype), + parent_proto, jsb_cocos2d_CameraBackgroundColorBrush_class, js_cocos2dx_CameraBackgroundColorBrush_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, "CameraBackgroundColorBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CameraBackgroundColorBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundColorBrush_prototype; - p->parentProto = jsb_cocos2d_CameraBackgroundDepthBrush_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundColorBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundColorBrush_class, proto, parent_proto); } JSClass *jsb_cocos2d_CameraBackgroundSkyBoxBrush_class; @@ -60368,7 +57620,7 @@ bool js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -60457,8 +57709,8 @@ bool js_cocos2dx_CameraBackgroundSkyBoxBrush_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -60502,32 +57754,20 @@ void js_register_cocos2dx_CameraBackgroundSkyBoxBrush(JSContext *cx, JS::HandleO JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CameraBackgroundBrush_prototype); jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundBrush_prototype), + parent_proto, jsb_cocos2d_CameraBackgroundSkyBoxBrush_class, js_cocos2dx_CameraBackgroundSkyBoxBrush_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, "CameraBackgroundSkyBoxBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CameraBackgroundSkyBoxBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype; - p->parentProto = jsb_cocos2d_CameraBackgroundBrush_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundSkyBoxBrush_class, proto, parent_proto); } JSClass *jsb_cocos2d_GridBase_class; @@ -60621,7 +57861,7 @@ bool js_cocos2dx_GridBase_afterDraw(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -60838,7 +58078,7 @@ bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_initWithSize : Invalid Native Object"); @@ -60881,7 +58121,7 @@ bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -60907,7 +58147,7 @@ bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61034,7 +58274,7 @@ bool js_cocos2dx_GridBase_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61114,30 +58354,17 @@ void js_register_cocos2dx_GridBase(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_GridBase_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GridBase_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "GridBase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_GridBase_class; - p->proto = jsb_cocos2d_GridBase_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GridBase_prototype); + jsb_register_class(cx, jsb_cocos2d_GridBase_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.GridBase.extend = cc.Class.extend; })()"); } @@ -61240,7 +58467,7 @@ bool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61274,7 +58501,7 @@ bool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61319,8 +58546,8 @@ bool js_cocos2dx_Grid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -61382,32 +58609,20 @@ void js_register_cocos2dx_Grid3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridBase_prototype); jsb_cocos2d_Grid3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridBase_prototype), + parent_proto, jsb_cocos2d_Grid3D_class, js_cocos2dx_Grid3D_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, "Grid3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Grid3D_class; - p->proto = jsb_cocos2d_Grid3D_prototype; - p->parentProto = jsb_cocos2d_GridBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Grid3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Grid3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Grid3D.extend = cc.Class.extend; })()"); } @@ -61472,7 +58687,7 @@ bool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61506,7 +58721,7 @@ bool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61551,8 +58766,8 @@ bool js_cocos2dx_TiledGrid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -61612,32 +58827,20 @@ void js_register_cocos2dx_TiledGrid3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridBase_prototype); jsb_cocos2d_TiledGrid3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridBase_prototype), + parent_proto, jsb_cocos2d_TiledGrid3D_class, js_cocos2dx_TiledGrid3D_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, "TiledGrid3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TiledGrid3D_class; - p->proto = jsb_cocos2d_TiledGrid3D_prototype; - p->parentProto = jsb_cocos2d_GridBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TiledGrid3D_prototype); + jsb_register_class(cx, jsb_cocos2d_TiledGrid3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TiledGrid3D.extend = cc.Class.extend; })()"); } @@ -61813,32 +59016,20 @@ void js_register_cocos2dx_BaseLight(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_BaseLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_BaseLight_class, empty_constructor, 0, 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, "BaseLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_BaseLight_class; - p->proto = jsb_cocos2d_BaseLight_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BaseLight_prototype); + jsb_register_class(cx, jsb_cocos2d_BaseLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_DirectionLight_class; @@ -61943,8 +59134,8 @@ bool js_cocos2dx_DirectionLight_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -61990,32 +59181,20 @@ void js_register_cocos2dx_DirectionLight(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_DirectionLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_DirectionLight_class, js_cocos2dx_DirectionLight_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, "DirectionLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_DirectionLight_class; - p->proto = jsb_cocos2d_DirectionLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_DirectionLight_prototype); + jsb_register_class(cx, jsb_cocos2d_DirectionLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_PointLight_class; @@ -62104,8 +59283,8 @@ bool js_cocos2dx_PointLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -62150,32 +59329,20 @@ void js_register_cocos2dx_PointLight(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_PointLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_PointLight_class, js_cocos2dx_PointLight_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, "PointLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_PointLight_class; - p->proto = jsb_cocos2d_PointLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PointLight_prototype); + jsb_register_class(cx, jsb_cocos2d_PointLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_SpotLight_class; @@ -62438,8 +59605,8 @@ bool js_cocos2dx_SpotLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -62493,32 +59660,20 @@ void js_register_cocos2dx_SpotLight(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_SpotLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_SpotLight_class, js_cocos2dx_SpotLight_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, "SpotLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SpotLight_class; - p->proto = jsb_cocos2d_SpotLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpotLight_prototype); + jsb_register_class(cx, jsb_cocos2d_SpotLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_AmbientLight_class; @@ -62565,8 +59720,8 @@ bool js_cocos2dx_AmbientLight_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -62609,32 +59764,20 @@ void js_register_cocos2dx_AmbientLight(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_AmbientLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_AmbientLight_class, js_cocos2dx_AmbientLight_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, "AmbientLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_AmbientLight_class; - p->proto = jsb_cocos2d_AmbientLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AmbientLight_prototype); + jsb_register_class(cx, jsb_cocos2d_AmbientLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_GLProgram_class; @@ -62765,7 +59908,7 @@ bool js_cocos2dx_GLProgram_initWithByteArrays(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_initWithByteArrays : Invalid Native Object"); @@ -62836,7 +59979,7 @@ bool js_cocos2dx_GLProgram_initWithFilenames(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_initWithFilenames : Invalid Native Object"); @@ -62911,7 +60054,7 @@ bool js_cocos2dx_GLProgram_setUniformsForBuiltins(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformsForBuiltins : Invalid Native Object"); @@ -63333,8 +60476,8 @@ bool js_cocos2dx_GLProgram_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -63418,30 +60561,17 @@ void js_register_cocos2dx_GLProgram(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_GLProgram_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLProgram_class, js_cocos2dx_GLProgram_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, "GLProgram", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_GLProgram_class; - p->proto = jsb_cocos2d_GLProgram_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLProgram_prototype); + jsb_register_class(cx, jsb_cocos2d_GLProgram_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.GLProgram.extend = cc.Class.extend; })()"); } @@ -63495,7 +60625,7 @@ bool js_cocos2dx_GLProgramCache_addGLProgram(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63604,8 +60734,8 @@ bool js_cocos2dx_GLProgramCache_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -63654,30 +60784,17 @@ void js_register_cocos2dx_GLProgramCache(JSContext *cx, JS::HandleObject global) jsb_cocos2d_GLProgramCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLProgramCache_class, js_cocos2dx_GLProgramCache_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, "ShaderCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_GLProgramCache_class; - p->proto = jsb_cocos2d_GLProgramCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLProgramCache_prototype); + jsb_register_class(cx, jsb_cocos2d_GLProgramCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_RenderState_class; @@ -63697,7 +60814,7 @@ bool js_cocos2dx_RenderState_setTexture(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63725,7 +60842,7 @@ bool js_cocos2dx_RenderState_getTopmost(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::RenderState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63787,7 +60904,7 @@ bool js_cocos2dx_RenderState_bind(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Pass*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63858,7 +60975,7 @@ bool js_cocos2dx_RenderState_setParent(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::RenderState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63937,30 +61054,17 @@ void js_register_cocos2dx_RenderState(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_RenderState_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_RenderState_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RenderState", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_RenderState_class; - p->proto = jsb_cocos2d_RenderState_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RenderState_prototype); + jsb_register_class(cx, jsb_cocos2d_RenderState_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Pass_class; @@ -63989,7 +61093,7 @@ bool js_cocos2dx_Pass_bind(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Pass *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Pass_bind : Invalid Native Object"); @@ -64127,7 +61231,7 @@ bool js_cocos2dx_Pass_setVertexAttribBinding(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::VertexAttribBinding*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64151,7 +61255,7 @@ bool js_cocos2dx_Pass_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Technique*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64185,7 +61289,7 @@ bool js_cocos2dx_Pass_createWithGLProgramState(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Technique*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64194,7 +61298,7 @@ bool js_cocos2dx_Pass_createWithGLProgramState(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -64258,32 +61362,20 @@ void js_register_cocos2dx_Pass(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_RenderState_prototype); jsb_cocos2d_Pass_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_RenderState_prototype), + parent_proto, jsb_cocos2d_Pass_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Pass", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Pass_class; - p->proto = jsb_cocos2d_Pass_prototype; - p->parentProto = jsb_cocos2d_RenderState_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Pass_prototype); + jsb_register_class(cx, jsb_cocos2d_Pass_class, proto, parent_proto); } JSClass *jsb_cocos2d_Technique_class; @@ -64346,7 +61438,7 @@ bool js_cocos2dx_Technique_addPass(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Pass*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64435,7 +61527,7 @@ bool js_cocos2dx_Technique_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64469,7 +61561,7 @@ bool js_cocos2dx_Technique_createWithGLProgramState(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64478,7 +61570,7 @@ bool js_cocos2dx_Technique_createWithGLProgramState(JSContext *cx, uint32_t argc if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -64541,32 +61633,20 @@ void js_register_cocos2dx_Technique(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_RenderState_prototype); jsb_cocos2d_Technique_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_RenderState_prototype), + parent_proto, jsb_cocos2d_Technique_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Technique", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Technique_class; - p->proto = jsb_cocos2d_Technique_prototype; - p->parentProto = jsb_cocos2d_RenderState_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Technique_prototype); + jsb_register_class(cx, jsb_cocos2d_Technique_class, proto, parent_proto); } JSClass *jsb_cocos2d_Material_class; @@ -64763,7 +61843,7 @@ bool js_cocos2dx_Material_addTechnique(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Technique*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64837,7 +61917,7 @@ bool js_cocos2dx_Material_createWithGLStateProgram(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64870,7 +61950,7 @@ bool js_cocos2dx_Material_createWithProperties(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Properties*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64938,32 +62018,20 @@ void js_register_cocos2dx_Material(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_RenderState_prototype); jsb_cocos2d_Material_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_RenderState_prototype), + parent_proto, jsb_cocos2d_Material_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Material", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Material_class; - p->proto = jsb_cocos2d_Material_prototype; - p->parentProto = jsb_cocos2d_RenderState_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Material_prototype); + jsb_register_class(cx, jsb_cocos2d_Material_class, proto, parent_proto); } JSClass *jsb_cocos2d_TextureCache_class; @@ -65058,7 +62126,8 @@ bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Texture2D* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -65136,7 +62205,7 @@ bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_addImage : Invalid Native Object"); @@ -65147,7 +62216,7 @@ bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -65257,7 +62326,7 @@ bool js_cocos2dx_TextureCache_getTextureFilePath(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -65303,7 +62372,7 @@ bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -65349,8 +62418,8 @@ bool js_cocos2dx_TextureCache_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -65404,30 +62473,17 @@ void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TextureCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TextureCache_class, js_cocos2dx_TextureCache_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, "TextureCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TextureCache_class; - p->proto = jsb_cocos2d_TextureCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TextureCache_prototype); + jsb_register_class(cx, jsb_cocos2d_TextureCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Device_class; @@ -65548,30 +62604,17 @@ void js_register_cocos2dx_Device(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Device_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Device_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Device", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Device_class; - p->proto = jsb_cocos2d_Device_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Device_prototype); + jsb_register_class(cx, jsb_cocos2d_Device_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_SAXParser_class; @@ -65630,30 +62673,17 @@ void js_register_cocos2dx_SAXParser(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_SAXParser_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_SAXParser_class, empty_constructor, 0, 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, "PlistParser", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SAXParser_class; - p->proto = jsb_cocos2d_SAXParser_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SAXParser_prototype); + jsb_register_class(cx, jsb_cocos2d_SAXParser_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Application_class; @@ -65793,30 +62823,17 @@ void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Application_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Application_class, empty_constructor, 0, 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, "Application", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Application_class; - p->proto = jsb_cocos2d_Application_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Application_prototype); + jsb_register_class(cx, jsb_cocos2d_Application_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_AnimationCache_class; @@ -65866,7 +62883,7 @@ bool js_cocos2dx_AnimationCache_addAnimation(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66010,8 +63027,8 @@ bool js_cocos2dx_AnimationCache_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -66078,30 +63095,17 @@ void js_register_cocos2dx_AnimationCache(JSContext *cx, JS::HandleObject global) jsb_cocos2d_AnimationCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_AnimationCache_class, js_cocos2dx_AnimationCache_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, "AnimationCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_AnimationCache_class; - p->proto = jsb_cocos2d_AnimationCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AnimationCache_prototype); + jsb_register_class(cx, jsb_cocos2d_AnimationCache_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.AnimationCache.extend = cc.Class.extend; })()"); } @@ -66122,7 +63126,7 @@ bool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66152,7 +63156,7 @@ bool js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66211,7 +63215,7 @@ bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66230,7 +63234,7 @@ bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66279,7 +63283,7 @@ bool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66310,7 +63314,7 @@ bool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66341,7 +63345,7 @@ bool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66470,7 +63474,7 @@ bool js_cocos2dx_SpriteBatchNode_insertQuadFromSprite(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66499,7 +63503,7 @@ bool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66528,7 +63532,7 @@ bool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66559,7 +63563,7 @@ bool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_ 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66611,7 +63615,7 @@ bool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66699,7 +63703,7 @@ bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66725,7 +63729,7 @@ bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66765,8 +63769,8 @@ bool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -66846,32 +63850,20 @@ void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_SpriteBatchNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_SpriteBatchNode_class, js_cocos2dx_SpriteBatchNode_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, "SpriteBatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SpriteBatchNode_class; - p->proto = jsb_cocos2d_SpriteBatchNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpriteBatchNode_prototype); + jsb_register_class(cx, jsb_cocos2d_SpriteBatchNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.SpriteBatchNode.extend = cc.Class.extend; })()"); } @@ -66894,7 +63886,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent(JSContext *cx, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -66923,7 +63915,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFrame(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66945,7 +63937,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile : Invalid Native Object"); @@ -66984,7 +63976,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -67174,7 +64166,7 @@ bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture(JSContext *cx, u 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -67267,30 +64259,17 @@ void js_register_cocos2dx_SpriteFrameCache(JSContext *cx, JS::HandleObject globa jsb_cocos2d_SpriteFrameCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_SpriteFrameCache_class, empty_constructor, 0, 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, "SpriteFrameCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_SpriteFrameCache_class; - p->proto = jsb_cocos2d_SpriteFrameCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpriteFrameCache_prototype); + jsb_register_class(cx, jsb_cocos2d_SpriteFrameCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TextFieldTTF_class; @@ -67359,7 +64338,7 @@ bool js_cocos2dx_TextFieldTTF_initWithPlaceHolder(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_initWithPlaceHolder : Invalid Native Object"); @@ -67417,7 +64396,7 @@ bool js_cocos2dx_TextFieldTTF_setColorSpaceHolder(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_setColorSpaceHolder : Invalid Native Object"); @@ -67619,8 +64598,8 @@ bool js_cocos2dx_TextFieldTTF_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -67690,32 +64669,20 @@ void js_register_cocos2dx_TextFieldTTF(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Label_prototype); jsb_cocos2d_TextFieldTTF_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Label_prototype), + parent_proto, jsb_cocos2d_TextFieldTTF_class, js_cocos2dx_TextFieldTTF_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, "TextFieldTTF", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TextFieldTTF_class; - p->proto = jsb_cocos2d_TextFieldTTF_prototype; - p->parentProto = jsb_cocos2d_Label_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TextFieldTTF_prototype); + jsb_register_class(cx, jsb_cocos2d_TextFieldTTF_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TextFieldTTF.extend = cc.Class.extend; })()"); } @@ -67729,7 +64696,7 @@ bool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParallaxNode_getParallaxArray : Invalid Native Object"); @@ -67773,7 +64740,7 @@ bool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -67868,8 +64835,8 @@ bool js_cocos2dx_ParallaxNode_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -67933,32 +64900,20 @@ void js_register_cocos2dx_ParallaxNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParallaxNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParallaxNode_class, js_cocos2dx_ParallaxNode_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, "ParallaxNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ParallaxNode_class; - p->proto = jsb_cocos2d_ParallaxNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParallaxNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ParallaxNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ParallaxNode.extend = cc.Class.extend; })()"); } @@ -68054,7 +65009,7 @@ bool js_cocos2dx_TMXObjectGroup_getObjects(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getObjects : Invalid Native Object"); @@ -68108,7 +65063,7 @@ bool js_cocos2dx_TMXObjectGroup_getProperties(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getProperties : Invalid Native Object"); @@ -68209,8 +65164,8 @@ bool js_cocos2dx_TMXObjectGroup_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -68260,30 +65215,17 @@ void js_register_cocos2dx_TMXObjectGroup(JSContext *cx, JS::HandleObject global) jsb_cocos2d_TMXObjectGroup_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXObjectGroup_class, js_cocos2dx_TMXObjectGroup_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, "TMXObjectGroup", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TMXObjectGroup_class; - p->proto = jsb_cocos2d_TMXObjectGroup_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXObjectGroup_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXObjectGroup_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TMXLayerInfo_class; @@ -68343,8 +65285,8 @@ bool js_cocos2dx_TMXLayerInfo_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -68386,30 +65328,17 @@ void js_register_cocos2dx_TMXLayerInfo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TMXLayerInfo_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXLayerInfo_class, js_cocos2dx_TMXLayerInfo_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, "TMXLayerInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TMXLayerInfo_class; - p->proto = jsb_cocos2d_TMXLayerInfo_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXLayerInfo_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXLayerInfo_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TMXTilesetInfo_class; @@ -68453,8 +65382,8 @@ bool js_cocos2dx_TMXTilesetInfo_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -68495,30 +65424,17 @@ void js_register_cocos2dx_TMXTilesetInfo(JSContext *cx, JS::HandleObject global) jsb_cocos2d_TMXTilesetInfo_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXTilesetInfo_class, js_cocos2dx_TMXTilesetInfo_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, "TMXTilesetInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TMXTilesetInfo_class; - p->proto = jsb_cocos2d_TMXTilesetInfo_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXTilesetInfo_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXTilesetInfo_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TMXMapInfo_class; @@ -68731,7 +65647,7 @@ bool js_cocos2dx_TMXMapInfo_getLayers(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getLayers : Invalid Native Object"); @@ -68765,7 +65681,7 @@ bool js_cocos2dx_TMXMapInfo_getTilesets(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getTilesets : Invalid Native Object"); @@ -68935,7 +65851,7 @@ bool js_cocos2dx_TMXMapInfo_getObjectGroups(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getObjectGroups : Invalid Native Object"); @@ -69145,7 +66061,7 @@ bool js_cocos2dx_TMXMapInfo_getProperties(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getProperties : Invalid Native Object"); @@ -69278,8 +66194,8 @@ bool js_cocos2dx_TMXMapInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -69372,30 +66288,17 @@ void js_register_cocos2dx_TMXMapInfo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TMXMapInfo_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXMapInfo_class, js_cocos2dx_TMXMapInfo_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, "TMXMapInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TMXMapInfo_class; - p->proto = jsb_cocos2d_TMXMapInfo_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXMapInfo_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXMapInfo_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.TMXMapInfo.extend = cc.Class.extend; })()"); } @@ -69647,7 +66550,7 @@ bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -69656,7 +66559,7 @@ bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::TMXLayerInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -69665,7 +66568,7 @@ bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsva if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::TMXMapInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -69704,7 +66607,7 @@ bool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setTileGID : Invalid Native Object"); @@ -69834,7 +66737,7 @@ bool js_cocos2dx_TMXLayer_setTileSet(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -69880,7 +66783,7 @@ bool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getProperties : Invalid Native Object"); @@ -69948,7 +66851,7 @@ bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -69957,7 +66860,7 @@ bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::TMXLayerInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -69966,7 +66869,7 @@ bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::TMXMapInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -70005,8 +66908,8 @@ bool js_cocos2dx_TMXLayer_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -70088,32 +66991,20 @@ void js_register_cocos2dx_TMXLayer(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_SpriteBatchNode_prototype); jsb_cocos2d_TMXLayer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_SpriteBatchNode_prototype), + parent_proto, jsb_cocos2d_TMXLayer_class, js_cocos2dx_TMXLayer_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, "TMXLayer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TMXLayer_class; - p->proto = jsb_cocos2d_TMXLayer_prototype; - p->parentProto = jsb_cocos2d_SpriteBatchNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXLayer_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXLayer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TMXLayer.extend = cc.Class.extend; })()"); } @@ -70218,7 +67109,7 @@ bool js_cocos2dx_TMXTiledMap_getObjectGroups(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getObjectGroups : Invalid Native Object"); @@ -70352,7 +67243,7 @@ bool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getPropertiesForGID : Invalid Native Object"); @@ -70366,7 +67257,7 @@ bool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Value**)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -70571,8 +67462,8 @@ bool js_cocos2dx_TMXTiledMap_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -70649,32 +67540,20 @@ void js_register_cocos2dx_TMXTiledMap(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_TMXTiledMap_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_TMXTiledMap_class, js_cocos2dx_TMXTiledMap_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, "TMXTiledMap", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TMXTiledMap_class; - p->proto = jsb_cocos2d_TMXTiledMap_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXTiledMap_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXTiledMap_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TMXTiledMap.extend = cc.Class.extend; })()"); } @@ -70855,8 +67734,8 @@ bool js_cocos2dx_TileMapAtlas_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -70922,32 +67801,20 @@ void js_register_cocos2dx_TileMapAtlas(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_AtlasNode_prototype); jsb_cocos2d_TileMapAtlas_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_AtlasNode_prototype), + parent_proto, jsb_cocos2d_TileMapAtlas_class, js_cocos2dx_TileMapAtlas_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, "TileMapAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_TileMapAtlas_class; - p->proto = jsb_cocos2d_TileMapAtlas_prototype; - p->parentProto = jsb_cocos2d_AtlasNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TileMapAtlas_prototype); + jsb_register_class(cx, jsb_cocos2d_TileMapAtlas_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TileMapAtlas.extend = cc.Class.extend; })()"); } @@ -71507,30 +68374,17 @@ void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JS::HandleObject glob jsb_CocosDenshion_SimpleAudioEngine_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_CocosDenshion_SimpleAudioEngine_class, empty_constructor, 0, 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, "AudioEngine", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_CocosDenshion_SimpleAudioEngine_class; - p->proto = jsb_CocosDenshion_SimpleAudioEngine_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_CocosDenshion_SimpleAudioEngine_prototype); + jsb_register_class(cx, jsb_CocosDenshion_SimpleAudioEngine_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ComponentJS_class; @@ -71580,8 +68434,8 @@ bool js_cocos2dx_ComponentJS_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -71645,32 +68499,20 @@ void js_register_cocos2dx_ComponentJS(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_ComponentJS_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_ComponentJS_class, js_cocos2dx_ComponentJS_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, "ComponentJS", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ComponentJS_class; - p->proto = jsb_cocos2d_ComponentJS_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ComponentJS_prototype); + jsb_register_class(cx, jsb_cocos2d_ComponentJS_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ComponentJS.extend = cc.Class.extend; })()"); } diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index fc47a4ce20..1cc6ffe101 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -2427,6 +2427,7 @@ bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval * bool js_cocos2dx_MenuItem_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_selected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_setCallback(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_rect(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_MenuItem(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp index d3440967a9..1b83ed43ec 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp @@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -59,7 +59,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *c 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -68,7 +68,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *c if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -134,7 +134,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel(JSContext *cx 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -174,7 +174,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setBaseValue(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -239,7 +239,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setRootNode(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -349,7 +349,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -358,7 +358,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -387,7 +387,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_getContainerSize(JSContext *cx, uin 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -417,7 +417,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel(JSContext 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -669,7 +669,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode(JSContext *cx 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -697,7 +697,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setDelegate(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBAnimationManagerDelegate*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -747,7 +747,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode(JSContext * 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -818,7 +818,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setCallFunc(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -921,8 +921,8 @@ bool js_cocos2dx_builder_CCBAnimationManager_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -999,30 +999,17 @@ void js_register_cocos2dx_builder_CCBAnimationManager(JSContext *cx, JS::HandleO jsb_cocosbuilder_CCBAnimationManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocosbuilder_CCBAnimationManager_class, js_cocos2dx_builder_CCBAnimationManager_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, "BuilderAnimationManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocosbuilder_CCBAnimationManager_class; - p->proto = jsb_cocosbuilder_CCBAnimationManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocosbuilder_CCBAnimationManager_prototype); + jsb_register_class(cx, jsb_cocosbuilder_CCBAnimationManager_class, proto, JS::NullPtr()); } JSClass *jsb_cocosbuilder_CCBReader_class; @@ -1067,7 +1054,7 @@ bool js_cocos2dx_builder_CCBReader_setAnimationManager(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBAnimationManager*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1173,7 +1160,7 @@ bool js_cocos2dx_builder_CCBReader_addOwnerOutletNode(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1219,7 +1206,7 @@ bool js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1359,7 +1346,7 @@ bool js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1441,7 +1428,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBReader*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1461,8 +1448,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1477,7 +1464,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1497,8 +1484,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1513,7 +1500,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1524,7 +1511,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1544,8 +1531,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1560,7 +1547,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1571,7 +1558,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1582,7 +1569,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1602,8 +1589,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1618,7 +1605,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1629,7 +1616,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1640,7 +1627,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1651,7 +1638,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocosbuilder::NodeLoaderListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -1671,8 +1658,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1696,8 +1683,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1767,30 +1754,17 @@ void js_register_cocos2dx_builder_CCBReader(JSContext *cx, JS::HandleObject glob jsb_cocosbuilder_CCBReader_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocosbuilder_CCBReader_class, js_cocos2dx_builder_CCBReader_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, "_Reader", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocosbuilder_CCBReader_class; - p->proto = jsb_cocosbuilder_CCBReader_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocosbuilder_CCBReader_prototype); + jsb_register_class(cx, jsb_cocosbuilder_CCBReader_class, proto, JS::NullPtr()); } void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp index 7ba5c234e2..d3ef2d7f9f 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -324,8 +324,8 @@ bool js_cocos2dx_experimental_video_VideoPlayer_constructor(JSContext *cx, uint3 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -381,32 +381,20 @@ void js_register_cocos2dx_experimental_video_VideoPlayer(JSContext *cx, JS::Hand JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_experimental_ui_VideoPlayer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_experimental_ui_VideoPlayer_class, js_cocos2dx_experimental_video_VideoPlayer_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, "VideoPlayer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_experimental_ui_VideoPlayer_class; - p->proto = jsb_cocos2d_experimental_ui_VideoPlayer_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_ui_VideoPlayer_class, proto, parent_proto); } void register_all_cocos2dx_experimental_video(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp index 81776d11e5..1b0d37bddd 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -384,8 +384,8 @@ bool js_cocos2dx_experimental_webView_WebView_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -444,32 +444,20 @@ void js_register_cocos2dx_experimental_webView_WebView(JSContext *cx, JS::Handle JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_experimental_ui_WebView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_experimental_ui_WebView_class, js_cocos2dx_experimental_webView_WebView_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, "WebView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_experimental_ui_WebView_class; - p->proto = jsb_cocos2d_experimental_ui_WebView_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_WebView_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_ui_WebView_class, proto, parent_proto); } void register_all_cocos2dx_experimental_webView(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp index 266d9d67bf..aef3313aa0 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp @@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -206,7 +206,7 @@ bool js_cocos2dx_extension_Control_isTouchInside(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -256,7 +256,7 @@ bool js_cocos2dx_extension_Control_getTouchLocation(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -327,8 +327,8 @@ bool js_cocos2dx_extension_Control_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -383,32 +383,20 @@ void js_register_cocos2dx_extension_Control(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_extension_Control_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_extension_Control_class, js_cocos2dx_extension_Control_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, "Control", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_Control_class; - p->proto = jsb_cocos2d_extension_Control_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_Control_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_Control_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_ControlButton_class; @@ -447,7 +435,7 @@ bool js_cocos2dx_extension_ControlButton_setTitleLabelForState(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -556,7 +544,7 @@ bool js_cocos2dx_extension_ControlButton_initWithBackgroundSprite(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -652,7 +640,7 @@ bool js_cocos2dx_extension_ControlButton_setTitleLabel(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -738,7 +726,7 @@ bool js_cocos2dx_extension_ControlButton_setBackgroundSprite(JSContext *cx, uint 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -989,7 +977,7 @@ bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState(JSCont 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1019,7 +1007,7 @@ bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(JSContext * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1195,7 +1183,7 @@ bool js_cocos2dx_extension_ControlButton_getCurrentTitle(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getCurrentTitle : Invalid Native Object"); @@ -1237,7 +1225,7 @@ bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSCont 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1246,7 +1234,7 @@ bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSCont if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1314,7 +1302,7 @@ bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1359,7 +1347,7 @@ bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1370,7 +1358,7 @@ bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1435,8 +1423,8 @@ bool js_cocos2dx_extension_ControlButton_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1534,32 +1522,20 @@ void js_register_cocos2dx_extension_ControlButton(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlButton_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlButton_class, js_cocos2dx_extension_ControlButton_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, "ControlButton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlButton_class; - p->proto = jsb_cocos2d_extension_ControlButton_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlButton_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlButton_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlButton.extend = cc.Class.extend; })()"); } @@ -1581,7 +1557,7 @@ bool js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1693,7 +1669,7 @@ bool js_cocos2dx_extension_ControlHuePicker_setBackground(JSContext *cx, uint32_ 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1784,7 +1760,7 @@ bool js_cocos2dx_extension_ControlHuePicker_setSlider(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1809,7 +1785,7 @@ bool js_cocos2dx_extension_ControlHuePicker_create(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -1849,8 +1825,8 @@ bool js_cocos2dx_extension_ControlHuePicker_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1903,32 +1879,20 @@ void js_register_cocos2dx_extension_ControlHuePicker(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlHuePicker_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlHuePicker_class, js_cocos2dx_extension_ControlHuePicker_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, "ControlHuePicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlHuePicker_class; - p->proto = jsb_cocos2d_extension_ControlHuePicker_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlHuePicker_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlHuePicker_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; @@ -1974,7 +1938,7 @@ bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPo 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -2131,7 +2095,7 @@ bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_create(JSContext *c 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -2171,8 +2135,8 @@ bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor(JSConte CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2223,32 +2187,20 @@ void js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(JSContext JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class, js_cocos2dx_extension_ControlSaturationBrightnessPicker_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, "ControlSaturationBrightnessPicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlSaturationBrightnessPicker_class; - p->proto = jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_ControlColourPicker_class; @@ -2269,7 +2221,7 @@ bool js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged(JSContext * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2348,7 +2300,7 @@ bool js_cocos2dx_extension_ControlColourPicker_setBackground(JSContext *cx, uint 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2376,7 +2328,7 @@ bool js_cocos2dx_extension_ControlColourPicker_setcolourPicker(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ControlSaturationBrightnessPicker*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2405,7 +2357,7 @@ bool js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged(JSContex 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2434,7 +2386,7 @@ bool js_cocos2dx_extension_ControlColourPicker_setHuePicker(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ControlHuePicker*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2510,8 +2462,8 @@ bool js_cocos2dx_extension_ControlColourPicker_constructor(JSContext *cx, uint32 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2579,32 +2531,20 @@ void js_register_cocos2dx_extension_ControlColourPicker(JSContext *cx, JS::Handl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlColourPicker_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlColourPicker_class, js_cocos2dx_extension_ControlColourPicker_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, "ControlColourPicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlColourPicker_class; - p->proto = jsb_cocos2d_extension_ControlColourPicker_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlColourPicker_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlColourPicker_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlColourPicker.extend = cc.Class.extend; })()"); } @@ -2794,7 +2734,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_setThumbSprite(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2902,7 +2842,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_setProgressTimer(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ProgressTimer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2977,7 +2917,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTime 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2986,7 +2926,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTime if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ProgressTimer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -2995,7 +2935,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTime if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3076,8 +3016,8 @@ bool js_cocos2dx_extension_ControlPotentiometer_constructor(JSContext *cx, uint3 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -3155,32 +3095,20 @@ void js_register_cocos2dx_extension_ControlPotentiometer(JSContext *cx, JS::Hand JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlPotentiometer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlPotentiometer_class, js_cocos2dx_extension_ControlPotentiometer_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, "ControlPotentiometer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlPotentiometer_class; - p->proto = jsb_cocos2d_extension_ControlPotentiometer_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlPotentiometer_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlPotentiometer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlPotentiometer.extend = cc.Class.extend; })()"); } @@ -3201,7 +3129,7 @@ bool js_cocos2dx_extension_ControlSlider_setBackgroundSprite(JSContext *cx, uint 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3240,7 +3168,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_initWithSprites : Invalid Native Object"); @@ -3251,7 +3179,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3262,7 +3190,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3273,7 +3201,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3284,7 +3212,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -3305,7 +3233,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3316,7 +3244,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3327,7 +3255,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3419,7 +3347,7 @@ bool js_cocos2dx_extension_ControlSlider_setProgressSprite(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3485,7 +3413,7 @@ bool js_cocos2dx_extension_ControlSlider_setThumbSprite(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3601,7 +3529,7 @@ bool js_cocos2dx_extension_ControlSlider_locationFromTouch(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3696,7 +3624,7 @@ bool js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite(JSContext *cx, u 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3742,7 +3670,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3753,7 +3681,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3764,7 +3692,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3847,7 +3775,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3858,7 +3786,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3869,7 +3797,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3880,7 +3808,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -3919,8 +3847,8 @@ bool js_cocos2dx_extension_ControlSlider_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -4000,32 +3928,20 @@ void js_register_cocos2dx_extension_ControlSlider(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlSlider_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlSlider_class, js_cocos2dx_extension_ControlSlider_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, "ControlSlider", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlSlider_class; - p->proto = jsb_cocos2d_extension_ControlSlider_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlSlider_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlSlider_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlSlider.extend = cc.Class.extend; })()"); } @@ -4112,7 +4028,7 @@ bool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSCon 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4121,7 +4037,7 @@ bool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSCon if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4263,7 +4179,7 @@ bool js_cocos2dx_extension_ControlStepper_setMinusLabel(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4381,7 +4297,7 @@ bool js_cocos2dx_extension_ControlStepper_setPlusLabel(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4452,7 +4368,7 @@ bool js_cocos2dx_extension_ControlStepper_setPlusSprite(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4480,7 +4396,7 @@ bool js_cocos2dx_extension_ControlStepper_setMinusSprite(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4505,7 +4421,7 @@ bool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4514,7 +4430,7 @@ bool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4553,8 +4469,8 @@ bool js_cocos2dx_extension_ControlStepper_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -4634,32 +4550,20 @@ void js_register_cocos2dx_extension_ControlStepper(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlStepper_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlStepper_class, js_cocos2dx_extension_ControlStepper_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, "ControlStepper", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlStepper_class; - p->proto = jsb_cocos2d_extension_ControlStepper_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlStepper_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlStepper_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlStepper.extend = cc.Class.extend; })()"); } @@ -4673,7 +4577,7 @@ bool js_cocos2dx_extension_ControlSwitch_setOn(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_setOn : Invalid Native Object"); @@ -4716,7 +4620,7 @@ bool js_cocos2dx_extension_ControlSwitch_locationFromTouch(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4757,7 +4661,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_initWithMaskSprite : Invalid Native Object"); @@ -4768,7 +4672,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4779,7 +4683,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4790,7 +4694,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4801,7 +4705,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -4812,7 +4716,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -4823,7 +4727,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(5).isNull()) { arg5 = nullptr; break; } if (!args.get(5).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(5).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(5).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg5 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg5, cx, false, "Invalid Native Object"); @@ -4844,7 +4748,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4855,7 +4759,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4866,7 +4770,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4877,7 +4781,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -4924,7 +4828,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4935,7 +4839,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4946,7 +4850,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4957,7 +4861,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -4985,7 +4889,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4996,7 +4900,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5007,7 +4911,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -5018,7 +4922,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -5029,7 +4933,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -5040,7 +4944,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(5).isNull()) { arg5 = nullptr; break; } if (!args.get(5).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(5).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(5).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg5 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg5, cx, false, "Invalid Native Object"); @@ -5079,8 +4983,8 @@ bool js_cocos2dx_extension_ControlSwitch_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5145,32 +5049,20 @@ void js_register_cocos2dx_extension_ControlSwitch(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlSwitch_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlSwitch_class, js_cocos2dx_extension_ControlSwitch_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, "ControlSwitch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ControlSwitch_class; - p->proto = jsb_cocos2d_extension_ControlSwitch_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlSwitch_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlSwitch_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlSwitch.extend = cc.Class.extend; })()"); } @@ -5209,7 +5101,7 @@ bool js_cocos2dx_extension_ScrollView_setContainer(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -5450,7 +5342,7 @@ bool js_cocos2dx_extension_ScrollView_initWithViewSize(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5480,7 +5372,7 @@ bool js_cocos2dx_extension_ScrollView_pause(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5670,7 +5562,7 @@ bool js_cocos2dx_extension_ScrollView_resume(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5792,7 +5684,7 @@ bool js_cocos2dx_extension_ScrollView_isNodeVisible(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -5833,7 +5725,7 @@ bool js_cocos2dx_extension_ScrollView_setZoomScale(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setZoomScale : Invalid Native Object"); @@ -5915,7 +5807,7 @@ bool js_cocos2dx_extension_ScrollView_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5954,8 +5846,8 @@ bool js_cocos2dx_extension_ScrollView_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6046,32 +5938,20 @@ void js_register_cocos2dx_extension_ScrollView(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_extension_ScrollView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_extension_ScrollView_class, js_cocos2dx_extension_ScrollView_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, "ScrollView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_ScrollView_class; - p->proto = jsb_cocos2d_extension_ScrollView_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ScrollView_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ScrollView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ScrollView.extend = cc.Class.extend; })()"); } @@ -6169,8 +6049,8 @@ bool js_cocos2dx_extension_TableViewCell_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6233,32 +6113,20 @@ void js_register_cocos2dx_extension_TableViewCell(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_extension_TableViewCell_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_extension_TableViewCell_class, js_cocos2dx_extension_TableViewCell_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, "TableViewCell", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_TableViewCell_class; - p->proto = jsb_cocos2d_extension_TableViewCell_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_TableViewCell_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_TableViewCell_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TableViewCell.extend = cc.Class.extend; })()"); } @@ -6319,7 +6187,7 @@ bool js_cocos2dx_extension_TableView_scrollViewDidZoom(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6413,7 +6281,7 @@ bool js_cocos2dx_extension_TableView_initWithViewSize(JSContext *cx, uint32_t ar if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6443,7 +6311,7 @@ bool js_cocos2dx_extension_TableView_scrollViewDidScroll(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6563,8 +6431,8 @@ bool js_cocos2dx_extension_TableView_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6633,32 +6501,20 @@ void js_register_cocos2dx_extension_TableView(JSContext *cx, JS::HandleObject gl JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_ScrollView_prototype); jsb_cocos2d_extension_TableView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_ScrollView_prototype), + parent_proto, jsb_cocos2d_extension_TableView_class, js_cocos2dx_extension_TableView_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, "TableView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_TableView_class; - p->proto = jsb_cocos2d_extension_TableView_prototype; - p->parentProto = jsb_cocos2d_extension_ScrollView_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_TableView_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_TableView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TableView.extend = cc.Class.extend; })()"); } @@ -6828,7 +6684,7 @@ bool js_cocos2dx_extension_EventAssetsManagerEx_constructor(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6847,8 +6703,8 @@ bool js_cocos2dx_extension_EventAssetsManagerEx_constructor(JSContext *cx, uint3 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6896,32 +6752,20 @@ void js_register_cocos2dx_extension_EventAssetsManagerEx(JSContext *cx, JS::Hand JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventCustom_prototype); jsb_cocos2d_extension_EventAssetsManagerEx_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventCustom_prototype), + parent_proto, jsb_cocos2d_extension_EventAssetsManagerEx_class, js_cocos2dx_extension_EventAssetsManagerEx_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, "EventAssetsManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_EventAssetsManagerEx_class; - p->proto = jsb_cocos2d_extension_EventAssetsManagerEx_prototype; - p->parentProto = jsb_cocos2d_EventCustom_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_EventAssetsManagerEx_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_EventAssetsManagerEx_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_Manifest_class; @@ -7090,30 +6934,17 @@ void js_register_cocos2dx_extension_Manifest(JSContext *cx, JS::HandleObject glo jsb_cocos2d_extension_Manifest_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_extension_Manifest_class, empty_constructor, 0, 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, "Manifest", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_Manifest_class; - p->proto = jsb_cocos2d_extension_Manifest_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_Manifest_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_Manifest_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_extension_AssetsManagerEx_class; @@ -7301,8 +7132,8 @@ bool js_cocos2dx_extension_AssetsManagerEx_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -7352,30 +7183,17 @@ void js_register_cocos2dx_extension_AssetsManagerEx(JSContext *cx, JS::HandleObj jsb_cocos2d_extension_AssetsManagerEx_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_extension_AssetsManagerEx_class, js_cocos2dx_extension_AssetsManagerEx_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, "AssetsManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_AssetsManagerEx_class; - p->proto = jsb_cocos2d_extension_AssetsManagerEx_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_AssetsManagerEx_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_extension_EventListenerAssetsManagerEx_class; @@ -7396,7 +7214,7 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7404,7 +7222,8 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -7452,7 +7271,7 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7460,7 +7279,8 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -7520,8 +7340,8 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_constructor(JSContext *c CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -7565,32 +7385,20 @@ void js_register_cocos2dx_extension_EventListenerAssetsManagerEx(JSContext *cx, JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListenerCustom_prototype); jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListenerCustom_prototype), + parent_proto, jsb_cocos2d_extension_EventListenerAssetsManagerEx_class, js_cocos2dx_extension_EventListenerAssetsManagerEx_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, "EventListenerAssetsManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_extension_EventListenerAssetsManagerEx_class; - p->proto = jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype; - p->parentProto = jsb_cocos2d_EventListenerCustom_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_EventListenerAssetsManagerEx_class, proto, parent_proto); } void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp index a178091a1a..4041cb029a 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -595,8 +595,8 @@ bool js_cocos2dx_navmesh_NavMeshAgent_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -667,32 +667,20 @@ void js_register_cocos2dx_navmesh_NavMeshAgent(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_NavMeshAgent_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_NavMeshAgent_class, js_cocos2dx_navmesh_NavMeshAgent_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, "NavMeshAgent", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_NavMeshAgent_class; - p->proto = jsb_cocos2d_NavMeshAgent_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NavMeshAgent_prototype); + jsb_register_class(cx, jsb_cocos2d_NavMeshAgent_class, proto, parent_proto); } JSClass *jsb_cocos2d_NavMeshObstacle_class; @@ -885,8 +873,8 @@ bool js_cocos2dx_navmesh_NavMeshObstacle_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -937,32 +925,20 @@ void js_register_cocos2dx_navmesh_NavMeshObstacle(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_NavMeshObstacle_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_NavMeshObstacle_class, js_cocos2dx_navmesh_NavMeshObstacle_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, "NavMeshObstacle", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_NavMeshObstacle_class; - p->proto = jsb_cocos2d_NavMeshObstacle_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NavMeshObstacle_prototype); + jsb_register_class(cx, jsb_cocos2d_NavMeshObstacle_class, proto, parent_proto); } JSClass *jsb_cocos2d_NavMesh_class; @@ -982,7 +958,7 @@ bool js_cocos2dx_navmesh_NavMesh_removeNavMeshObstacle(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1010,7 +986,7 @@ bool js_cocos2dx_navmesh_NavMesh_removeNavMeshAgent(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1076,7 +1052,7 @@ bool js_cocos2dx_navmesh_NavMesh_addNavMeshAgent(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1104,7 +1080,7 @@ bool js_cocos2dx_navmesh_NavMesh_addNavMeshObstacle(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1152,7 +1128,7 @@ bool js_cocos2dx_navmesh_NavMesh_debugDraw(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1209,8 +1185,8 @@ bool js_cocos2dx_navmesh_NavMesh_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1261,30 +1237,17 @@ void js_register_cocos2dx_navmesh_NavMesh(JSContext *cx, JS::HandleObject global jsb_cocos2d_NavMesh_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_NavMesh_class, js_cocos2dx_navmesh_NavMesh_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, "NavMesh", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_NavMesh_class; - p->proto = jsb_cocos2d_NavMesh_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NavMesh_prototype); + jsb_register_class(cx, jsb_cocos2d_NavMesh_class, proto, JS::NullPtr()); } void register_all_cocos2dx_navmesh(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp index a1e0ac3275..d94b26ac15 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -61,7 +61,7 @@ bool js_cocos2dx_physics3d_Physics3DShape_initConvexHull(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -276,7 +276,7 @@ bool js_cocos2dx_physics3d_Physics3DShape_createConvexHull(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -368,8 +368,8 @@ bool js_cocos2dx_physics3d_Physics3DShape_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -423,30 +423,17 @@ void js_register_cocos2dx_physics3d_Physics3DShape(JSContext *cx, JS::HandleObje jsb_cocos2d_Physics3DShape_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DShape_class, js_cocos2dx_physics3d_Physics3DShape_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, "Physics3DShape", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DShape_class; - p->proto = jsb_cocos2d_Physics3DShape_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DShape_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DShape_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DObject_class; @@ -523,7 +510,7 @@ bool js_cocos2dx_physics3d_Physics3DObject_setPhysicsWorld(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -694,30 +681,17 @@ void js_register_cocos2dx_physics3d_Physics3DObject(JSContext *cx, JS::HandleObj jsb_cocos2d_Physics3DObject_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DObject_class, empty_constructor, 0, 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, "Physics3DObject", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DObject_class; - p->proto = jsb_cocos2d_Physics3DObject_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DObject_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DObject_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DRigidBody_class; @@ -768,7 +742,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_setAngularFactor(JSContext *cx, ui JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DRigidBody_setAngularFactor : Invalid Native Object"); @@ -811,7 +785,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_addConstraint(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1449,7 +1423,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_removeConstraint(JSContext *cx, ui JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DRigidBody_removeConstraint : Invalid Native Object"); @@ -1471,7 +1445,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_removeConstraint(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1751,8 +1725,8 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1841,32 +1815,20 @@ void js_register_cocos2dx_physics3d_Physics3DRigidBody(JSContext *cx, JS::Handle JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DObject_prototype); jsb_cocos2d_Physics3DRigidBody_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DObject_prototype), + parent_proto, jsb_cocos2d_Physics3DRigidBody_class, js_cocos2dx_physics3d_Physics3DRigidBody_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, "Physics3DRigidBody", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DRigidBody_class; - p->proto = jsb_cocos2d_Physics3DRigidBody_prototype; - p->parentProto = jsb_cocos2d_Physics3DObject_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DRigidBody_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DRigidBody_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DComponent_class; @@ -1902,7 +1864,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_addToPhysicsWorld(JSContext *cx, u 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1971,7 +1933,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_setPhysics3DObject(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2039,7 +2001,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_create(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2066,7 +2028,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_create(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2096,7 +2058,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_create(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2172,8 +2134,8 @@ bool js_cocos2dx_physics3d_Physics3DComponent_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2224,32 +2186,20 @@ void js_register_cocos2dx_physics3d_Physics3DComponent(JSContext *cx, JS::Handle JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_Physics3DComponent_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_Physics3DComponent_class, js_cocos2dx_physics3d_Physics3DComponent_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, "Physics3DComponent", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DComponent_class; - p->proto = jsb_cocos2d_Physics3DComponent_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DComponent_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DComponent_class, proto, parent_proto); } JSClass *jsb_cocos2d_PhysicsSprite3D_class; @@ -2348,8 +2298,8 @@ bool js_cocos2dx_physics3d_PhysicsSprite3D_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2393,32 +2343,20 @@ void js_register_cocos2dx_physics3d_PhysicsSprite3D(JSContext *cx, JS::HandleObj JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite3D_prototype); jsb_cocos2d_PhysicsSprite3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), + parent_proto, jsb_cocos2d_PhysicsSprite3D_class, js_cocos2dx_physics3d_PhysicsSprite3D_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, "PhysicsSprite3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_PhysicsSprite3D_class; - p->proto = jsb_cocos2d_PhysicsSprite3D_prototype; - p->parentProto = jsb_cocos2d_Sprite3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PhysicsSprite3D_prototype); + jsb_register_class(cx, jsb_cocos2d_PhysicsSprite3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DWorld_class; @@ -2619,7 +2557,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *c 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2647,7 +2585,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2695,7 +2633,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject(JSContext *cx, u 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2723,7 +2661,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_getPhysicsObject(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const btCollisionObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2760,7 +2698,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DConstraint(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2777,7 +2715,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DConstraint(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2806,7 +2744,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_debugDraw(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2837,7 +2775,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_sweepShape(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DShape*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2899,8 +2837,8 @@ bool js_cocos2dx_physics3d_Physics3DWorld_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2961,30 +2899,17 @@ void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObje jsb_cocos2d_Physics3DWorld_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DWorld_class, js_cocos2dx_physics3d_Physics3DWorld_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, "Physics3DWorld", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DWorld_class; - p->proto = jsb_cocos2d_Physics3DWorld_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DWorld_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DWorld_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DConstraint_class; @@ -3278,30 +3203,17 @@ void js_register_cocos2dx_physics3d_Physics3DConstraint(JSContext *cx, JS::Handl jsb_cocos2d_Physics3DConstraint_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DConstraint_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DConstraint_class; - p->proto = jsb_cocos2d_Physics3DConstraint_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DConstraint_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DPointToPointConstraint_class; @@ -3350,7 +3262,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DPointToPointConstraint *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init : Invalid Native Object"); @@ -3361,7 +3273,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3372,7 +3284,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3399,7 +3311,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3471,7 +3383,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_create(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3482,7 +3394,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_create(JSContext *cx, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3516,7 +3428,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_create(JSContext *cx, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3558,8 +3470,8 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_constructor(JSContext CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -3607,32 +3519,20 @@ void js_register_cocos2dx_physics3d_Physics3DPointToPointConstraint(JSContext *c JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DPointToPointConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DPointToPointConstraint_class, js_cocos2dx_physics3d_Physics3DPointToPointConstraint_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, "Physics3DPointToPointConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DPointToPointConstraint_class; - p->proto = jsb_cocos2d_Physics3DPointToPointConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DPointToPointConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DPointToPointConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DHingeConstraint_class; @@ -3645,7 +3545,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_getHingeAngle(JSContext *cx, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DHingeConstraint_getHingeAngle : Invalid Native Object"); @@ -4037,7 +3937,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_setMotorTarget(JSContext *cx JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DHingeConstraint_setMotorTarget : Invalid Native Object"); @@ -4140,7 +4040,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4173,7 +4073,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4210,7 +4110,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4240,7 +4140,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4274,7 +4174,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4285,7 +4185,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4324,7 +4224,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4335,7 +4235,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4378,7 +4278,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4389,7 +4289,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4422,7 +4322,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4433,7 +4333,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4481,8 +4381,8 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_constructor(JSContext *cx, u CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -4546,32 +4446,20 @@ void js_register_cocos2dx_physics3d_Physics3DHingeConstraint(JSContext *cx, JS:: JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DHingeConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DHingeConstraint_class, js_cocos2dx_physics3d_Physics3DHingeConstraint_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, "Physics3DHingeConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DHingeConstraint_class; - p->proto = jsb_cocos2d_Physics3DHingeConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DHingeConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DHingeConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DSliderConstraint_class; @@ -5805,7 +5693,7 @@ bool js_cocos2dx_physics3d_Physics3DSliderConstraint_create(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5814,7 +5702,7 @@ bool js_cocos2dx_physics3d_Physics3DSliderConstraint_create(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5856,8 +5744,8 @@ bool js_cocos2dx_physics3d_Physics3DSliderConstraint_constructor(JSContext *cx, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5964,32 +5852,20 @@ void js_register_cocos2dx_physics3d_Physics3DSliderConstraint(JSContext *cx, JS: JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DSliderConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DSliderConstraint_class, js_cocos2dx_physics3d_Physics3DSliderConstraint_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, "Physics3DSliderConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DSliderConstraint_class; - p->proto = jsb_cocos2d_Physics3DSliderConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DSliderConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DSliderConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DConeTwistConstraint_class; @@ -6387,7 +6263,7 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_create(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6398,7 +6274,7 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_create(JSContext *cx, ui if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6432,7 +6308,7 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_create(JSContext *cx, ui 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6474,8 +6350,8 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_constructor(JSContext *c CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6535,32 +6411,20 @@ void js_register_cocos2dx_physics3d_Physics3DConeTwistConstraint(JSContext *cx, JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DConeTwistConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DConeTwistConstraint_class, js_cocos2dx_physics3d_Physics3DConeTwistConstraint_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, "Physics3DConeTwistConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3DConeTwistConstraint_class; - p->proto = jsb_cocos2d_Physics3DConeTwistConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DConeTwistConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DConeTwistConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3D6DofConstraint_class; @@ -6790,7 +6654,7 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_create(JSContext *cx, uint32_ 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6824,7 +6688,7 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_create(JSContext *cx, uint32_ 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6835,7 +6699,7 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_create(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6883,8 +6747,8 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_constructor(JSContext *cx, ui CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6938,32 +6802,20 @@ void js_register_cocos2dx_physics3d_Physics3D6DofConstraint(JSContext *cx, JS::H JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3D6DofConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3D6DofConstraint_class, js_cocos2dx_physics3d_Physics3D6DofConstraint_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, "Physics3D6DofConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_Physics3D6DofConstraint_class; - p->proto = jsb_cocos2d_Physics3D6DofConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3D6DofConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3D6DofConstraint_class, proto, parent_proto); } void register_all_cocos2dx_physics3d(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp index 838d77a01c..a1fb9cc721 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -90,7 +90,7 @@ bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(JSContext *cx, uint32_t ar JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Invalid Native Object"); @@ -364,7 +364,7 @@ bool js_cocos2dx_spine_SkeletonRenderer_initWithFile(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_initWithFile : Invalid Native Object"); @@ -462,7 +462,7 @@ bool js_cocos2dx_spine_SkeletonRenderer_setSkin(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Invalid Native Object"); @@ -645,8 +645,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -676,8 +676,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -701,8 +701,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -733,8 +733,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -768,8 +768,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -799,8 +799,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -833,8 +833,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -905,32 +905,20 @@ void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_spine_SkeletonRenderer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_spine_SkeletonRenderer_class, js_cocos2dx_spine_SkeletonRenderer_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, "Skeleton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_spine_SkeletonRenderer_class; - p->proto = jsb_spine_SkeletonRenderer_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_spine_SkeletonRenderer_prototype); + jsb_register_class(cx, jsb_spine_SkeletonRenderer_class, proto, parent_proto); } JSClass *jsb_spine_SkeletonAnimation_class; @@ -949,7 +937,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setStartListener(JSContext *cx, uint32_ do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -993,7 +982,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0, spEvent* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1056,7 +1046,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener(JSContext *cx, do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0, int larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1128,7 +1119,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -1189,7 +1181,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setCompleteListener(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0, int larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1234,7 +1227,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -1275,7 +1269,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_ do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0, spEvent* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1341,7 +1336,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -1585,8 +1581,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1616,8 +1612,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1641,8 +1637,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1673,8 +1669,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1708,8 +1704,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1739,8 +1735,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1773,8 +1769,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -2001,32 +1997,20 @@ void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_spine_SkeletonRenderer_prototype); jsb_spine_SkeletonAnimation_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_spine_SkeletonRenderer_prototype), + parent_proto, jsb_spine_SkeletonAnimation_class, js_cocos2dx_spine_SkeletonAnimation_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SkeletonAnimation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_spine_SkeletonAnimation_class; - p->proto = jsb_spine_SkeletonAnimation_prototype; - p->parentProto = jsb_spine_SkeletonRenderer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_spine_SkeletonAnimation_prototype); + jsb_register_class(cx, jsb_spine_SkeletonAnimation_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { sp.SkeletonAnimation.extend = cc.Class.extend; })()"); } diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp index 36ba34352a..4819d2922a 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -181,7 +181,7 @@ bool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_play : Invalid Native Object"); @@ -192,7 +192,7 @@ bool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -247,7 +247,7 @@ bool js_cocos2dx_studio_ActionObject_removeActionNode(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ActionNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -295,7 +295,7 @@ bool js_cocos2dx_studio_ActionObject_initWithBinary(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::CocoLoader*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -306,7 +306,7 @@ bool js_cocos2dx_studio_ActionObject_initWithBinary(JSContext *cx, uint32_t argc if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -334,7 +334,7 @@ bool js_cocos2dx_studio_ActionObject_addActionNode(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ActionNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -460,8 +460,8 @@ bool js_cocos2dx_studio_ActionObject_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -519,30 +519,17 @@ void js_register_cocos2dx_studio_ActionObject(JSContext *cx, JS::HandleObject gl jsb_cocostudio_ActionObject_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ActionObject_class, js_cocos2dx_studio_ActionObject_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, "ActionObject", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ActionObject_class; - p->proto = jsb_cocostudio_ActionObject_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ActionObject_prototype); + jsb_register_class(cx, jsb_cocostudio_ActionObject_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ActionManagerEx_class; @@ -628,7 +615,7 @@ bool js_cocos2dx_studio_ActionManagerEx_initWithBinary(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -637,7 +624,7 @@ bool js_cocos2dx_studio_ActionManagerEx_initWithBinary(JSContext *cx, uint32_t a if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocostudio::CocoLoader*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -660,7 +647,7 @@ bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_playActionByName : Invalid Native Object"); @@ -677,7 +664,7 @@ bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -812,30 +799,17 @@ void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JS::HandleObject jsb_cocostudio_ActionManagerEx_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ActionManagerEx_class, empty_constructor, 0, 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, "ActionManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ActionManagerEx_class; - p->proto = jsb_cocostudio_ActionManagerEx_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ActionManagerEx_prototype); + jsb_register_class(cx, jsb_cocostudio_ActionManagerEx_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_BaseData_class; @@ -916,8 +890,8 @@ bool js_cocos2dx_studio_BaseData_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -962,30 +936,17 @@ void js_register_cocos2dx_studio_BaseData(JSContext *cx, JS::HandleObject global jsb_cocostudio_BaseData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_BaseData_class, js_cocos2dx_studio_BaseData_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, "BaseData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_BaseData_class; - p->proto = jsb_cocostudio_BaseData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_BaseData_prototype); + jsb_register_class(cx, jsb_cocostudio_BaseData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_MovementData_class; @@ -1034,7 +995,7 @@ bool js_cocos2dx_studio_MovementData_addMovementBoneData(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::MovementBoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1085,8 +1046,8 @@ bool js_cocos2dx_studio_MovementData_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1131,30 +1092,17 @@ void js_register_cocos2dx_studio_MovementData(JSContext *cx, JS::HandleObject gl jsb_cocostudio_MovementData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_MovementData_class, js_cocos2dx_studio_MovementData_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, "MovementData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_MovementData_class; - p->proto = jsb_cocostudio_MovementData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_MovementData_prototype); + jsb_register_class(cx, jsb_cocostudio_MovementData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_AnimationData_class; @@ -1221,7 +1169,7 @@ bool js_cocos2dx_studio_AnimationData_addMovement(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::MovementData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1272,8 +1220,8 @@ bool js_cocos2dx_studio_AnimationData_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1319,30 +1267,17 @@ void js_register_cocos2dx_studio_AnimationData(JSContext *cx, JS::HandleObject g jsb_cocostudio_AnimationData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_AnimationData_class, js_cocos2dx_studio_AnimationData_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, "AnimationData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_AnimationData_class; - p->proto = jsb_cocostudio_AnimationData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_AnimationData_prototype); + jsb_register_class(cx, jsb_cocostudio_AnimationData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ContourData_class; @@ -1423,8 +1358,8 @@ bool js_cocos2dx_studio_ContourData_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1469,30 +1404,17 @@ void js_register_cocos2dx_studio_ContourData(JSContext *cx, JS::HandleObject glo jsb_cocostudio_ContourData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ContourData_class, js_cocos2dx_studio_ContourData_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, "ContourData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ContourData_class; - p->proto = jsb_cocostudio_ContourData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ContourData_prototype); + jsb_register_class(cx, jsb_cocostudio_ContourData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_TextureData_class; @@ -1559,7 +1481,7 @@ bool js_cocos2dx_studio_TextureData_addContourData(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ContourData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1610,8 +1532,8 @@ bool js_cocos2dx_studio_TextureData_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -1657,30 +1579,17 @@ void js_register_cocos2dx_studio_TextureData(JSContext *cx, JS::HandleObject glo jsb_cocostudio_TextureData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_TextureData_class, js_cocos2dx_studio_TextureData_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, "TextureData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_TextureData_class; - p->proto = jsb_cocostudio_TextureData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_TextureData_prototype); + jsb_register_class(cx, jsb_cocostudio_TextureData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ProcessBase_class; @@ -2002,8 +1911,8 @@ bool js_cocos2dx_studio_ProcessBase_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2059,30 +1968,17 @@ void js_register_cocos2dx_studio_ProcessBase(JSContext *cx, JS::HandleObject glo jsb_cocostudio_ProcessBase_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ProcessBase_class, js_cocos2dx_studio_ProcessBase_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, "ProcessBase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ProcessBase_class; - p->proto = jsb_cocostudio_ProcessBase_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ProcessBase_prototype); + jsb_register_class(cx, jsb_cocostudio_ProcessBase_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_Tween_class; @@ -2151,7 +2047,7 @@ bool js_cocos2dx_studio_Tween_play(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::MovementBoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2203,7 +2099,7 @@ bool js_cocos2dx_studio_Tween_init(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2233,7 +2129,7 @@ bool js_cocos2dx_studio_Tween_setAnimation(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureAnimation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2257,7 +2153,7 @@ bool js_cocos2dx_studio_Tween_create(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2296,8 +2192,8 @@ bool js_cocos2dx_studio_Tween_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2346,32 +2242,20 @@ void js_register_cocos2dx_studio_Tween(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_ProcessBase_prototype); jsb_cocostudio_Tween_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_ProcessBase_prototype), + parent_proto, jsb_cocostudio_Tween_class, js_cocos2dx_studio_Tween_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, "Tween", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_Tween_class; - p->proto = jsb_cocostudio_Tween_prototype; - p->parentProto = jsb_cocostudio_ProcessBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Tween_prototype); + jsb_register_class(cx, jsb_cocostudio_Tween_class, proto, parent_proto); } JSClass *jsb_cocostudio_ColliderFilter_class; @@ -2407,30 +2291,17 @@ void js_register_cocos2dx_studio_ColliderFilter(JSContext *cx, JS::HandleObject jsb_cocostudio_ColliderFilter_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ColliderFilter_class, empty_constructor, 0, 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, "ColliderFilter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ColliderFilter_class; - p->proto = jsb_cocostudio_ColliderFilter_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ColliderFilter_prototype); + jsb_register_class(cx, jsb_cocostudio_ColliderFilter_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ColliderBody_class; @@ -2466,30 +2337,17 @@ void js_register_cocos2dx_studio_ColliderBody(JSContext *cx, JS::HandleObject gl jsb_cocostudio_ColliderBody_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ColliderBody_class, empty_constructor, 0, 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, "ColliderBody", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ColliderBody_class; - p->proto = jsb_cocostudio_ColliderBody_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ColliderBody_prototype); + jsb_register_class(cx, jsb_cocostudio_ColliderBody_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ColliderDetector_class; @@ -2599,7 +2457,7 @@ bool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_init : Invalid Native Object"); @@ -2610,7 +2468,7 @@ bool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2671,7 +2529,7 @@ bool js_cocos2dx_studio_ColliderDetector_setBone(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2697,7 +2555,7 @@ bool js_cocos2dx_studio_ColliderDetector_create(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2778,30 +2636,17 @@ void js_register_cocos2dx_studio_ColliderDetector(JSContext *cx, JS::HandleObjec jsb_cocostudio_ColliderDetector_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ColliderDetector_class, empty_constructor, 0, 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, "ColliderDetector", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ColliderDetector_class; - p->proto = jsb_cocostudio_ColliderDetector_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ColliderDetector_prototype); + jsb_register_class(cx, jsb_cocostudio_ColliderDetector_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_DecorativeDisplay_class; @@ -2871,7 +2716,7 @@ bool js_cocos2dx_studio_DecorativeDisplay_setDisplay(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -2917,7 +2762,7 @@ bool js_cocos2dx_studio_DecorativeDisplay_setDisplayData(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2970,7 +2815,7 @@ bool js_cocos2dx_studio_DecorativeDisplay_setColliderDetector(JSContext *cx, uin 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ColliderDetector*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3045,30 +2890,17 @@ void js_register_cocos2dx_studio_DecorativeDisplay(JSContext *cx, JS::HandleObje jsb_cocostudio_DecorativeDisplay_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_DecorativeDisplay_class, empty_constructor, 0, 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, "DecorativeDisplay", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_DecorativeDisplay_class; - p->proto = jsb_cocostudio_DecorativeDisplay_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_DecorativeDisplay_prototype); + jsb_register_class(cx, jsb_cocostudio_DecorativeDisplay_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_DisplayManager_class; @@ -3156,7 +2988,7 @@ bool js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay(JSContext *cx 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DecorativeDisplay*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3242,7 +3074,7 @@ bool js_cocos2dx_studio_DisplayManager_init(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3301,7 +3133,7 @@ bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_addDisplay : Invalid Native Object"); @@ -3312,7 +3144,7 @@ bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -3334,7 +3166,7 @@ bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3359,7 +3191,7 @@ bool js_cocos2dx_studio_DisplayManager_containPoint(JSContext *cx, uint32_t argc JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_containPoint : Invalid Native Object"); @@ -3409,7 +3241,7 @@ bool js_cocos2dx_studio_DisplayManager_initDisplayList(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3616,7 +3448,7 @@ bool js_cocos2dx_studio_DisplayManager_create(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3655,8 +3487,8 @@ bool js_cocos2dx_studio_DisplayManager_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -3721,30 +3553,17 @@ void js_register_cocos2dx_studio_DisplayManager(JSContext *cx, JS::HandleObject jsb_cocostudio_DisplayManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_DisplayManager_class, js_cocos2dx_studio_DisplayManager_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, "DisplayManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_DisplayManager_class; - p->proto = jsb_cocostudio_DisplayManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_DisplayManager_prototype); + jsb_register_class(cx, jsb_cocostudio_DisplayManager_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_Bone_class; @@ -3879,7 +3698,7 @@ bool js_cocos2dx_studio_Bone_addChildBone(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4056,7 +3875,7 @@ bool js_cocos2dx_studio_Bone_setBoneData(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4106,7 +3925,7 @@ bool js_cocos2dx_studio_Bone_setParentBone(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4127,7 +3946,7 @@ bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_addDisplay : Invalid Native Object"); @@ -4138,7 +3957,7 @@ bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -4160,7 +3979,7 @@ bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4344,7 +4163,7 @@ bool js_cocos2dx_studio_Bone_setArmature(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4393,7 +4212,7 @@ bool js_cocos2dx_studio_Bone_removeChildBone(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4422,7 +4241,7 @@ bool js_cocos2dx_studio_Bone_setChildArmature(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4564,8 +4383,8 @@ bool js_cocos2dx_studio_Bone_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -4640,32 +4459,20 @@ void js_register_cocos2dx_studio_Bone(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_Bone_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_Bone_class, js_cocos2dx_studio_Bone_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, "Bone", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_Bone_class; - p->proto = jsb_cocostudio_Bone_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Bone_prototype); + jsb_register_class(cx, jsb_cocostudio_Bone_class, proto, parent_proto); } JSClass *jsb_cocostudio_BatchNode_class; @@ -4725,32 +4532,20 @@ void js_register_cocos2dx_studio_BatchNode(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_BatchNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_BatchNode_class, empty_constructor, 0, 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, "BatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_BatchNode_class; - p->proto = jsb_cocostudio_BatchNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_BatchNode_prototype); + jsb_register_class(cx, jsb_cocostudio_BatchNode_class, proto, parent_proto); } JSClass *jsb_cocostudio_ArmatureAnimation_class; @@ -4892,7 +4687,7 @@ bool js_cocos2dx_studio_ArmatureAnimation_setAnimationData(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4985,7 +4780,7 @@ bool js_cocos2dx_studio_ArmatureAnimation_init(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5131,7 +4926,7 @@ bool js_cocos2dx_studio_ArmatureAnimation_create(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5170,8 +4965,8 @@ bool js_cocos2dx_studio_ArmatureAnimation_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5227,32 +5022,20 @@ void js_register_cocos2dx_studio_ArmatureAnimation(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_ProcessBase_prototype); jsb_cocostudio_ArmatureAnimation_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_ProcessBase_prototype), + parent_proto, jsb_cocostudio_ArmatureAnimation_class, js_cocos2dx_studio_ArmatureAnimation_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, "ArmatureAnimation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ArmatureAnimation_class; - p->proto = jsb_cocostudio_ArmatureAnimation_prototype; - p->parentProto = jsb_cocostudio_ProcessBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ArmatureAnimation_prototype); + jsb_register_class(cx, jsb_cocostudio_ArmatureAnimation_class, proto, parent_proto); } JSClass *jsb_cocostudio_ArmatureDataManager_class; @@ -5312,7 +5095,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5331,7 +5114,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5353,7 +5136,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo(JSContext *cx, u JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo : Invalid Native Object"); @@ -5511,7 +5294,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5530,7 +5313,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5637,7 +5420,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::TextureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5656,7 +5439,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::TextureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5806,30 +5589,17 @@ void js_register_cocos2dx_studio_ArmatureDataManager(JSContext *cx, JS::HandleOb jsb_cocostudio_ArmatureDataManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ArmatureDataManager_class, empty_constructor, 0, 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, "ArmatureDataManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ArmatureDataManager_class; - p->proto = jsb_cocostudio_ArmatureDataManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ArmatureDataManager_prototype); + jsb_register_class(cx, jsb_cocostudio_ArmatureDataManager_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_Armature_class; @@ -5879,7 +5649,7 @@ bool js_cocos2dx_studio_Armature_changeBoneParent(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5908,7 +5678,7 @@ bool js_cocos2dx_studio_Armature_setAnimation(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureAnimation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6047,7 +5817,7 @@ bool js_cocos2dx_studio_Armature_removeBone(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6094,7 +5864,7 @@ bool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_init : Invalid Native Object"); @@ -6108,7 +5878,7 @@ bool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6152,7 +5922,7 @@ bool js_cocos2dx_studio_Armature_setParentBone(JSContext *cx, uint32_t argc, jsv 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6180,7 +5950,7 @@ bool js_cocos2dx_studio_Armature_setBatchNode(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BatchNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6226,7 +5996,7 @@ bool js_cocos2dx_studio_Armature_setArmatureData(JSContext *cx, uint32_t argc, j 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6255,7 +6025,7 @@ bool js_cocos2dx_studio_Armature_addBone(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6464,7 +6234,7 @@ bool js_cocos2dx_studio_Armature_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6503,8 +6273,8 @@ bool js_cocos2dx_studio_Armature_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6587,32 +6357,20 @@ void js_register_cocos2dx_studio_Armature(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_Armature_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_Armature_class, js_cocos2dx_studio_Armature_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, "Armature", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_Armature_class; - p->proto = jsb_cocostudio_Armature_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Armature_prototype); + jsb_register_class(cx, jsb_cocostudio_Armature_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.Armature.extend = cc.Class.extend; })()"); } @@ -6710,7 +6468,7 @@ bool js_cocos2dx_studio_Skin_setBone(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6809,8 +6567,8 @@ bool js_cocos2dx_studio_Skin_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6859,32 +6617,20 @@ void js_register_cocos2dx_studio_Skin(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite_prototype); jsb_cocostudio_Skin_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Sprite_prototype), + parent_proto, jsb_cocostudio_Skin_class, js_cocos2dx_studio_Skin_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, "Skin", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_Skin_class; - p->proto = jsb_cocostudio_Skin_prototype; - p->parentProto = jsb_cocos2d_Sprite_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Skin_prototype); + jsb_register_class(cx, jsb_cocostudio_Skin_class, proto, parent_proto); } JSClass *jsb_cocostudio_ComAttribute_class; @@ -7173,8 +6919,8 @@ bool js_cocos2dx_studio_ComAttribute_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -7226,32 +6972,20 @@ void js_register_cocos2dx_studio_ComAttribute(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComAttribute_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComAttribute_class, js_cocos2dx_studio_ComAttribute_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, "ComAttribute", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ComAttribute_class; - p->proto = jsb_cocostudio_ComAttribute_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComAttribute_prototype); + jsb_register_class(cx, jsb_cocostudio_ComAttribute_class, proto, parent_proto); } JSClass *jsb_cocostudio_ComAudio_class; @@ -7390,7 +7124,7 @@ bool js_cocos2dx_studio_ComAudio_stopBackgroundMusic(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_stopBackgroundMusic : Invalid Native Object"); @@ -7526,7 +7260,7 @@ bool js_cocos2dx_studio_ComAudio_playBackgroundMusic(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_playBackgroundMusic : Invalid Native Object"); @@ -7572,7 +7306,7 @@ bool js_cocos2dx_studio_ComAudio_playEffect(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_playEffect : Invalid Native Object"); @@ -7844,8 +7578,8 @@ bool js_cocos2dx_studio_ComAudio_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -7914,32 +7648,20 @@ void js_register_cocos2dx_studio_ComAudio(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComAudio_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComAudio_class, js_cocos2dx_studio_ComAudio_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, "ComAudio", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ComAudio_class; - p->proto = jsb_cocostudio_ComAudio_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComAudio_prototype); + jsb_register_class(cx, jsb_cocostudio_ComAudio_class, proto, parent_proto); } JSClass *jsb_cocostudio_InputDelegate_class; @@ -8175,30 +7897,17 @@ void js_register_cocos2dx_studio_InputDelegate(JSContext *cx, JS::HandleObject g jsb_cocostudio_InputDelegate_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_InputDelegate_class, empty_constructor, 0, 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, "InputDelegate", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_InputDelegate_class; - p->proto = jsb_cocostudio_InputDelegate_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_InputDelegate_prototype); + jsb_register_class(cx, jsb_cocostudio_InputDelegate_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ComController_class; @@ -8241,8 +7950,8 @@ bool js_cocos2dx_studio_ComController_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -8302,32 +8011,20 @@ void js_register_cocos2dx_studio_ComController(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComController_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComController_class, js_cocos2dx_studio_ComController_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, "ComController", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ComController_class; - p->proto = jsb_cocostudio_ComController_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComController_prototype); + jsb_register_class(cx, jsb_cocostudio_ComController_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.ComController.extend = cc.Class.extend; })()"); } @@ -8348,7 +8045,7 @@ bool js_cocos2dx_studio_ComRender_setNode(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -8399,7 +8096,7 @@ bool js_cocos2dx_studio_ComRender_create(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -8456,7 +8153,7 @@ bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -8479,8 +8176,8 @@ bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsva typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -8504,8 +8201,8 @@ bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsva typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // 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 proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -8559,32 +8256,20 @@ void js_register_cocos2dx_studio_ComRender(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComRender_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComRender_class, js_cocos2dx_studio_ComRender_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, "ComRender", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ComRender_class; - p->proto = jsb_cocostudio_ComRender_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComRender_prototype); + jsb_register_class(cx, jsb_cocostudio_ComRender_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_Frame_class; @@ -8649,7 +8334,7 @@ bool js_cocos2dx_studio_Frame_setNode(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -8677,7 +8362,7 @@ bool js_cocos2dx_studio_Frame_setTimeline(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8916,30 +8601,17 @@ void js_register_cocos2dx_studio_Frame(JSContext *cx, JS::HandleObject global) { jsb_cocostudio_timeline_Frame_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_timeline_Frame_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Frame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_Frame_class; - p->proto = jsb_cocostudio_timeline_Frame_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_Frame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_Frame_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_timeline_VisibleFrame_class; @@ -9020,8 +8692,8 @@ bool js_cocos2dx_studio_VisibleFrame_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9066,32 +8738,20 @@ void js_register_cocos2dx_studio_VisibleFrame(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_VisibleFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_VisibleFrame_class, js_cocos2dx_studio_VisibleFrame_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, "VisibleFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_VisibleFrame_class; - p->proto = jsb_cocostudio_timeline_VisibleFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_VisibleFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_VisibleFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_TextureFrame_class; @@ -9172,8 +8832,8 @@ bool js_cocos2dx_studio_TextureFrame_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9218,32 +8878,20 @@ void js_register_cocos2dx_studio_TextureFrame(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_TextureFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_TextureFrame_class, js_cocos2dx_studio_TextureFrame_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, "TextureFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_TextureFrame_class; - p->proto = jsb_cocostudio_timeline_TextureFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_TextureFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_TextureFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_RotationFrame_class; @@ -9324,8 +8972,8 @@ bool js_cocos2dx_studio_RotationFrame_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9370,32 +9018,20 @@ void js_register_cocos2dx_studio_RotationFrame(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_RotationFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_RotationFrame_class, js_cocos2dx_studio_RotationFrame_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, "RotationFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_RotationFrame_class; - p->proto = jsb_cocostudio_timeline_RotationFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_RotationFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_RotationFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_SkewFrame_class; @@ -9514,8 +9150,8 @@ bool js_cocos2dx_studio_SkewFrame_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9562,32 +9198,20 @@ void js_register_cocos2dx_studio_SkewFrame(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_SkewFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_SkewFrame_class, js_cocos2dx_studio_SkewFrame_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, "SkewFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_SkewFrame_class; - p->proto = jsb_cocostudio_timeline_SkewFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_SkewFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_SkewFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_RotationSkewFrame_class; @@ -9630,8 +9254,8 @@ bool js_cocos2dx_studio_RotationSkewFrame_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9674,32 +9298,20 @@ void js_register_cocos2dx_studio_RotationSkewFrame(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_SkewFrame_prototype); jsb_cocostudio_timeline_RotationSkewFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_SkewFrame_prototype), + parent_proto, jsb_cocostudio_timeline_RotationSkewFrame_class, js_cocos2dx_studio_RotationSkewFrame_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, "RotationSkewFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_RotationSkewFrame_class; - p->proto = jsb_cocostudio_timeline_RotationSkewFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_SkewFrame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_RotationSkewFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_RotationSkewFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_PositionFrame_class; @@ -9856,8 +9468,8 @@ bool js_cocos2dx_studio_PositionFrame_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9906,32 +9518,20 @@ void js_register_cocos2dx_studio_PositionFrame(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_PositionFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_PositionFrame_class, js_cocos2dx_studio_PositionFrame_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, "PositionFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_PositionFrame_class; - p->proto = jsb_cocostudio_timeline_PositionFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_PositionFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_PositionFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_ScaleFrame_class; @@ -10070,8 +9670,8 @@ bool js_cocos2dx_studio_ScaleFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -10119,32 +9719,20 @@ void js_register_cocos2dx_studio_ScaleFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_ScaleFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_ScaleFrame_class, js_cocos2dx_studio_ScaleFrame_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, "ScaleFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_ScaleFrame_class; - p->proto = jsb_cocostudio_timeline_ScaleFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ScaleFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ScaleFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_AnchorPointFrame_class; @@ -10225,8 +9813,8 @@ bool js_cocos2dx_studio_AnchorPointFrame_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -10271,32 +9859,20 @@ void js_register_cocos2dx_studio_AnchorPointFrame(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_AnchorPointFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_AnchorPointFrame_class, js_cocos2dx_studio_AnchorPointFrame_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, "AnchorPointFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_AnchorPointFrame_class; - p->proto = jsb_cocostudio_timeline_AnchorPointFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_AnchorPointFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_AnchorPointFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_InnerActionFrame_class; @@ -10531,8 +10107,8 @@ bool js_cocos2dx_studio_InnerActionFrame_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -10585,32 +10161,20 @@ void js_register_cocos2dx_studio_InnerActionFrame(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_InnerActionFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_InnerActionFrame_class, js_cocos2dx_studio_InnerActionFrame_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, "InnerActionFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_InnerActionFrame_class; - p->proto = jsb_cocostudio_timeline_InnerActionFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_InnerActionFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_InnerActionFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_ColorFrame_class; @@ -10691,8 +10255,8 @@ bool js_cocos2dx_studio_ColorFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -10737,32 +10301,20 @@ void js_register_cocos2dx_studio_ColorFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_ColorFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_ColorFrame_class, js_cocos2dx_studio_ColorFrame_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, "ColorFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_ColorFrame_class; - p->proto = jsb_cocostudio_timeline_ColorFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ColorFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ColorFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_AlphaFrame_class; @@ -10843,8 +10395,8 @@ bool js_cocos2dx_studio_AlphaFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -10889,32 +10441,20 @@ void js_register_cocos2dx_studio_AlphaFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_AlphaFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_AlphaFrame_class, js_cocos2dx_studio_AlphaFrame_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, "AlphaFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_AlphaFrame_class; - p->proto = jsb_cocostudio_timeline_AlphaFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_AlphaFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_AlphaFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_EventFrame_class; @@ -11011,8 +10551,8 @@ bool js_cocos2dx_studio_EventFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -11058,32 +10598,20 @@ void js_register_cocos2dx_studio_EventFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_EventFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_EventFrame_class, js_cocos2dx_studio_EventFrame_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, "EventFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_EventFrame_class; - p->proto = jsb_cocostudio_timeline_EventFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_EventFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_EventFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_ZOrderFrame_class; @@ -11164,8 +10692,8 @@ bool js_cocos2dx_studio_ZOrderFrame_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -11210,32 +10738,20 @@ void js_register_cocos2dx_studio_ZOrderFrame(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_ZOrderFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_ZOrderFrame_class, js_cocos2dx_studio_ZOrderFrame_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, "ZOrderFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_ZOrderFrame_class; - p->proto = jsb_cocostudio_timeline_ZOrderFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ZOrderFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ZOrderFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_BlendFuncFrame_class; @@ -11316,8 +10832,8 @@ bool js_cocos2dx_studio_BlendFuncFrame_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -11362,32 +10878,20 @@ void js_register_cocos2dx_studio_BlendFuncFrame(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_BlendFuncFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_BlendFuncFrame_class, js_cocos2dx_studio_BlendFuncFrame_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, "BlendFuncFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_BlendFuncFrame_class; - p->proto = jsb_cocostudio_timeline_BlendFuncFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_BlendFuncFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_BlendFuncFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_Timeline_class; @@ -11452,7 +10956,7 @@ bool js_cocos2dx_studio_Timeline_setNode(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -11506,7 +11010,7 @@ bool js_cocos2dx_studio_Timeline_insertFrame(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11555,7 +11059,7 @@ bool js_cocos2dx_studio_Timeline_addFrame(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11644,7 +11148,7 @@ bool js_cocos2dx_studio_Timeline_removeFrame(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11672,7 +11176,7 @@ bool js_cocos2dx_studio_Timeline_setActionTimeline(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::ActionTimeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11743,8 +11247,8 @@ bool js_cocos2dx_studio_Timeline_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -11800,30 +11304,17 @@ void js_register_cocos2dx_studio_Timeline(JSContext *cx, JS::HandleObject global jsb_cocostudio_timeline_Timeline_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_timeline_Timeline_class, js_cocos2dx_studio_Timeline_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, "Timeline", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_Timeline_class; - p->proto = jsb_cocostudio_timeline_Timeline_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_Timeline_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_Timeline_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_timeline_ActionTimelineData_class; @@ -11930,8 +11421,8 @@ bool js_cocos2dx_studio_ActionTimelineData_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -11977,30 +11468,17 @@ void js_register_cocos2dx_studio_ActionTimelineData(JSContext *cx, JS::HandleObj jsb_cocostudio_timeline_ActionTimelineData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_timeline_ActionTimelineData_class, js_cocos2dx_studio_ActionTimelineData_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, "ActionTimelineData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_ActionTimelineData_class; - p->proto = jsb_cocostudio_timeline_ActionTimelineData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ActionTimelineData_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ActionTimelineData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_timeline_ActionTimeline_class; @@ -12019,7 +11497,8 @@ bool js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocostudio::timeline::Frame* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -12085,7 +11564,8 @@ bool js_cocos2dx_studio_ActionTimeline_setAnimationEndCallFunc(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -12125,7 +11605,7 @@ bool js_cocos2dx_studio_ActionTimeline_addTimeline(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12223,7 +11703,7 @@ bool js_cocos2dx_studio_ActionTimeline_removeTimeline(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12250,7 +11730,8 @@ bool js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc(JSContext *cx, uint3 do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -12393,7 +11874,8 @@ bool js_cocos2dx_studio_ActionTimeline_addFrameEndCallFunc(JSContext *cx, uint32 do { if(JS_TypeOfValue(cx, args.get(2)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(2))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(2))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -12560,7 +12042,7 @@ bool js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay : Invalid Native Object"); @@ -12795,8 +12277,8 @@ bool js_cocos2dx_studio_ActionTimeline_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -12870,32 +12352,20 @@ void js_register_cocos2dx_studio_ActionTimeline(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocostudio_timeline_ActionTimeline_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocostudio_timeline_ActionTimeline_class, js_cocos2dx_studio_ActionTimeline_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, "ActionTimeline", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_ActionTimeline_class; - p->proto = jsb_cocostudio_timeline_ActionTimeline_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ActionTimeline_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ActionTimeline_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_BoneNode_class; @@ -12926,7 +12396,7 @@ bool js_cocos2dx_studio_BoneNode_getChildBones(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_getChildBones : Invalid Native Object"); @@ -13072,7 +12542,7 @@ bool js_cocos2dx_studio_BoneNode_displaySkin(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_displaySkin : Invalid Native Object"); @@ -13096,7 +12566,7 @@ bool js_cocos2dx_studio_BoneNode_displaySkin(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::SkinNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13138,7 +12608,7 @@ bool js_cocos2dx_studio_BoneNode_addSkin(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_addSkin : Invalid Native Object"); @@ -13149,7 +12619,7 @@ bool js_cocos2dx_studio_BoneNode_addSkin(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::SkinNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13172,7 +12642,7 @@ bool js_cocos2dx_studio_BoneNode_addSkin(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::SkinNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13241,7 +12711,7 @@ bool js_cocos2dx_studio_BoneNode_getSkins(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_getSkins : Invalid Native Object"); @@ -13422,8 +12892,8 @@ bool js_cocos2dx_studio_BoneNode_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13502,32 +12972,20 @@ void js_register_cocos2dx_studio_BoneNode(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_timeline_BoneNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_timeline_BoneNode_class, js_cocos2dx_studio_BoneNode_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, "BoneNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_BoneNode_class; - p->proto = jsb_cocostudio_timeline_BoneNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_BoneNode_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_BoneNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.BoneNode.extend = cc.Class.extend; })()"); } @@ -13570,7 +13028,7 @@ bool js_cocos2dx_studio_SkeletonNode_changeSkins(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::SkeletonNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_SkeletonNode_changeSkins : Invalid Native Object"); @@ -13676,8 +13134,8 @@ bool js_cocos2dx_studio_SkeletonNode_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13741,32 +13199,20 @@ void js_register_cocos2dx_studio_SkeletonNode(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_BoneNode_prototype); jsb_cocostudio_timeline_SkeletonNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_BoneNode_prototype), + parent_proto, jsb_cocostudio_timeline_SkeletonNode_class, js_cocos2dx_studio_SkeletonNode_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, "SkeletonNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_timeline_SkeletonNode_class; - p->proto = jsb_cocostudio_timeline_SkeletonNode_prototype; - p->parentProto = jsb_cocostudio_timeline_BoneNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_SkeletonNode_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_SkeletonNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.SkeletonNode.extend = cc.Class.extend; })()"); } @@ -13886,8 +13332,8 @@ bool js_cocos2dx_studio_ComExtensionData_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13934,32 +13380,20 @@ void js_register_cocos2dx_studio_ComExtensionData(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComExtensionData_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComExtensionData_class, js_cocos2dx_studio_ComExtensionData_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, "ComExtensionData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_cocostudio_ComExtensionData_class; - p->proto = jsb_cocostudio_ComExtensionData_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComExtensionData_prototype); + jsb_register_class(cx, jsb_cocostudio_ComExtensionData_class, proto, parent_proto); } void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index be7803f52b..54bf6dfde8 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -127,7 +127,7 @@ bool js_cocos2dx_ui_LayoutParameter_copyProperties(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::LayoutParameter*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -178,8 +178,8 @@ bool js_cocos2dx_ui_LayoutParameter_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -226,30 +226,17 @@ void js_register_cocos2dx_ui_LayoutParameter(JSContext *cx, JS::HandleObject glo jsb_cocos2d_ui_LayoutParameter_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ui_LayoutParameter_class, js_cocos2dx_ui_LayoutParameter_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, "LayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_LayoutParameter_class; - p->proto = jsb_cocos2d_ui_LayoutParameter_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LayoutParameter_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ui_LinearLayoutParameter_class; @@ -330,8 +317,8 @@ bool js_cocos2dx_ui_LinearLayoutParameter_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -376,32 +363,20 @@ void js_register_cocos2dx_ui_LinearLayoutParameter(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype); jsb_cocos2d_ui_LinearLayoutParameter_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), + parent_proto, jsb_cocos2d_ui_LinearLayoutParameter_class, js_cocos2dx_ui_LinearLayoutParameter_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, "LinearLayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_LinearLayoutParameter_class; - p->proto = jsb_cocos2d_ui_LinearLayoutParameter_prototype; - p->parentProto = jsb_cocos2d_ui_LayoutParameter_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LinearLayoutParameter_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LinearLayoutParameter_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_RelativeLayoutParameter_class; @@ -558,8 +533,8 @@ bool js_cocos2dx_ui_RelativeLayoutParameter_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -608,32 +583,20 @@ void js_register_cocos2dx_ui_RelativeLayoutParameter(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype); jsb_cocos2d_ui_RelativeLayoutParameter_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), + parent_proto, jsb_cocos2d_ui_RelativeLayoutParameter_class, js_cocos2dx_ui_RelativeLayoutParameter_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, "RelativeLayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RelativeLayoutParameter_class; - p->proto = jsb_cocos2d_ui_RelativeLayoutParameter_prototype; - p->parentProto = jsb_cocos2d_ui_LayoutParameter_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RelativeLayoutParameter_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RelativeLayoutParameter_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_Widget_class; @@ -1026,7 +989,8 @@ bool js_cocos2dx_ui_Widget_addCCSEventListener(JSContext *cx, uint32_t argc, jsv do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Ref* larg0, int larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1134,7 +1098,7 @@ bool js_cocos2dx_ui_Widget_findNextFocusedWidget(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1471,7 +1435,7 @@ bool js_cocos2dx_ui_Widget_setLayoutParameter(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::LayoutParameter*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1581,7 +1545,7 @@ bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1590,7 +1554,7 @@ bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1659,7 +1623,7 @@ bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (const cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1668,7 +1632,7 @@ bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1725,7 +1689,7 @@ bool js_cocos2dx_ui_Widget_updateSizeAndPosition(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_updateSizeAndPosition : Invalid Native Object"); @@ -1766,7 +1730,7 @@ bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1775,7 +1739,7 @@ bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1843,6 +1807,56 @@ bool js_cocos2dx_ui_Widget_getCallbackType(JSContext *cx, uint32_t argc, jsval * JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCallbackType : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Widget_addTouchEventListener(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::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_addTouchEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::Widget::TouchEventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_addTouchEventListener : Error processing arguments"); + cobj->addTouchEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_addTouchEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Widget_getTouchEndPosition(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1896,7 +1910,7 @@ bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1905,7 +1919,7 @@ bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1932,7 +1946,8 @@ bool js_cocos2dx_ui_Widget_addClickEventListener(JSContext *cx, uint32_t argc, j do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -2062,7 +2077,7 @@ bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -2071,7 +2086,7 @@ bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -2217,8 +2232,8 @@ bool js_cocos2dx_ui_Widget_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -2325,6 +2340,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { JS_FN("getTouchMovePosition", js_cocos2dx_ui_Widget_getTouchMovePosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSizeType", js_cocos2dx_ui_Widget_getSizeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCallbackType", js_cocos2dx_ui_Widget_getCallbackType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addTouchEventListener", js_cocos2dx_ui_Widget_addTouchEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchEndPosition", js_cocos2dx_ui_Widget_getTouchEndPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionPercent", js_cocos2dx_ui_Widget_getPositionPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("propagateTouchEvent", js_cocos2dx_ui_Widget_propagateTouchEvent, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2348,32 +2364,20 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ProtectedNode_prototype); jsb_cocos2d_ui_Widget_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ProtectedNode_prototype), + parent_proto, jsb_cocos2d_ui_Widget_class, js_cocos2dx_ui_Widget_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, "Widget", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_Widget_class; - p->proto = jsb_cocos2d_ui_Widget_prototype; - p->parentProto = jsb_cocos2d_ProtectedNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Widget_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Widget_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Widget.extend = cc.Class.extend; })()"); } @@ -2526,7 +2530,7 @@ bool js_cocos2dx_ui_Layout_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -2661,7 +2665,7 @@ bool js_cocos2dx_ui_Layout_setBackGroundColor(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColor : Invalid Native Object"); @@ -3101,8 +3105,8 @@ bool js_cocos2dx_ui_Layout_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -3197,32 +3201,20 @@ void js_register_cocos2dx_ui_Layout(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Layout_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Layout_class, js_cocos2dx_ui_Layout_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, "Layout", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_Layout_class; - p->proto = jsb_cocos2d_ui_Layout_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Layout_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Layout_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Layout.extend = cc.Class.extend; })()"); } @@ -3397,7 +3389,7 @@ bool js_cocos2dx_ui_Button_getDisabledFile(JSContext *cx, uint32_t argc, jsval * if (argc == 0) { cocos2d::ResouceData ret = cobj->getDisabledFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -3471,7 +3463,7 @@ bool js_cocos2dx_ui_Button_getNormalFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -3769,7 +3761,7 @@ bool js_cocos2dx_ui_Button_setTitleAlignment(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setTitleAlignment : Invalid Native Object"); @@ -3945,7 +3937,7 @@ bool js_cocos2dx_ui_Button_getPressedFile(JSContext *cx, uint32_t argc, jsval *v if (argc == 0) { cocos2d::ResouceData ret = cobj->getPressedFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4228,8 +4220,8 @@ bool js_cocos2dx_ui_Button_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -4327,32 +4319,20 @@ void js_register_cocos2dx_ui_Button(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Button_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Button_class, js_cocos2dx_ui_Button_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, "Button", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_Button_class; - p->proto = jsb_cocos2d_ui_Button_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Button_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Button_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Button.extend = cc.Class.extend; })()"); } @@ -4369,7 +4349,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile(JSContext *cx, uint3 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackDisabledFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4387,7 +4367,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile(JSContext *cx, uint if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossDisabeldFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4465,7 +4445,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4503,7 +4483,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackPressedFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4694,7 +4674,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile(JSContext *cx, uint32_ if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4947,37 +4927,75 @@ void js_register_cocos2dx_ui_AbstractCheckButton(JSContext *cx, JS::HandleObject JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_AbstractCheckButton_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_AbstractCheckButton_class, empty_constructor, 0, 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, "AbstractCheckButton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_AbstractCheckButton_class; - p->proto = jsb_cocos2d_ui_AbstractCheckButton_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_AbstractCheckButton_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_CheckBox_class; JSObject *jsb_cocos2d_ui_CheckBox_prototype; +bool js_cocos2dx_ui_CheckBox_addEventListener(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::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::CheckBox::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5153,8 +5171,8 @@ bool js_cocos2dx_ui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5205,6 +5223,7 @@ void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("addEventListener", js_cocos2dx_ui_CheckBox_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_CheckBox_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -5215,38 +5234,76 @@ void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype); jsb_cocos2d_ui_CheckBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype), + parent_proto, jsb_cocos2d_ui_CheckBox_class, js_cocos2dx_ui_CheckBox_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, "CheckBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_CheckBox_class; - p->proto = jsb_cocos2d_ui_CheckBox_prototype; - p->parentProto = jsb_cocos2d_ui_AbstractCheckButton_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_CheckBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_CheckBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.CheckBox.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ui_RadioButton_class; JSObject *jsb_cocos2d_ui_RadioButton_prototype; +bool js_cocos2dx_ui_RadioButton_addEventListener(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::ui::RadioButton* cobj = (cocos2d::ui::RadioButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButton_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::ui::RadioButton* larg0, cocos2d::ui::RadioButton::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RadioButton*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RadioButton_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RadioButton_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_RadioButton_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5422,8 +5479,8 @@ bool js_cocos2dx_ui_RadioButton_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5474,6 +5531,7 @@ void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("addEventListener", js_cocos2dx_ui_RadioButton_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_RadioButton_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -5484,32 +5542,20 @@ void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype); jsb_cocos2d_ui_RadioButton_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype), + parent_proto, jsb_cocos2d_ui_RadioButton_class, js_cocos2dx_ui_RadioButton_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, "RadioButton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RadioButton_class; - p->proto = jsb_cocos2d_ui_RadioButton_prototype; - p->parentProto = jsb_cocos2d_ui_AbstractCheckButton_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RadioButton_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RadioButton_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RadioButton.extend = cc.Class.extend; })()"); } @@ -5530,7 +5576,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_removeRadioButton(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5607,7 +5653,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent : Invalid Native Object"); @@ -5618,7 +5664,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5644,6 +5690,57 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx JS_ReportError(cx, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent : wrong number of arguments"); return false; } +bool js_cocos2dx_ui_RadioButtonGroup_addEventListener(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::ui::RadioButtonGroup* cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::ui::RadioButton* larg0, int larg1, cocos2d::ui::RadioButtonGroup::EventType larg2) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[3]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RadioButton*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, larg1); + largv[2] = int32_to_jsval(cx, (int)larg2); + JS::RootedValue rval(cx); + bool succeed = func->invoke(3, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RadioButtonGroup_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RadioButtonGroup_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5721,7 +5818,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_addRadioButton(JSContext *cx, uint32_t argc 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5742,7 +5839,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButton(JSContext *cx, uint32_t a JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButton : Invalid Native Object"); @@ -5753,7 +5850,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButton(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5816,8 +5913,8 @@ bool js_cocos2dx_ui_RadioButtonGroup_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -5873,6 +5970,7 @@ void js_register_cocos2dx_ui_RadioButtonGroup(JSContext *cx, JS::HandleObject gl JS_FN("getSelectedButtonIndex", js_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAllowedNoSelection", js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelectedButtonWithoutEvent", js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_RadioButtonGroup_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllRadioButtons", js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRadioButtonByIndex", js_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNumberOfRadioButtons", js_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -5887,32 +5985,20 @@ void js_register_cocos2dx_ui_RadioButtonGroup(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_RadioButtonGroup_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_RadioButtonGroup_class, js_cocos2dx_ui_RadioButtonGroup_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, "RadioButtonGroup", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RadioButtonGroup_class; - p->proto = jsb_cocos2d_ui_RadioButtonGroup_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RadioButtonGroup_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RadioButtonGroup_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RadioButtonGroup.extend = cc.Class.extend; })()"); } @@ -6053,7 +6139,7 @@ bool js_cocos2dx_ui_ImageView_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -6200,8 +6286,8 @@ bool js_cocos2dx_ui_ImageView_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6270,32 +6356,20 @@ void js_register_cocos2dx_ui_ImageView(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_ImageView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_ImageView_class, js_cocos2dx_ui_ImageView_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, "ImageView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_ImageView_class; - p->proto = jsb_cocos2d_ui_ImageView_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ImageView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ImageView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ImageView.extend = cc.Class.extend; })()"); } @@ -6392,7 +6466,7 @@ bool js_cocos2dx_ui_Text_disableEffect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_disableEffect : Invalid Native Object"); @@ -6903,8 +6977,8 @@ bool js_cocos2dx_ui_Text_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -6989,32 +7063,20 @@ void js_register_cocos2dx_ui_Text(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Text_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Text_class, js_cocos2dx_ui_Text_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, "Text", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_Text_class; - p->proto = jsb_cocos2d_ui_Text_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Text_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Text_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Text.extend = cc.Class.extend; })()"); } @@ -7087,7 +7149,7 @@ bool js_cocos2dx_ui_TextAtlas_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -7232,8 +7294,8 @@ bool js_cocos2dx_ui_TextAtlas_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -7300,32 +7362,20 @@ void js_register_cocos2dx_ui_TextAtlas(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_TextAtlas_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_TextAtlas_class, js_cocos2dx_ui_TextAtlas_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, "TextAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_TextAtlas_class; - p->proto = jsb_cocos2d_ui_TextAtlas_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_TextAtlas_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_TextAtlas_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.TextAtlas.extend = cc.Class.extend; })()"); } @@ -7412,7 +7462,7 @@ bool js_cocos2dx_ui_LoadingBar_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -7683,8 +7733,8 @@ bool js_cocos2dx_ui_LoadingBar_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -7755,32 +7805,20 @@ void js_register_cocos2dx_ui_LoadingBar(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_LoadingBar_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_LoadingBar_class, js_cocos2dx_ui_LoadingBar_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, "LoadingBar", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_LoadingBar_class; - p->proto = jsb_cocos2d_ui_LoadingBar_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LoadingBar_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LoadingBar_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.LoadingBar.extend = cc.Class.extend; })()"); } @@ -8204,6 +8242,56 @@ bool js_cocos2dx_ui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t arg JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToPercentVertical : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_ScrollView_addEventListener(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::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::ScrollView::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_ScrollView_setScrollBarAutoHideTime(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -8820,8 +8908,8 @@ bool js_cocos2dx_ui_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -8893,6 +8981,7 @@ void js_register_cocos2dx_ui_ScrollView(JSContext *cx, JS::HandleObject global) JS_FN("getInnerContainerSize", js_cocos2dx_ui_ScrollView_getInnerContainerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBounceEnabled", js_cocos2dx_ui_ScrollView_isBounceEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToPercentVertical", js_cocos2dx_ui_ScrollView_jumpToPercentVertical, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_ScrollView_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScrollBarAutoHideTime", js_cocos2dx_ui_ScrollView_setScrollBarAutoHideTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScrollBarPositionFromCornerForHorizontal", js_cocos2dx_ui_ScrollView_setScrollBarPositionFromCornerForHorizontal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInertiaScrollEnabled", js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -8932,32 +9021,20 @@ void js_register_cocos2dx_ui_ScrollView(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_ScrollView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_ScrollView_class, js_cocos2dx_ui_ScrollView_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, "ScrollView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_ScrollView_class; - p->proto = jsb_cocos2d_ui_ScrollView_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ScrollView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ScrollView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ScrollView.extend = cc.Class.extend; })()"); } @@ -9119,7 +9196,7 @@ bool js_cocos2dx_ui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9149,7 +9226,7 @@ bool js_cocos2dx_ui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9203,6 +9280,56 @@ bool js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary(JSContext *cx, uint JS_ReportError(cx, "js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_ListView_addEventListener(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::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::ListView::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_ListView_doLayout(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9422,7 +9549,7 @@ bool js_cocos2dx_ui_ListView_scrollToItem(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_scrollToItem : Invalid Native Object"); @@ -9601,7 +9728,7 @@ bool js_cocos2dx_ui_ListView_setItemModel(JSContext *cx, uint32_t argc, jsval *v 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9630,7 +9757,7 @@ bool js_cocos2dx_ui_ListView_insertCustomItem(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9703,8 +9830,8 @@ bool js_cocos2dx_ui_ListView_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -9766,6 +9893,7 @@ void js_register_cocos2dx_ui_ListView(JSContext *cx, JS::HandleObject global) { JS_FN("pushBackCustomItem", js_cocos2dx_ui_ListView_pushBackCustomItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertDefaultItem", js_cocos2dx_ui_ListView_insertDefaultItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMagneticAllowedOutOfBoundary", js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_ListView_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("doLayout", js_cocos2dx_ui_ListView_doLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTopmostItemInCurrentView", js_cocos2dx_ui_ListView_getTopmostItemInCurrentView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllItems", js_cocos2dx_ui_ListView_removeAllItems, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -9794,32 +9922,20 @@ void js_register_cocos2dx_ui_ListView(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_ScrollView_prototype); jsb_cocos2d_ui_ListView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_ScrollView_prototype), + parent_proto, jsb_cocos2d_ui_ListView_class, js_cocos2dx_ui_ListView_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, "ListView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_ListView_class; - p->proto = jsb_cocos2d_ui_ListView_prototype; - p->parentProto = jsb_cocos2d_ui_ScrollView_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ListView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ListView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ListView.extend = cc.Class.extend; })()"); } @@ -9934,7 +10050,7 @@ bool js_cocos2dx_ui_Slider_getBallNormalFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -9990,7 +10106,7 @@ bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallPressedFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10072,6 +10188,56 @@ bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextures : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Slider_addEventListener(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::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::Slider::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Slider_setMaxPercent(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -10132,7 +10298,7 @@ bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getProgressBarFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10198,7 +10364,7 @@ bool js_cocos2dx_ui_Slider_getBackFile(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10274,7 +10440,7 @@ bool js_cocos2dx_ui_Slider_getBallDisabeldFile(JSContext *cx, uint32_t argc, jsv if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallDisabeldFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10479,8 +10645,8 @@ bool js_cocos2dx_ui_Slider_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -10541,6 +10707,7 @@ void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global) { JS_FN("getBallPressedFile", js_cocos2dx_ui_Slider_getBallPressedFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_ui_Slider_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTextures", js_cocos2dx_ui_Slider_loadSlidBallTextures, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_Slider_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxPercent", js_cocos2dx_ui_Slider_setMaxPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadBarTexture", js_cocos2dx_ui_Slider_loadBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProgressBarFile", js_cocos2dx_ui_Slider_getProgressBarFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -10565,32 +10732,20 @@ void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Slider_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Slider_class, js_cocos2dx_ui_Slider_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, "Slider", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_Slider_class; - p->proto = jsb_cocos2d_ui_Slider_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Slider_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Slider_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Slider.extend = cc.Class.extend; })()"); } @@ -10611,7 +10766,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10719,7 +10874,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward(JSContext *cx, uint3 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10959,7 +11114,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldInsertText(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10991,7 +11146,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME(JSContext *cx, uint32 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11164,8 +11319,8 @@ bool js_cocos2dx_ui_UICCTextField_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -11233,32 +11388,20 @@ void js_register_cocos2dx_ui_UICCTextField(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TextFieldTTF_prototype); jsb_cocos2d_ui_UICCTextField_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TextFieldTTF_prototype), + parent_proto, jsb_cocos2d_ui_UICCTextField_class, js_cocos2dx_ui_UICCTextField_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, "UICCTextField", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_UICCTextField_class; - p->proto = jsb_cocos2d_ui_UICCTextField_prototype; - p->parentProto = jsb_cocos2d_TextFieldTTF_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_UICCTextField_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_UICCTextField_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_TextField_class; @@ -11528,6 +11671,56 @@ bool js_cocos2dx_ui_TextField_setTextVerticalAlignment(JSContext *cx, uint32_t a JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTextVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_TextField_addEventListener(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::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::TextField::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -11813,7 +12006,7 @@ bool js_cocos2dx_ui_TextField_setPlaceHolderColor(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setPlaceHolderColor : Invalid Native Object"); @@ -12121,8 +12314,8 @@ bool js_cocos2dx_ui_TextField_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -12187,6 +12380,7 @@ void js_register_cocos2dx_ui_TextField(JSContext *cx, JS::HandleObject global) { JS_FN("setString", js_cocos2dx_ui_TextField_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDetachWithIME", js_cocos2dx_ui_TextField_getDetachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextVerticalAlignment", js_cocos2dx_ui_TextField_setTextVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_TextField_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("didNotSelectSelf", js_cocos2dx_ui_TextField_didNotSelectSelf, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontName", js_cocos2dx_ui_TextField_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextAreaSize", js_cocos2dx_ui_TextField_setTextAreaSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -12223,32 +12417,20 @@ void js_register_cocos2dx_ui_TextField(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_TextField_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_TextField_class, js_cocos2dx_ui_TextField_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, "TextField", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_TextField_class; - p->proto = jsb_cocos2d_ui_TextField_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_TextField_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_TextField_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.TextField.extend = cc.Class.extend; })()"); } @@ -12321,7 +12503,7 @@ bool js_cocos2dx_ui_TextBMFont_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -12433,8 +12615,8 @@ bool js_cocos2dx_ui_TextBMFont_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -12500,32 +12682,20 @@ void js_register_cocos2dx_ui_TextBMFont(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_TextBMFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_TextBMFont_class, js_cocos2dx_ui_TextBMFont_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, "TextBMFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_TextBMFont_class; - p->proto = jsb_cocos2d_ui_TextBMFont_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_TextBMFont_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_TextBMFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.TextBMFont.extend = cc.Class.extend; })()"); } @@ -12661,7 +12831,7 @@ bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12708,7 +12878,7 @@ bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12722,6 +12892,56 @@ bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_PageView_removePage : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_PageView_addEventListener(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::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::PageView::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_PageView_setCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -12854,7 +13074,7 @@ bool js_cocos2dx_ui_PageView_addPage(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12980,8 +13200,8 @@ bool js_cocos2dx_ui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13041,6 +13261,7 @@ void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { JS_FN("insertPage", js_cocos2dx_ui_PageView_insertPage, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentPageIndex", js_cocos2dx_ui_PageView_getCurrentPageIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removePage", js_cocos2dx_ui_PageView_removePage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_PageView_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCurrentPageIndex", js_cocos2dx_ui_PageView_setCurrentPageIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIndicatorEnabled", js_cocos2dx_ui_PageView_getIndicatorEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToPage", js_cocos2dx_ui_PageView_scrollToPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -13061,32 +13282,20 @@ void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_ListView_prototype); jsb_cocos2d_ui_PageView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_ListView_prototype), + parent_proto, jsb_cocos2d_ui_PageView_class, js_cocos2dx_ui_PageView_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, "PageView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_PageView_class; - p->proto = jsb_cocos2d_ui_PageView_prototype; - p->parentProto = jsb_cocos2d_ui_ListView_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_PageView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_PageView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.PageView.extend = cc.Class.extend; })()"); } @@ -13125,7 +13334,7 @@ bool js_cocos2dx_ui_Helper_convertBoundingBoxToScreen(JSContext *cx, uint32_t ar 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -13168,7 +13377,7 @@ bool js_cocos2dx_ui_Helper_seekActionWidgetByActionTag(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13203,7 +13412,7 @@ bool js_cocos2dx_ui_Helper_seekWidgetByName(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13238,7 +13447,7 @@ bool js_cocos2dx_ui_Helper_seekWidgetByTag(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13292,7 +13501,7 @@ bool js_cocos2dx_ui_Helper_doLayout(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -13346,30 +13555,17 @@ void js_register_cocos2dx_ui_Helper(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ui_Helper_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ui_Helper_class, empty_constructor, 0, 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, "Helper", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_Helper_class; - p->proto = jsb_cocos2d_ui_Helper_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Helper_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Helper_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ui_RichElement_class; @@ -13417,8 +13613,8 @@ bool js_cocos2dx_ui_RichElement_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13476,30 +13672,17 @@ void js_register_cocos2dx_ui_RichElement(JSContext *cx, JS::HandleObject global) jsb_cocos2d_ui_RichElement_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ui_RichElement_class, js_cocos2dx_ui_RichElement_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, "RichElement", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RichElement_class; - p->proto = jsb_cocos2d_ui_RichElement_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElement_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElement_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { ccui.RichElement.extend = cc.Class.extend; })()"); } @@ -13589,8 +13772,8 @@ bool js_cocos2dx_ui_RichElementText_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13651,32 +13834,20 @@ void js_register_cocos2dx_ui_RichElementText(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_RichElement_prototype); jsb_cocos2d_ui_RichElementText_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + parent_proto, jsb_cocos2d_ui_RichElementText_class, js_cocos2dx_ui_RichElementText_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, "RichElementText", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RichElementText_class; - p->proto = jsb_cocos2d_ui_RichElementText_prototype; - p->parentProto = jsb_cocos2d_ui_RichElement_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElementText_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElementText_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichElementText.extend = cc.Class.extend; })()"); } @@ -13758,8 +13929,8 @@ bool js_cocos2dx_ui_RichElementImage_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -13820,32 +13991,20 @@ void js_register_cocos2dx_ui_RichElementImage(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_RichElement_prototype); jsb_cocos2d_ui_RichElementImage_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + parent_proto, jsb_cocos2d_ui_RichElementImage_class, js_cocos2dx_ui_RichElementImage_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, "RichElementImage", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RichElementImage_class; - p->proto = jsb_cocos2d_ui_RichElementImage_prototype; - p->parentProto = jsb_cocos2d_ui_RichElement_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElementImage_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElementImage_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichElementImage.extend = cc.Class.extend; })()"); } @@ -13872,7 +14031,7 @@ bool js_cocos2dx_ui_RichElementCustomNode_init(JSContext *cx, uint32_t argc, jsv if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -13904,7 +14063,7 @@ bool js_cocos2dx_ui_RichElementCustomNode_create(JSContext *cx, uint32_t argc, j if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -13943,8 +14102,8 @@ bool js_cocos2dx_ui_RichElementCustomNode_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14005,32 +14164,20 @@ void js_register_cocos2dx_ui_RichElementCustomNode(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_RichElement_prototype); jsb_cocos2d_ui_RichElementCustomNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + parent_proto, jsb_cocos2d_ui_RichElementCustomNode_class, js_cocos2dx_ui_RichElementCustomNode_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, "RichElementCustomNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RichElementCustomNode_class; - p->proto = jsb_cocos2d_ui_RichElementCustomNode_prototype; - p->parentProto = jsb_cocos2d_ui_RichElement_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElementCustomNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElementCustomNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichElementCustomNode.extend = cc.Class.extend; })()"); } @@ -14052,7 +14199,7 @@ bool js_cocos2dx_ui_RichText_insertElement(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14081,7 +14228,7 @@ bool js_cocos2dx_ui_RichText_pushBackElement(JSContext *cx, uint32_t argc, jsval 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14138,7 +14285,7 @@ bool js_cocos2dx_ui_RichText_removeElement(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::RichText *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichText_removeElement : Invalid Native Object"); @@ -14149,7 +14296,7 @@ bool js_cocos2dx_ui_RichText_removeElement(JSContext *cx, uint32_t argc, jsval * 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14212,8 +14359,8 @@ bool js_cocos2dx_ui_RichText_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14278,32 +14425,20 @@ void js_register_cocos2dx_ui_RichText(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_RichText_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_RichText_class, js_cocos2dx_ui_RichText_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, "RichText", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RichText_class; - p->proto = jsb_cocos2d_ui_RichText_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichText_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichText_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichText.extend = cc.Class.extend; })()"); } @@ -14392,8 +14527,8 @@ bool js_cocos2dx_ui_HBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14454,32 +14589,20 @@ void js_register_cocos2dx_ui_HBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_HBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_HBox_class, js_cocos2dx_ui_HBox_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, "HBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_HBox_class; - p->proto = jsb_cocos2d_ui_HBox_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_HBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_HBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.HBox.extend = cc.Class.extend; })()"); } @@ -14568,8 +14691,8 @@ bool js_cocos2dx_ui_VBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14630,32 +14753,20 @@ void js_register_cocos2dx_ui_VBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_VBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_VBox_class, js_cocos2dx_ui_VBox_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, "VBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_VBox_class; - p->proto = jsb_cocos2d_ui_VBox_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_VBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_VBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.VBox.extend = cc.Class.extend; })()"); } @@ -14744,8 +14855,8 @@ bool js_cocos2dx_ui_RelativeBox_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -14806,32 +14917,20 @@ void js_register_cocos2dx_ui_RelativeBox(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_RelativeBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_RelativeBox_class, js_cocos2dx_ui_RelativeBox_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, "RelativeBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_RelativeBox_class; - p->proto = jsb_cocos2d_ui_RelativeBox_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RelativeBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RelativeBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RelativeBox.extend = cc.Class.extend; })()"); } @@ -14861,7 +14960,7 @@ bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_updateWithSprite : Invalid Native Object"); @@ -14872,7 +14971,7 @@ bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14907,7 +15006,7 @@ bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15120,7 +15219,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName : Invalid Native Object"); @@ -15228,7 +15327,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_init : Invalid Native Object"); @@ -15239,7 +15338,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15266,7 +15365,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15295,7 +15394,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15360,7 +15459,7 @@ bool js_cocos2dx_ui_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15377,7 +15476,7 @@ bool js_cocos2dx_ui_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, js 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15541,7 +15640,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithFile : Invalid Native Object"); @@ -15677,7 +15776,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame : Invalid Native Object"); @@ -15688,7 +15787,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15709,7 +15808,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t arg 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16001,7 +16100,7 @@ bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16032,7 +16131,7 @@ bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t a 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16071,8 +16170,8 @@ bool js_cocos2dx_ui_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16170,32 +16269,20 @@ void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ui_Scale9Sprite_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ui_Scale9Sprite_class, js_cocos2dx_ui_Scale9Sprite_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, "Scale9Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_Scale9Sprite_class; - p->proto = jsb_cocos2d_ui_Scale9Sprite_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Scale9Sprite_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Scale9Sprite_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Scale9Sprite.extend = cc.Class.extend; })()"); } @@ -16365,7 +16452,7 @@ bool js_cocos2dx_ui_EditBox_setPlaceholderFontColor(JSContext *cx, uint32_t argc JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFontColor : Invalid Native Object"); @@ -16401,7 +16488,7 @@ bool js_cocos2dx_ui_EditBox_setFontColor(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setFontColor : Invalid Native Object"); @@ -16459,7 +16546,7 @@ bool js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint3 JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite : Invalid Native Object"); @@ -16473,7 +16560,7 @@ bool js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16708,7 +16795,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16738,7 +16825,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16749,7 +16836,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -16779,7 +16866,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16790,7 +16877,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -16801,7 +16888,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -16840,8 +16927,8 @@ bool js_cocos2dx_ui_EditBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -16919,32 +17006,20 @@ void js_register_cocos2dx_ui_EditBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_EditBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_EditBox_class, js_cocos2dx_ui_EditBox_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, "EditBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_EditBox_class; - p->proto = jsb_cocos2d_ui_EditBox_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_EditBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_EditBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.EditBox.extend = cc.Class.extend; })()"); } @@ -17912,7 +17987,7 @@ bool js_cocos2dx_ui_LayoutComponent_bindLayoutComponent(JSContext *cx, uint32_t 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(); + JS::RootedObject tmpObj(cx, 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"); @@ -17951,8 +18026,8 @@ bool js_cocos2dx_ui_LayoutComponent_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -18062,32 +18137,20 @@ void js_register_cocos2dx_ui_LayoutComponent(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_ui_LayoutComponent_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_ui_LayoutComponent_class, js_cocos2dx_ui_LayoutComponent_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, "LayoutComponent", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_LayoutComponent_class; - p->proto = jsb_cocos2d_ui_LayoutComponent_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LayoutComponent_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LayoutComponent_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.LayoutComponent.extend = cc.Class.extend; })()"); } @@ -18277,7 +18340,7 @@ bool js_cocos2dx_ui_ScrollViewBar_create(JSContext *cx, uint32_t argc, jsval *vp 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -18311,7 +18374,7 @@ bool js_cocos2dx_ui_ScrollViewBar_constructor(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -18330,8 +18393,8 @@ bool js_cocos2dx_ui_ScrollViewBar_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); 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 @@ -18351,7 +18414,7 @@ bool js_cocos2dx_ui_ScrollViewBar_constructor(JSContext *cx, uint32_t argc, jsva 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(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -18414,32 +18477,20 @@ void js_register_cocos2dx_ui_ScrollViewBar(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ProtectedNode_prototype); jsb_cocos2d_ui_ScrollViewBar_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ProtectedNode_prototype), + parent_proto, jsb_cocos2d_ui_ScrollViewBar_class, js_cocos2dx_ui_ScrollViewBar_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, "ScrollViewBar", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest 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_ui_ScrollViewBar_class; - p->proto = jsb_cocos2d_ui_ScrollViewBar_prototype; - p->parentProto = jsb_cocos2d_ProtectedNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ScrollViewBar_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ScrollViewBar_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ScrollViewBar.extend = cc.Class.extend; })()"); } diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index 5ff1f071f9..4d6f753354 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -110,6 +110,7 @@ bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_ui_Widget_getTouchMovePosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getSizeType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getCallbackType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getTouchEndPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getPositionPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsval *vp); @@ -256,6 +257,7 @@ bool js_cocos2dx_ui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2dx_ui_CheckBox_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_CheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_CheckBox_createInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_CheckBox_CheckBox(JSContext *cx, uint32_t argc, jsval *vp); @@ -267,6 +269,7 @@ bool js_cocos2dx_ui_RadioButton_constructor(JSContext *cx, uint32_t argc, jsval void js_cocos2dx_ui_RadioButton_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RadioButton_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButton_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButton_createInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButton_RadioButton(JSContext *cx, uint32_t argc, jsval *vp); @@ -283,6 +286,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection(JSContext *cx, uint32_ bool js_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RadioButtonGroup_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons(JSContext *cx, uint32_t argc, jsval *vp); @@ -411,6 +415,7 @@ bool js_cocos2dx_ui_ScrollView_getInnerContainerPosition(JSContext *cx, uint32_t bool js_cocos2dx_ui_ScrollView_getInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_isBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_setScrollBarAutoHideTime(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_setScrollBarPositionFromCornerForHorizontal(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -462,6 +467,7 @@ bool js_cocos2dx_ui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_insertDefaultItem(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_doLayout(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_getTopmostItemInCurrentView(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_removeAllItems(JSContext *cx, uint32_t argc, jsval *vp); @@ -501,6 +507,7 @@ bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setMaxPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsval *vp); @@ -575,6 +582,7 @@ bool js_cocos2dx_ui_TextField_setInsertText(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_ui_TextField_setString(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_getFontName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp); @@ -637,6 +645,7 @@ bool js_cocos2dx_ui_PageView_getIndicatorPosition(JSContext *cx, uint32_t argc, bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_getCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_setCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_getIndicatorEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp); From 167aa9b6481df0f1984d0e8c28cf3dc5d45cc314 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 1 Dec 2015 15:00:45 +0800 Subject: [PATCH 189/192] Update console sub-module, update project template.json to meet file position change --- templates/js-template-runtime/cocos-project-template.json | 2 +- templates/lua-template-default/cocos-project-template.json | 2 +- templates/lua-template-runtime/cocos-project-template.json | 2 +- tools/cocos2d-console | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/js-template-runtime/cocos-project-template.json b/templates/js-template-runtime/cocos-project-template.json index 786c75bca1..4f38ecec4d 100644 --- a/templates/js-template-runtime/cocos-project-template.json +++ b/templates/js-template-runtime/cocos-project-template.json @@ -47,7 +47,7 @@ ] }, { - "from": "tools/simulator/frameworks/runtime-src/Classes", + "from": "cocos/scripting/js-bindings/manual", "to": "frameworks/runtime-src/Classes", "include": [ "js_module_register.h" diff --git a/templates/lua-template-default/cocos-project-template.json b/templates/lua-template-default/cocos-project-template.json index 6d44944420..ab7db13327 100644 --- a/templates/lua-template-default/cocos-project-template.json +++ b/templates/lua-template-default/cocos-project-template.json @@ -145,7 +145,7 @@ ] }, { - "from": "tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h", + "from": "cocos/scripting/lua-bindings/manual/lua_module_register.h", "to": "frameworks/runtime-src/Classes/" } ], diff --git a/templates/lua-template-runtime/cocos-project-template.json b/templates/lua-template-runtime/cocos-project-template.json index a4f6b3779c..45ec82da60 100644 --- a/templates/lua-template-runtime/cocos-project-template.json +++ b/templates/lua-template-runtime/cocos-project-template.json @@ -145,7 +145,7 @@ ] }, { - "from": "tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h", + "from": "cocos/scripting/lua-bindings/manual/lua_module_register.h", "to": "frameworks/runtime-src/Classes/" } ], diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 5089eb347b..be4cc39610 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 5089eb347b1d252c8f0a0d0c94c0e67d6bba723e +Subproject commit be4cc39610b447788cb60be470ed4122a314809c From e5d57b4fa2607731f46e17d2a74df4740d388b0f Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 1 Dec 2015 18:37:03 +0800 Subject: [PATCH 190/192] update binding-generator sub module & code --- .../js-bindings/manual/js_module_register.cpp | 5 +++-- .../js-bindings/manual/js_module_register.h | 2 +- tools/bindings-generator | 2 +- .../Classes/ide-support/RuntimeJsImpl.cpp | 21 ++++++++++++------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/js_module_register.cpp b/cocos/scripting/js-bindings/manual/js_module_register.cpp index c6739babf5..9c4785a466 100644 --- a/cocos/scripting/js-bindings/manual/js_module_register.cpp +++ b/cocos/scripting/js-bindings/manual/js_module_register.cpp @@ -119,7 +119,8 @@ int js_module_register() return 1; } -JSObject* get_jsb_cocos2d_FileUtils_prototype() +JS::HandleObject get_jsb_cocos2d_FileUtils_prototype() { - return jsb_cocos2d_FileUtils_prototype; + JS::RootedObject fileUtilsProto(ScriptingCore::getInstance()->getGlobalContext(), jsb_cocos2d_FileUtils_prototype); + return fileUtilsProto; } diff --git a/cocos/scripting/js-bindings/manual/js_module_register.h b/cocos/scripting/js-bindings/manual/js_module_register.h index aa06bd0cbe..cdb38b445c 100644 --- a/cocos/scripting/js-bindings/manual/js_module_register.h +++ b/cocos/scripting/js-bindings/manual/js_module_register.h @@ -6,7 +6,7 @@ CC_JS_DLL int js_module_register(); -CC_JS_DLL JSObject* get_jsb_cocos2d_FileUtils_prototype(); +CC_JS_DLL JS::HandleObject get_jsb_cocos2d_FileUtils_prototype(); #endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ diff --git a/tools/bindings-generator b/tools/bindings-generator index a0fe326ea3..2f9a05f308 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit a0fe326ea3d685d342ba2a61c0be6f9dee83f800 +Subproject commit 2f9a05f30839f9733da97ca0fffdc9dd20a71575 diff --git a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp index 02209c6511..ff8d08abac 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp +++ b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp @@ -50,7 +50,7 @@ bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object"); @@ -95,7 +95,7 @@ bool runtime_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Invalid Native Object"); @@ -144,13 +144,13 @@ void register_FileUtils(JSContext *cx, JS::HandleObject global) JS_GetProperty(cx, global, "cc", &nsval); if (nsval == JSVAL_VOID) { return; - } else { + } + else { ns.set(nsval.toObjectOrNull()); } - JSObject* fileUtils = get_jsb_cocos2d_FileUtils_prototype(); - JS::RootedObject proto(cx, fileUtils); - JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); - JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS::RootedObject proto(cx, get_jsb_cocos2d_FileUtils_prototype()); + JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); } RuntimeJsImpl* RuntimeJsImpl::create() @@ -231,7 +231,12 @@ void RuntimeJsImpl::onPrecompile(const rapidjson::Document& dArgParse, rapidjson const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) { - ScriptingCore::getInstance()->compileScript(objectfiles[i].GetString()); + ScriptingCore* sc = ScriptingCore::getInstance(); + JSContext* gc = sc->getGlobalContext(); + + sc->compileScript(objectfiles[i].GetString(), + JS::RootedObject(gc, sc->getGlobalObject()), + gc); } dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); From c0393ece7dab73a5c96a0392004a125f17d34765 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 1 Dec 2015 15:37:14 +0000 Subject: [PATCH 191/192] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index eea90890f9..ca53845498 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -5273,8 +5273,6 @@ "tools/simulator/frameworks/runtime-src/Classes/ide-support/lang", "tools/simulator/frameworks/runtime-src/Classes/ide-support/lua_debugger.c", "tools/simulator/frameworks/runtime-src/Classes/ide-support/lua_debugger.h", - "tools/simulator/frameworks/runtime-src/Classes/js_module_register.h", - "tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h", "tools/simulator/frameworks/runtime-src/proj.android/.classpath", "tools/simulator/frameworks/runtime-src/proj.android/.project", "tools/simulator/frameworks/runtime-src/proj.android/.settings/org.eclipse.jdt.core.prefs", @@ -5373,6 +5371,7 @@ "tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h", "tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.cpp", "tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h", + "tools/simulator/libsimulator/lib/SimulatorExport.h", "tools/simulator/libsimulator/lib/cocos2dx_extra.h", "tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp", "tools/simulator/libsimulator/lib/network/CCHTTPRequest.h", @@ -5472,6 +5471,8 @@ "tools/simulator/libsimulator/lib/runtime/Shine_png.cpp", "tools/simulator/libsimulator/lib/runtime/VisibleRect.cpp", "tools/simulator/libsimulator/lib/runtime/VisibleRect.h", + "tools/simulator/libsimulator/lib/runtime/Widget_mac.h", + "tools/simulator/libsimulator/lib/runtime/Widget_mac.mm", "tools/simulator/libsimulator/proj.android/Android.mk", "tools/simulator/libsimulator/proj.android/hellolua/Runtime_android.cpp", "tools/simulator/libsimulator/proj.ios_mac/ios/Prefix.pch", @@ -5557,6 +5558,7 @@ "cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.h", "cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp", "cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.h", + "cocos/scripting/js-bindings/manual/js-BindingsExport.h", "cocos/scripting/js-bindings/manual/js_bindings_config.h", "cocos/scripting/js-bindings/manual/js_bindings_core.cpp", "cocos/scripting/js-bindings/manual/js_bindings_core.h", @@ -5564,6 +5566,8 @@ "cocos/scripting/js-bindings/manual/js_bindings_opengl.h", "cocos/scripting/js-bindings/manual/js_manual_conversions.cpp", "cocos/scripting/js-bindings/manual/js_manual_conversions.h", + "cocos/scripting/js-bindings/manual/js_module_register.cpp", + "cocos/scripting/js-bindings/manual/js_module_register.h", "cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp", "cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.h", "cocos/scripting/js-bindings/manual/jsb_helper.h", @@ -6936,6 +6940,7 @@ "cocos/scripting/lua-bindings/manual/CCLuaValue.h", "cocos/scripting/lua-bindings/manual/Cocos2dxLuaLoader.cpp", "cocos/scripting/lua-bindings/manual/Cocos2dxLuaLoader.h", + "cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h", "cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp", "cocos/scripting/lua-bindings/manual/LuaBasicConversions.h", "cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.cpp", @@ -6970,6 +6975,8 @@ "cocos/scripting/lua-bindings/manual/controller/lua_cocos2dx_controller_manual.hpp", "cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp", "cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.h", + "cocos/scripting/lua-bindings/manual/lua_module_register.cpp", + "cocos/scripting/lua-bindings/manual/lua_module_register.h", "cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_conversions.cpp", "cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_conversions.h", "cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_manual.cpp", From df62e92d7b2a3d070088b0f2e3338654872d93f4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 1 Dec 2015 23:50:52 +0800 Subject: [PATCH 192/192] Correct bindings generator ref --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 2f9a05f308..250673608e 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 2f9a05f30839f9733da97ca0fffdc9dd20a71575 +Subproject commit 250673608e23c9644b96a8e9ef886ab4db96aaf7