diff --git a/AUTHORS b/AUTHORS index 4ec7b7de70..1fb0ec6e9e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,6 +13,10 @@ Developers: Rolando Abarca Javascript Binding and testjs + Squallium + Added ccFPSImages entity as linked resource on linux eclipse project setting. + Added CocosDenshion dependency to libextension project for eclipse project of linux. + longlene Improve android project creation script @@ -362,7 +366,8 @@ Developers: Refactoring emscripten building script. Peter Young (young40) - Implements setVisible() for CCEditBox + Implements setVisible() for CCEditBox. + Fixing a bug that event will not be sent to server when paramMap parameter of logEvent function is nil in plugin-x. csy1988525 Fixing a bug about display result is wrong when invoking CCControlButton:: setHighlighted. diff --git a/CocosDenshion/proj.mac/CocosDenshion.xcodeproj/project.pbxproj b/CocosDenshion/proj.mac/CocosDenshion.xcodeproj/project.pbxproj index 1c31a62577..810beeb4d2 100644 --- a/CocosDenshion/proj.mac/CocosDenshion.xcodeproj/project.pbxproj +++ b/CocosDenshion/proj.mac/CocosDenshion.xcodeproj/project.pbxproj @@ -258,7 +258,6 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; - OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = macosx; VALIDATE_PRODUCT = YES; }; diff --git a/cocos2d-ios.xcworkspace/contents.xcworkspacedata b/cocos2d-ios.xcworkspace/contents.xcworkspacedata index 455cfdbac8..e4605274d9 100644 --- a/cocos2d-ios.xcworkspace/contents.xcworkspacedata +++ b/cocos2d-ios.xcworkspace/contents.xcworkspacedata @@ -75,4 +75,49 @@ location = "group:scripting/lua/proj.ios/luabindings.xcodeproj"> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos2d-mac.xcworkspace/contents.xcworkspacedata b/cocos2d-mac.xcworkspace/contents.xcworkspacedata index 2fdc94ae40..3468d0041e 100644 --- a/cocos2d-mac.xcworkspace/contents.xcworkspacedata +++ b/cocos2d-mac.xcworkspace/contents.xcworkspacedata @@ -7,6 +7,9 @@ + + + + diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 221842d31b..77724c83e9 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -59,6 +59,7 @@ kazmath/src/GL/mat4stack.c \ kazmath/src/GL/matrix.c \ keypad_dispatcher/CCKeypadDelegate.cpp \ keypad_dispatcher/CCKeypadDispatcher.cpp \ +keyboard_dispatcher/CCKeyboardDispatcher.cpp \ label_nodes/CCLabelAtlas.cpp \ label_nodes/CCLabelBMFont.cpp \ label_nodes/CCLabelTTF.cpp \ diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index b96b617be2..5fdeaa9f39 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -64,9 +64,7 @@ THE SOFTWARE. #include "platform/CCImage.h" #include "CCEGLView.h" #include "CCConfiguration.h" -#ifdef KEYBOARD_SUPPORT #include "keyboard_dispatcher/CCKeyboardDispatcher.h" -#endif /** @@ -154,10 +152,8 @@ bool Director::init(void) _touchDispatcher = new TouchDispatcher(); _touchDispatcher->init(); -#ifdef KEYBOARD_SUPPORT // KeyboardDispatcher _keyboardDispatcher = new KeyboardDispatcher(); -#endif // KeypadDispatcher _keypadDispatcher = new KeypadDispatcher(); @@ -185,9 +181,7 @@ Director::~Director(void) CC_SAFE_RELEASE(_scheduler); CC_SAFE_RELEASE(_actionManager); CC_SAFE_RELEASE(_touchDispatcher); -#ifdef KEYBOARD_SUPPORT CC_SAFE_RELEASE(_keyboardDispatcher); -#endif CC_SAFE_RELEASE(_keypadDispatcher); CC_SAFE_DELETE(_accelerometer); @@ -1004,7 +998,6 @@ TouchDispatcher* Director::getTouchDispatcher() return _touchDispatcher; } -#ifdef KEYBOARD_SUPPORT void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher) { CC_SAFE_RETAIN(pKeyboardDispatcher); @@ -1016,7 +1009,6 @@ KeyboardDispatcher* Director::getKeyboardDispatcher() { return _keyboardDispatcher; } -#endif void Director::setKeypadDispatcher(KeypadDispatcher* pKeypadDispatcher) { diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 97f14c9e34..8f44a6a862 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -71,9 +71,7 @@ class Node; class Scheduler; class ActionManager; class TouchDispatcher; -#ifdef KEYBOARD_SUPPORT class KeyboardDispatcher; -#endif class KeypadDispatcher; class Accelerometer; @@ -328,12 +326,12 @@ public: */ CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher); -#ifdef KEYBOARD_SUPPORT /** KeyboardDispatcher associated with this director - @since v?.? + @note Supported on Mac and Linux only now. + @since v3.0 */ CC_PROPERTY(KeyboardDispatcher*, _keyboardDispatcher, KeyboardDispatcher); -#endif + /** KeypadDispatcher associated with this director @since v2.0 */ diff --git a/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp b/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp index be57e9477b..fbb089d176 100644 --- a/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp +++ b/cocos2dx/keyboard_dispatcher/CCKeyboardDispatcher.cpp @@ -33,8 +33,8 @@ NS_CC_BEGIN // //------------------------------------------------------------------ KeyboardDispatcher::KeyboardDispatcher() -: _keyPressDelegate(NULL) -, _keyReleaseDelegate(NULL) +: _keyPressDelegate(nullptr) +, _keyReleaseDelegate(nullptr) { } diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index ae5d984085..37b874dd4e 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -38,9 +38,7 @@ THE SOFTWARE. #include "support/TransformUtils.h" // extern #include "kazmath/GL/matrix.h" -#ifdef KEYBOARD_SUPPORT #include "keyboard_dispatcher/CCKeyboardDispatcher.h" -#endif NS_CC_BEGIN @@ -48,9 +46,7 @@ NS_CC_BEGIN Layer::Layer() : _touchEnabled(false) , _accelerometerEnabled(false) -#ifdef KEYBOARD_SUPPORT , _keyboardEnabled(false) -#endif , _keypadEnabled(false) , _scriptTouchHandlerEntry(NULL) , _scriptKeypadHandlerEntry(NULL) @@ -279,7 +275,6 @@ void Layer::unregisterScriptAccelerateHandler(void) CC_SAFE_RELEASE_NULL(_scriptAccelerateHandlerEntry); } -#ifdef KEYBOARD_SUPPORT /// isKeyboardEnabled getter bool Layer::isKeyboardEnabled() { @@ -300,12 +295,11 @@ void Layer::setKeyboardEnabled(bool enabled) } else { - pDirector->getKeyboardDispatcher()->setKeyPressDelegate(NULL); - pDirector->getKeyboardDispatcher()->setKeyReleaseDelegate(NULL); + pDirector->getKeyboardDispatcher()->setKeyPressDelegate(nullptr); + pDirector->getKeyboardDispatcher()->setKeyReleaseDelegate(nullptr); } } } -#endif /// isKeypadEnabled getter bool Layer::isKeypadEnabled() @@ -845,7 +839,6 @@ void LayerColor::setOpacity(GLubyte opacity) // // LayerGradient // - LayerGradient* LayerGradient::create(const ccColor4B& start, const ccColor4B& end) { LayerGradient * pLayer = new LayerGradient(); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 7ca3929557..9b5a17a375 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -67,7 +67,7 @@ public: virtual ~Layer(); virtual bool init(); - /** create one layer */ + /** creates a fullscreen black layer */ static Layer *create(void); virtual void onEnter(); @@ -134,12 +134,12 @@ public: You can enable / disable accelerometer events with this property. it's new in cocos2d-x */ -#ifdef KEYBOARD_SUPPORT + virtual bool isKeyboardEnabled(); virtual void setKeyboardEnabled(bool value); virtual void keyPressed(int keyCode) {}; virtual void keyReleased(int keyCode) {}; -#endif + virtual bool isKeypadEnabled(); virtual void setKeypadEnabled(bool value); @@ -157,9 +157,7 @@ public: protected: bool _touchEnabled; bool _accelerometerEnabled; -#ifdef KEYBOARD_SUPPORT bool _keyboardEnabled; -#endif bool _keypadEnabled; private: @@ -243,7 +241,8 @@ public: virtual void draw(); virtual void setContentSize(const Size & var); - + + /** creates a fullscreen black layer */ static LayerColor* create(); /** creates a Layer with color, width and height in Points */ @@ -304,6 +303,9 @@ class CC_DLL LayerGradient : public LayerColor { public: + /** Creates a fullscreen black layer */ + static LayerGradient* create(); + /** Creates a full-screen Layer with a gradient between start and end. */ static LayerGradient* create(const ccColor4B& start, const ccColor4B& end); @@ -332,8 +334,6 @@ public: virtual void setCompressedInterpolation(bool bCompressedInterpolation); virtual bool isCompressedInterpolation(); - static LayerGradient* create(); - protected: virtual void updateColor(); }; diff --git a/cocos2dx/platform/linux/CCEGLView.cpp b/cocos2dx/platform/linux/CCEGLView.cpp index 95bbae6c82..2b9b497581 100644 --- a/cocos2dx/platform/linux/CCEGLView.cpp +++ b/cocos2dx/platform/linux/CCEGLView.cpp @@ -13,9 +13,7 @@ #include "touch_dispatcher/CCTouch.h" #include "touch_dispatcher/CCTouchDispatcher.h" #include "text_input_node/CCIMEDispatcher.h" -#ifdef KEYBOARD_SUPPORT #include "keyboard_dispatcher/CCKeyboardDispatcher.h" -#endif PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL; PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL; @@ -157,7 +155,6 @@ int closeEventHandle() { return GL_TRUE; } -#ifdef KEYBOARD_SUPPORT void GLFWCALL keyboardEventHandle(int keyCode, int action) { KeyboardDispatcher *kbDisp = Director::sharedDirector()->getKeyboardDispatcher(); @@ -172,7 +169,6 @@ void GLFWCALL keyboardEventHandle(int keyCode, int action) break; } } -#endif void EGLView::setFrameSize(float width, float height) { @@ -248,7 +244,7 @@ void EGLView::setFrameSize(float width, float height) glfwSetMouseButtonCallback(mouseButtonEventHandle); //register the glfw mouse pos event glfwSetMousePosCallback(mousePosEventHandle); -#ifdef KEYBOARD_SUPPORT +#ifdef CC_KEYBOARD_SUPPORT //register the glfw keyboard event glfwSetKeyCallback(keyboardEventHandle); #endif diff --git a/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id index f19db9f2c1..d9e6ced132 100644 --- a/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -aa069b7e15b1c1a60eb701106de33aa81dca0f77 \ No newline at end of file +a44aca2820580a568d0cb92fb573086e1096d5e1 \ No newline at end of file diff --git a/cocos2dx/proj.linux/.project b/cocos2dx/proj.linux/.project index 65b43549e7..306260a9da 100755 --- a/cocos2dx/proj.linux/.project +++ b/cocos2dx/proj.linux/.project @@ -96,6 +96,16 @@ 1 PARENT-1-PROJECT_LOC/CCConfiguration.h + + ccFPSImages.c + 1 + PARENT-1-PROJECT_LOC/ccFPSImages.c + + + ccFPSImages.h + 1 + PARENT-1-PROJECT_LOC/ccFPSImages.h + CCDirector.cpp 1 diff --git a/cocos2dx/proj.linux/cocos2dx.mk b/cocos2dx/proj.linux/cocos2dx.mk index 522d3fb0bc..bb1b98d495 100644 --- a/cocos2dx/proj.linux/cocos2dx.mk +++ b/cocos2dx/proj.linux/cocos2dx.mk @@ -11,7 +11,7 @@ CCFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC CXXFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC -std=gnu++0x ARFLAGS = cr -DEFINES += -DLINUX -DKEYBOARD_SUPPORT +DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT ifdef USE_BOX2D DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION=1 diff --git a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id index 8456e51bbc..c674431d3e 100644 --- a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -d0d80920ec6a91b8d245eb1905b39fe55135f362 \ No newline at end of file +1dc917cb6f1a62d8d7536db3c3db9f25562d59b7 \ No newline at end of file diff --git a/cocos2dx/proj.marmalade/cocos2dx.mkf b/cocos2dx/proj.marmalade/cocos2dx.mkf index 8f5a075930..c5a696ef41 100644 --- a/cocos2dx/proj.marmalade/cocos2dx.mkf +++ b/cocos2dx/proj.marmalade/cocos2dx.mkf @@ -109,6 +109,11 @@ files "*.h" "*.cpp" + ("../keyboard_dispatcher") + [keyboard_dispatcher] + "*.h" + "*.cpp" + ("../label_nodes") [label_nodes] "*.h" diff --git a/cocos2dx/proj.nacl/Makefile b/cocos2dx/proj.nacl/Makefile index cbc82320d0..1bf672f7e1 100644 --- a/cocos2dx/proj.nacl/Makefile +++ b/cocos2dx/proj.nacl/Makefile @@ -37,6 +37,7 @@ SOURCES = ../actions/CCAction.cpp \ ../effects/CCGrid.cpp \ ../keypad_dispatcher/CCKeypadDelegate.cpp \ ../keypad_dispatcher/CCKeypadDispatcher.cpp \ +../keyboard_dispatcher/CCKeyboardDispatcher.cpp \ ../label_nodes/CCLabelAtlas.cpp \ ../label_nodes/CCLabelBMFont.cpp \ ../label_nodes/CCLabelTTF.cpp \ diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj index 4bb0ee12e0..887f002440 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj +++ b/cocos2dx/proj.win32/cocos2d.vcxproj @@ -172,6 +172,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir + @@ -313,6 +314,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir + diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj.filters b/cocos2dx/proj.win32/cocos2d.vcxproj.filters index c08ef80f32..ee7e91e62e 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj.filters +++ b/cocos2dx/proj.win32/cocos2d.vcxproj.filters @@ -1,971 +1,977 @@ - - - - - {cc64f5ad-2234-494c-9c51-b7a20c8887aa} - - - {aec8225f-81a7-4213-b97b-7004d5535398} - - - {736cf4ab-e0d6-40ba-912a-b062d28d318a} - - - {1c7c61b8-3d36-4ba0-a87c-457eb4c782d0} - - - {0b3a64bd-79fa-476a-a461-6b97e5072453} - - - {e455af5e-da09-4f41-b79f-df4dd311820d} - - - {206bd96b-f80e-4722-8675-d7c6ff9b3639} - - - {075492ba-08bc-404c-92da-32029797a600} - - - {41abe422-1602-4fe0-ac1c-6b04a14c1abb} - - - {8bf0f517-2ac3-4fc3-a1ad-999d9ea103cd} - - - {926fc31c-8742-4984-9940-c972dd02fc8a} - - - {9428f8e6-4ce3-4596-b8af-14d70b7c5b5d} - - - {755e5282-111e-46a5-9169-7c12b37f5ffc} - - - {d94bbf20-8de9-49a7-ae20-6a1140cf633b} - - - {4a64789e-cc8d-4f84-a869-e6dae2e0d58c} - - - {bb98a889-9a48-4e31-af2f-117f14da388a} - - - {fdea327e-b905-47db-8c33-b70d7866166b} - - - {46c8d130-b8b5-47f5-a063-ca700e1c32cc} - - - {f2671200-b2d8-4d2e-9728-06719cf6f835} - - - {eaa16c9b-dfbc-4a37-8e3e-e961d9ca1d1a} - - - {3c91932f-7667-4049-b9bd-caac4c8eab15} - - - {535c04b0-fe2b-44c9-9a8c-9029e2b6de5c} - - - {5b082c5c-d396-43ca-b3b1-997d0f6247d0} - - - {7751500e-ac9e-4604-a96d-670b30b7d8bd} - - - {b38113b1-3d59-4f6e-ac5a-f43921f6ed09} - - - {569c49c9-27eb-456e-a3f4-9f403e28a3a1} - - - {191b3e94-47dc-4054-b1cb-bf145d281521} - - - {a91a4cc0-41e6-43e9-80c0-2c9101924386} - - - {e278b354-1e41-4e92-95b3-7f661ba67140} - - - {163895ae-8a8e-46bf-bdf2-98bb2c1347fc} - - - {1179d205-d065-49f0-8457-bc4c3f1d0cb3} - - - {cc25bb83-527d-4218-8d68-ebf963ce7698} - - - {c45b97e8-fa1f-4e58-8ec5-d46371c2dd26} - - - {caa78ce0-9b58-4314-b117-1acae278691e} - - - {5e6e45aa-50ef-451b-9bb1-f98b9b78259b} - - - - - base_nodes - - - base_nodes - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - effects - - - effects - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - label_nodes - - - label_nodes - - - label_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - menu_nodes - - - menu_nodes - - - misc_nodes - - - misc_nodes - - - misc_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - platform - - - platform - - - platform - - - platform - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - support - - - support - - - support - - - support - - - support - - - support - - - support - - - support\data_support - - - support\image_support - - - support\zip_support - - - support\zip_support - - - support\zip_support - - - textures - - - textures - - - textures - - - textures - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - touch_dispatcher - - - touch_dispatcher - - - touch_dispatcher - - - keypad_dispatcher - - - keypad_dispatcher - - - text_input_node - - - text_input_node - - - script_support - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src - - - kazmath\src\GL - - - kazmath\src\GL - - - - - - - - draw_nodes - - - draw_nodes - - - misc_nodes - - - shaders - - - shaders - - - shaders - - - shaders - - - platform\win32 - - - platform - - - platform - - - platform\win32 - - - support - - - support\user_default - - - support\tinyxml2 - - - cocoa - - - - textures - - - support\component - - - support\component - - - textures\etc - - - - - base_nodes - - - base_nodes - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - effects - - - effects - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - actions - - - include - - - include - - - include - - - include - - - include - - - include - - - label_nodes - - - label_nodes - - - label_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - layers_scenes_transitions_nodes - - - menu_nodes - - - menu_nodes - - - misc_nodes - - - misc_nodes - - - misc_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - particle_nodes - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - platform\win32 - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - sprite_nodes - - - support - - - support - - - support - - - support - - - support - - - support - - - support - - - support\data_support - - - support\data_support - - - support\data_support - - - support\image_support - - - support\zip_support - - - support\zip_support - - - support\zip_support - - - textures - - - textures - - - textures - - - textures - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - tilemap_parallax_nodes - - - touch_dispatcher - - - touch_dispatcher - - - touch_dispatcher - - - touch_dispatcher - - - keypad_dispatcher - - - keypad_dispatcher - - - text_input_node - - - text_input_node - - - text_input_node - - - script_support - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath - - - kazmath\include\kazmath\GL - - - kazmath\include\kazmath\GL - - - - - - - draw_nodes - - - draw_nodes - - - misc_nodes - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - platform\win32 - - - support - - - support\user_default - - - support\tinyxml2 - - - cocoa - - - cocoa - - - cocoa - - - cocoa - - - textures - - - - support\component - - - support\component - - - textures\etc - - + + + + + {cc64f5ad-2234-494c-9c51-b7a20c8887aa} + + + {aec8225f-81a7-4213-b97b-7004d5535398} + + + {736cf4ab-e0d6-40ba-912a-b062d28d318a} + + + {1c7c61b8-3d36-4ba0-a87c-457eb4c782d0} + + + {0b3a64bd-79fa-476a-a461-6b97e5072453} + + + {e455af5e-da09-4f41-b79f-df4dd311820d} + + + {206bd96b-f80e-4722-8675-d7c6ff9b3639} + + + {075492ba-08bc-404c-92da-32029797a600} + + + {41abe422-1602-4fe0-ac1c-6b04a14c1abb} + + + {8bf0f517-2ac3-4fc3-a1ad-999d9ea103cd} + + + {926fc31c-8742-4984-9940-c972dd02fc8a} + + + {9428f8e6-4ce3-4596-b8af-14d70b7c5b5d} + + + {755e5282-111e-46a5-9169-7c12b37f5ffc} + + + {d94bbf20-8de9-49a7-ae20-6a1140cf633b} + + + {4a64789e-cc8d-4f84-a869-e6dae2e0d58c} + + + {bb98a889-9a48-4e31-af2f-117f14da388a} + + + {fdea327e-b905-47db-8c33-b70d7866166b} + + + {46c8d130-b8b5-47f5-a063-ca700e1c32cc} + + + {f2671200-b2d8-4d2e-9728-06719cf6f835} + + + {eaa16c9b-dfbc-4a37-8e3e-e961d9ca1d1a} + + + {3c91932f-7667-4049-b9bd-caac4c8eab15} + + + {535c04b0-fe2b-44c9-9a8c-9029e2b6de5c} + + + {5b082c5c-d396-43ca-b3b1-997d0f6247d0} + + + {7751500e-ac9e-4604-a96d-670b30b7d8bd} + + + {b38113b1-3d59-4f6e-ac5a-f43921f6ed09} + + + {569c49c9-27eb-456e-a3f4-9f403e28a3a1} + + + {191b3e94-47dc-4054-b1cb-bf145d281521} + + + {a91a4cc0-41e6-43e9-80c0-2c9101924386} + + + {e278b354-1e41-4e92-95b3-7f661ba67140} + + + {163895ae-8a8e-46bf-bdf2-98bb2c1347fc} + + + {1179d205-d065-49f0-8457-bc4c3f1d0cb3} + + + {cc25bb83-527d-4218-8d68-ebf963ce7698} + + + {c45b97e8-fa1f-4e58-8ec5-d46371c2dd26} + + + {caa78ce0-9b58-4314-b117-1acae278691e} + + + {5e6e45aa-50ef-451b-9bb1-f98b9b78259b} + + {e7134ba0-4220-4dd1-b120-3533883394ac} + + + + + base_nodes + + + base_nodes + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + effects + + + effects + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + label_nodes + + + label_nodes + + + label_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + menu_nodes + + + menu_nodes + + + misc_nodes + + + misc_nodes + + + misc_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + platform + + + platform + + + platform + + + platform + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + support + + + support + + + support + + + support + + + support + + + support + + + support + + + support\data_support + + + support\image_support + + + support\zip_support + + + support\zip_support + + + support\zip_support + + + textures + + + textures + + + textures + + + textures + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + touch_dispatcher + + + touch_dispatcher + + + touch_dispatcher + + + keypad_dispatcher + + + keypad_dispatcher + + + text_input_node + + + text_input_node + + + script_support + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src + + + kazmath\src\GL + + + kazmath\src\GL + + + + + + + + draw_nodes + + + draw_nodes + + + misc_nodes + + + shaders + + + shaders + + + shaders + + + shaders + + + platform\win32 + + + platform + + + platform + + + platform\win32 + + + support + + + support\user_default + + + support\tinyxml2 + + + cocoa + + + + textures + + + support\component + + + support\component + + + textures\etc + + keyboard_dispatcher + + + + + base_nodes + + + base_nodes + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + effects + + + effects + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + actions + + + include + + + include + + + include + + + include + + + include + + + include + + + label_nodes + + + label_nodes + + + label_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + layers_scenes_transitions_nodes + + + menu_nodes + + + menu_nodes + + + misc_nodes + + + misc_nodes + + + misc_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + particle_nodes + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + platform\win32 + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + sprite_nodes + + + support + + + support + + + support + + + support + + + support + + + support + + + support + + + support\data_support + + + support\data_support + + + support\data_support + + + support\image_support + + + support\zip_support + + + support\zip_support + + + support\zip_support + + + textures + + + textures + + + textures + + + textures + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + tilemap_parallax_nodes + + + touch_dispatcher + + + touch_dispatcher + + + touch_dispatcher + + + touch_dispatcher + + + keypad_dispatcher + + + keypad_dispatcher + + + text_input_node + + + text_input_node + + + text_input_node + + + script_support + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath + + + kazmath\include\kazmath\GL + + + kazmath\include\kazmath\GL + + + + + + + draw_nodes + + + draw_nodes + + + misc_nodes + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + shaders + + + platform\win32 + + + support + + + support\user_default + + + support\tinyxml2 + + + cocoa + + + cocoa + + + cocoa + + + cocoa + + + textures + + + + support\component + + + support\component + + + textures\etc + + keyboard_dispatcher + + \ No newline at end of file diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index a2a0591eb5..c5494df2ca 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -516,7 +516,7 @@ bool Texture2D::initWithString(const char *text, ccFontDefinition *textDefinitio #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data - VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize); + VolatileTexture::addStringTexture(this, text, textDefinition->_dimensions, textDefinition->_alignment, textDefinition->_vertAlignment, textDefinition->_fontName.c_str(), textDefinition->_fontSize); #endif bool bRet = false; diff --git a/extensions/physics_nodes/CCPhysicsSprite.cpp b/extensions/physics_nodes/CCPhysicsSprite.cpp index c9a8193273..feba6a3f57 100644 --- a/extensions/physics_nodes/CCPhysicsSprite.cpp +++ b/extensions/physics_nodes/CCPhysicsSprite.cpp @@ -23,6 +23,10 @@ #include "CCPhysicsSprite.h" #include "support/CCPointExtension.h" +#if defined(CC_ENABLE_CHIPMUNK_INTEGRATION) && defined(CC_ENABLE_BOX2D_INTEGRATION) +#error "Either Chipmunk or Box2d should be enabled, but not both at the same time" +#endif + #if CC_ENABLE_CHIPMUNK_INTEGRATION #include "chipmunk.h" #elif CC_ENABLE_BOX2D_INTEGRATION @@ -33,12 +37,9 @@ NS_CC_EXT_BEGIN PhysicsSprite::PhysicsSprite() : _ignoreBodyRotation(false) -#if CC_ENABLE_CHIPMUNK_INTEGRATION , _CPBody(NULL) -#elif CC_ENABLE_BOX2D_INTEGRATION , _pB2Body(NULL) , _PTMRatio(0.0f) -#endif {} PhysicsSprite* PhysicsSprite::create() @@ -189,6 +190,10 @@ float PhysicsSprite::getPositionY() return _position.y; } +// +// Chipmunk only +// + #if CC_ENABLE_CHIPMUNK_INTEGRATION cpBody* PhysicsSprite::getCPBody() const @@ -201,56 +206,31 @@ void PhysicsSprite::setCPBody(cpBody *pBody) _CPBody = pBody; } -void PhysicsSprite::updatePosFromPhysics() +b2Body* PhysicsSprite::getB2Body() const { - cpVect cpPos = cpBodyGetPos(_CPBody); - _position = ccp(cpPos.x, cpPos.y); + CCAssert(false, "Can't call box2d methods when Chipmunk is enabled"); + return NULL; } -void PhysicsSprite::setPosition(const Point &pos) +void PhysicsSprite::setB2Body(b2Body *pBody) { - cpVect cpPos = cpv(pos.x, pos.y); - cpBodySetPos(_CPBody, cpPos); + CCAssert(false, "Can't call box2d methods when Chipmunk is enabled"); } -float PhysicsSprite::getRotation() +float PhysicsSprite::getPTMRatio() const { - return (_ignoreBodyRotation ? Sprite::getRotation() : -CC_RADIANS_TO_DEGREES(cpBodyGetAngle(_CPBody))); + CCAssert(false, "Can't call box2d methods when Chipmunk is enabled"); + return 0; } -void PhysicsSprite::setRotation(float fRotation) +void PhysicsSprite::setPTMRatio(float fRatio) { - if (_ignoreBodyRotation) - { - Sprite::setRotation(fRotation); - } - else - { - cpBodySetAngle(_CPBody, -CC_DEGREES_TO_RADIANS(fRotation)); - } -} - -// returns the transform matrix according the Chipmunk Body values -AffineTransform PhysicsSprite::nodeToParentTransform() -{ - // Although scale is not used by physics engines, it is calculated just in case - // the sprite is animated (scaled up/down) using actions. - // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990 - cpVect rot = (_ignoreBodyRotation ? cpvforangle(-CC_DEGREES_TO_RADIANS(_rotationX)) : _CPBody->rot); - float x = _CPBody->p.x + rot.x * -_anchorPointInPoints.x * _scaleX - rot.y * -_anchorPointInPoints.y * _scaleY; - float y = _CPBody->p.y + rot.y * -_anchorPointInPoints.x * _scaleX + rot.x * -_anchorPointInPoints.y * _scaleY; - - if (_ignoreAnchorPointForPosition) - { - x += _anchorPointInPoints.x; - y += _anchorPointInPoints.y; - } - - return (_transform = AffineTransformMake(rot.x * _scaleX, rot.y * _scaleX, - -rot.y * _scaleY, rot.x * _scaleY, - x, y)); + CCAssert(false, "Can't call box2d methods when Chipmunk is enabled"); } +// +// Box2d only +// #elif CC_ENABLE_BOX2D_INTEGRATION b2Body* PhysicsSprite::getB2Body() const @@ -273,25 +253,68 @@ void PhysicsSprite::setPTMRatio(float fRatio) _PTMRatio = fRatio; } -// Override the setters and getters to always reflect the body's properties. +cpBody* PhysicsSprite::getCPBody() const +{ + CCAssert(false, "Can't call Chipmunk methods when Box2d is enabled"); + return NULL; +} + +void PhysicsSprite::setCPBody(cpBody *pBody) +{ + CCAssert(false, "Can't call Chipmunk methods when Box2d is enabled"); +} + +#endif + +// +// Common to Box2d and Chipmunk +// + void PhysicsSprite::updatePosFromPhysics() { + +#if CC_ENABLE_CHIPMUNK_INTEGRATION + + cpVect cpPos = cpBodyGetPos(_CPBody); + _position = ccp(cpPos.x, cpPos.y); + +#elif CC_ENABLE_BOX2D_INTEGRATION + b2Vec2 pos = _pB2Body->GetPosition(); float x = pos.x * _PTMRatio; float y = pos.y * _PTMRatio; _position = ccp(x,y); +#endif + } void PhysicsSprite::setPosition(const Point &pos) { +#if CC_ENABLE_CHIPMUNK_INTEGRATION + + cpVect cpPos = cpv(pos.x, pos.y); + cpBodySetPos(_CPBody, cpPos); + +#elif CC_ENABLE_BOX2D_INTEGRATION + float angle = _pB2Body->GetAngle(); _pB2Body->SetTransform(b2Vec2(pos.x / _PTMRatio, pos.y / _PTMRatio), angle); +#endif + } float PhysicsSprite::getRotation() { +#if CC_ENABLE_CHIPMUNK_INTEGRATION + + return (_ignoreBodyRotation ? Sprite::getRotation() : -CC_RADIANS_TO_DEGREES(cpBodyGetAngle(_CPBody))); + +#elif CC_ENABLE_BOX2D_INTEGRATION + return (_ignoreBodyRotation ? Sprite::getRotation() : CC_RADIANS_TO_DEGREES(_pB2Body->GetAngle())); +#endif + } void PhysicsSprite::setRotation(float fRotation) @@ -300,50 +323,79 @@ void PhysicsSprite::setRotation(float fRotation) { Sprite::setRotation(fRotation); } + +#if CC_ENABLE_CHIPMUNK_INTEGRATION + else + { + cpBodySetAngle(_CPBody, -CC_DEGREES_TO_RADIANS(fRotation)); + } + +#elif CC_ENABLE_BOX2D_INTEGRATION else { b2Vec2 p = _pB2Body->GetPosition(); float radians = CC_DEGREES_TO_RADIANS(fRotation); _pB2Body->SetTransform(p, radians); } +#endif + } -// returns the transform matrix according the Box2D Body values +// returns the transform matrix according the Chipmunk Body values AffineTransform PhysicsSprite::nodeToParentTransform() { - b2Vec2 pos = _pB2Body->GetPosition(); - - float x = pos.x * _PTMRatio; - float y = pos.y * _PTMRatio; - + // Although scale is not used by physics engines, it is calculated just in case + // the sprite is animated (scaled up/down) using actions. + // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990 + +#if CC_ENABLE_CHIPMUNK_INTEGRATION + + cpVect rot = (_ignoreBodyRotation ? cpvforangle(-CC_DEGREES_TO_RADIANS(_rotationX)) : _CPBody->rot); + float x = _CPBody->p.x + rot.x * -_anchorPointInPoints.x * _scaleX - rot.y * -_anchorPointInPoints.y * _scaleY; + float y = _CPBody->p.y + rot.y * -_anchorPointInPoints.x * _scaleX + rot.x * -_anchorPointInPoints.y * _scaleY; + if (_ignoreAnchorPointForPosition) { x += _anchorPointInPoints.x; y += _anchorPointInPoints.y; } - + + return (_transform = AffineTransformMake(rot.x * _scaleX, rot.y * _scaleX, + -rot.y * _scaleY, rot.x * _scaleY, + x, y)); + + +#elif CC_ENABLE_BOX2D_INTEGRATION + + b2Vec2 pos = _pB2Body->GetPosition(); + + float x = pos.x * _PTMRatio; + float y = pos.y * _PTMRatio; + + if (_ignoreAnchorPointForPosition) + { + x += _anchorPointInPoints.x; + y += _anchorPointInPoints.y; + } + // Make matrix float radians = _pB2Body->GetAngle(); float c = cosf(radians); float s = sinf(radians); - - // Although scale is not used by physics engines, it is calculated just in case - // the sprite is animated (scaled up/down) using actions. - // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990 + if (!_anchorPointInPoints.equals(PointZero)) { x += ((c * -_anchorPointInPoints.x * _scaleX) + (-s * -_anchorPointInPoints.y * _scaleY)); y += ((s * -_anchorPointInPoints.x * _scaleX) + (c * -_anchorPointInPoints.y * _scaleY)); } - + // Rot, Translate Matrix _transform = AffineTransformMake( c * _scaleX, s * _scaleX, - -s * _scaleY, c * _scaleY, - x, y ); - + -s * _scaleY, c * _scaleY, + x, y ); + return _transform; +#endif } -#endif - NS_CC_EXT_END diff --git a/extensions/physics_nodes/CCPhysicsSprite.h b/extensions/physics_nodes/CCPhysicsSprite.h index da11ce90ef..1d11738a20 100644 --- a/extensions/physics_nodes/CCPhysicsSprite.h +++ b/extensions/physics_nodes/CCPhysicsSprite.h @@ -25,13 +25,8 @@ #include "cocos2d.h" #include "ExtensionMacros.h" -#if CC_ENABLE_CHIPMUNK_INTEGRATION -#include "chipmunk.h" -#elif CC_ENABLE_BOX2D_INTEGRATION +struct cpBody; class b2Body; -#else // CC_ENABLE_BOX2D_INTEGRATION -#error "You must define either CC_ENABLE_CHIPMUNK_INTEGRATION or CC_ENABLE_BOX2D_INTEGRATION to use PhysicsSprite.h" -#endif NS_CC_EXT_BEGIN /** A Sprite subclass that is bound to a physics body. @@ -50,15 +45,15 @@ class PhysicsSprite : public Sprite { protected: bool _ignoreBodyRotation; -#if CC_ENABLE_CHIPMUNK_INTEGRATION + + + // chipmunk specific cpBody *_CPBody; -#elif CC_ENABLE_BOX2D_INTEGRATION + // box2d specific b2Body *_pB2Body; - - // Pixels to Meters ratio float _PTMRatio; -#endif // CC_ENABLE_CHIPMUNK_INTEGRATION + public: PhysicsSprite(); @@ -110,18 +105,22 @@ public: virtual void setRotation(float fRotation); virtual AffineTransform nodeToParentTransform(); -#if CC_ENABLE_CHIPMUNK_INTEGRATION + // + // Chipmunk specific + // /** Body accessor when using regular Chipmunk */ cpBody* getCPBody() const; void setCPBody(cpBody *pBody); -#elif CC_ENABLE_BOX2D_INTEGRATION + + // + // Box2d specific + // /** Body accessor when using box2d */ b2Body* getB2Body() const; void setB2Body(b2Body *pBody); float getPTMRatio() const; void setPTMRatio(float fPTMRatio); -#endif // CC_ENABLE_BOX2D_INTEGRATION protected: void updatePosFromPhysics(); diff --git a/extensions/proj.linux/.cproject b/extensions/proj.linux/.cproject index a4aac1c02c..9918728542 100644 --- a/extensions/proj.linux/.cproject +++ b/extensions/proj.linux/.cproject @@ -40,6 +40,7 @@ + @@ -66,6 +67,7 @@ + @@ -133,6 +135,7 @@ + @@ -159,6 +162,7 @@ + @@ -218,6 +222,7 @@ + @@ -244,6 +249,7 @@ + @@ -312,6 +318,7 @@ + @@ -338,6 +345,7 @@ + diff --git a/extensions/proj.mac/extensions.xcodeproj/project.pbxproj b/extensions/proj.mac/extensions.xcodeproj/project.pbxproj index 3ec88e06a2..bdee787e8f 100644 --- a/extensions/proj.mac/extensions.xcodeproj/project.pbxproj +++ b/extensions/proj.mac/extensions.xcodeproj/project.pbxproj @@ -112,6 +112,8 @@ 1A0C0D4F1777F9CD00838530 /* Slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE31777F9CD00838530 /* Slot.cpp */; }; 1A0C0D501777F9CD00838530 /* SlotData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE51777F9CD00838530 /* SlotData.cpp */; }; 1A0C0D511777F9CD00838530 /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE71777F9CD00838530 /* spine-cocos2dx.cpp */; }; + A05FCAE8177C1A1400BE600E /* libwebsockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAE7177C1A1400BE600E /* libwebsockets.a */; }; + A05FCAEA177C1F8E00BE600E /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAE9177C1F8E00BE600E /* libcurl.dylib */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -361,9 +363,9 @@ 1A0C0CE71777F9CD00838530 /* spine-cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "spine-cocos2dx.cpp"; sourceTree = ""; }; 1A0C0CE81777F9CD00838530 /* spine-cocos2dx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "spine-cocos2dx.h"; sourceTree = ""; }; 1A0C0CE91777F9CD00838530 /* spine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spine.h; sourceTree = ""; }; - 1A0C0D551777FAAD00838530 /* libwebsockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libwebsockets.h; sourceTree = ""; }; - 1A0C0D571777FAAD00838530 /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebsockets.a; sourceTree = ""; }; - 1A0C0D591777FB1300838530 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; + A05FCAE5177C1A1400BE600E /* libwebsockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libwebsockets.h; sourceTree = ""; }; + A05FCAE7177C1A1400BE600E /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebsockets.a; sourceTree = ""; }; + A05FCAE9177C1F8E00BE600E /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -371,7 +373,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + A05FCAEA177C1F8E00BE600E /* libcurl.dylib in Frameworks */, 1A0C0A7E1777F79700838530 /* Foundation.framework in Frameworks */, + A05FCAE8177C1A1400BE600E /* libwebsockets.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -409,8 +413,8 @@ 1A0C0A7C1777F79700838530 /* Frameworks */ = { isa = PBXGroup; children = ( - 1A0C0D591777FB1300838530 /* libcurl.a */, - 1A0C0D521777FAAD00838530 /* libwebsockets */, + A05FCAE9177C1F8E00BE600E /* libcurl.dylib */, + A05FCAE3177C1A1400BE600E /* libwebsockets */, 1A0C0A7D1777F79700838530 /* Foundation.framework */, ); name = Frameworks; @@ -805,36 +809,28 @@ path = ../spine; sourceTree = ""; }; - 1A0C0D521777FAAD00838530 /* libwebsockets */ = { + A05FCAE3177C1A1400BE600E /* libwebsockets */ = { isa = PBXGroup; children = ( - 1A0C0D531777FAAD00838530 /* ios */, + A05FCAE4177C1A1400BE600E /* include */, + A05FCAE6177C1A1400BE600E /* lib */, ); name = libwebsockets; - path = ../../external/libwebsockets; + path = ../../external/libwebsockets/mac; sourceTree = ""; }; - 1A0C0D531777FAAD00838530 /* ios */ = { + A05FCAE4177C1A1400BE600E /* include */ = { isa = PBXGroup; children = ( - 1A0C0D541777FAAD00838530 /* include */, - 1A0C0D561777FAAD00838530 /* lib */, - ); - path = ios; - sourceTree = ""; - }; - 1A0C0D541777FAAD00838530 /* include */ = { - isa = PBXGroup; - children = ( - 1A0C0D551777FAAD00838530 /* libwebsockets.h */, + A05FCAE5177C1A1400BE600E /* libwebsockets.h */, ); path = include; sourceTree = ""; }; - 1A0C0D561777FAAD00838530 /* lib */ = { + A05FCAE6177C1A1400BE600E /* lib */ = { isa = PBXGroup; children = ( - 1A0C0D571777FAAD00838530 /* libwebsockets.a */, + A05FCAE7177C1A1400BE600E /* libwebsockets.a */, ); path = lib; sourceTree = ""; @@ -1017,7 +1013,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", - "$(inherited)", + CC_KEYBOARD_SUPPORT, CC_TARGET_OS_MAC, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; @@ -1046,6 +1042,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( NDEBUG, CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, ); GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; diff --git a/external/libwebsockets/mac/include/libwebsockets.h b/external/libwebsockets/mac/include/libwebsockets.h new file mode 100644 index 0000000000..65bae14534 --- /dev/null +++ b/external/libwebsockets/mac/include/libwebsockets.h @@ -0,0 +1,993 @@ +/* + * libwebsockets - small server side websockets and web server implementation + * + * Copyright (C) 2010-2013 Andy Green + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation: + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __LIBWEBSOCKET_H__ +#define __LIBWEBSOCKET_H__ + +#ifdef __cplusplus +extern "C" { +#include +#endif + +#ifdef WIN32 + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include "../win32port/win32helpers/websock-w32.h" + +#include "../win32port/win32helpers/gettimeofday.h" + +#define strcasecmp stricmp +#define getdtablesize() 30000 + +typedef int ssize_t; + +#define LWS_VISIBLE + +#ifdef LWS_DLL +#ifdef LWS_INTERNAL +#define LWS_EXTERN extern __declspec(dllexport) +#else +#define LWS_EXTERN extern __declspec(dllimport) +#endif +#else +#define LWS_EXTERN +#endif + +#else // NOT WIN32 +#include +#include + +#if defined(__GNUC__) +#define LWS_VISIBLE __attribute__((visibility("default"))) +#else +#define LWS_VISIBLE +#endif + +#endif + +#include + +#ifndef LWS_EXTERN +#define LWS_EXTERN extern +#endif + +#define CONTEXT_PORT_NO_LISTEN 0 +#define MAX_MUX_RECURSION 2 + +enum lws_log_levels { + LLL_ERR = 1 << 0, + LLL_WARN = 1 << 1, + LLL_NOTICE = 1 << 2, + LLL_INFO = 1 << 3, + LLL_DEBUG = 1 << 4, + LLL_PARSER = 1 << 5, + LLL_HEADER = 1 << 6, + LLL_EXT = 1 << 7, + LLL_CLIENT = 1 << 8, + LLL_LATENCY = 1 << 9, + + LLL_COUNT = 10 /* set to count of valid flags */ +}; + +LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...); + +/* notice, warn and log are always compiled in */ +#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__) +#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__) +#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__) +/* + * weaker logging can be deselected at configure time using --disable-debug + * that gets rid of the overhead of checking while keeping _warn and _err + * active + */ +#ifdef _DEBUG + +#define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__) +#define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__) +#define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__) +#define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__) +#define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__) +#define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__) +#define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__) +LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len); + +#else /* no debug */ + +#define lwsl_info(...) +#define lwsl_debug(...) +#define lwsl_parser(...) +#define lwsl_header(...) +#define lwsl_ext(...) +#define lwsl_client(...) +#define lwsl_latency(...) +#define lwsl_hexdump(a, b) + +#endif + +enum libwebsocket_context_options { + LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2, + LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME = 4, +}; + +enum libwebsocket_callback_reasons { + LWS_CALLBACK_ESTABLISHED, + LWS_CALLBACK_CLIENT_CONNECTION_ERROR, + LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH, + LWS_CALLBACK_CLIENT_ESTABLISHED, + LWS_CALLBACK_CLOSED, + LWS_CALLBACK_RECEIVE, + LWS_CALLBACK_CLIENT_RECEIVE, + LWS_CALLBACK_CLIENT_RECEIVE_PONG, + LWS_CALLBACK_CLIENT_WRITEABLE, + LWS_CALLBACK_SERVER_WRITEABLE, + LWS_CALLBACK_HTTP, + LWS_CALLBACK_HTTP_FILE_COMPLETION, + LWS_CALLBACK_HTTP_WRITEABLE, + LWS_CALLBACK_FILTER_NETWORK_CONNECTION, + LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION, + LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS, + LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS, + LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION, + LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, + LWS_CALLBACK_CONFIRM_EXTENSION_OKAY, + LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED, + LWS_CALLBACK_PROTOCOL_INIT, + LWS_CALLBACK_PROTOCOL_DESTROY, + /* external poll() management support */ + LWS_CALLBACK_ADD_POLL_FD, + LWS_CALLBACK_DEL_POLL_FD, + LWS_CALLBACK_SET_MODE_POLL_FD, + LWS_CALLBACK_CLEAR_MODE_POLL_FD, +}; + +#ifndef LWS_NO_EXTENSIONS +enum libwebsocket_extension_callback_reasons { + LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT, + LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT, + LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT, + LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT, + LWS_EXT_CALLBACK_CONSTRUCT, + LWS_EXT_CALLBACK_CLIENT_CONSTRUCT, + LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE, + LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION, + LWS_EXT_CALLBACK_DESTROY, + LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING, + LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED, + LWS_EXT_CALLBACK_PACKET_RX_PREPARSE, + LWS_EXT_CALLBACK_PACKET_TX_PRESEND, + LWS_EXT_CALLBACK_PACKET_TX_DO_SEND, + LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX, + LWS_EXT_CALLBACK_FLUSH_PENDING_TX, + LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX, + LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION, + LWS_EXT_CALLBACK_1HZ, + LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE, + LWS_EXT_CALLBACK_IS_WRITEABLE, + LWS_EXT_CALLBACK_PAYLOAD_TX, + LWS_EXT_CALLBACK_PAYLOAD_RX, +}; +#endif + +enum libwebsocket_write_protocol { + LWS_WRITE_TEXT, + LWS_WRITE_BINARY, + LWS_WRITE_CONTINUATION, + LWS_WRITE_HTTP, + + /* special 04+ opcodes */ + + LWS_WRITE_CLOSE, + LWS_WRITE_PING, + LWS_WRITE_PONG, + + /* flags */ + + LWS_WRITE_NO_FIN = 0x40, + /* + * client packet payload goes out on wire unmunged + * only useful for security tests since normal servers cannot + * decode the content if used + */ + LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80 +}; + +/* + * you need these to look at headers that have been parsed if using the + * LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum + * list below is absent, .token = NULL and token_len = 0. Otherwise .token + * points to .token_len chars containing that header content. + */ + +struct lws_tokens { + char *token; + int token_len; +}; + +enum lws_token_indexes { + WSI_TOKEN_GET_URI, + WSI_TOKEN_HOST, + WSI_TOKEN_CONNECTION, + WSI_TOKEN_KEY1, + WSI_TOKEN_KEY2, + WSI_TOKEN_PROTOCOL, + WSI_TOKEN_UPGRADE, + WSI_TOKEN_ORIGIN, + WSI_TOKEN_DRAFT, + WSI_TOKEN_CHALLENGE, + + /* new for 04 */ + WSI_TOKEN_KEY, + WSI_TOKEN_VERSION, + WSI_TOKEN_SWORIGIN, + + /* new for 05 */ + WSI_TOKEN_EXTENSIONS, + + /* client receives these */ + WSI_TOKEN_ACCEPT, + WSI_TOKEN_NONCE, + WSI_TOKEN_HTTP, + WSI_TOKEN_MUXURL, + + /* use token storage to stash these */ + + _WSI_TOKEN_CLIENT_SENT_PROTOCOLS, + _WSI_TOKEN_CLIENT_PEER_ADDRESS, + _WSI_TOKEN_CLIENT_URI, + _WSI_TOKEN_CLIENT_HOST, + _WSI_TOKEN_CLIENT_ORIGIN, + + /* always last real token index*/ + WSI_TOKEN_COUNT, + /* parser state additions */ + WSI_TOKEN_NAME_PART, + WSI_TOKEN_SKIPPING, + WSI_TOKEN_SKIPPING_SAW_CR, + WSI_PARSING_COMPLETE, + WSI_INIT_TOKEN_MUXURL, +}; + +/* + * From RFC 6455 + 1000 + + 1000 indicates a normal closure, meaning that the purpose for + which the connection was established has been fulfilled. + + 1001 + + 1001 indicates that an endpoint is "going away", such as a server + going down or a browser having navigated away from a page. + + 1002 + + 1002 indicates that an endpoint is terminating the connection due + to a protocol error. + + 1003 + + 1003 indicates that an endpoint is terminating the connection + because it has received a type of data it cannot accept (e.g., an + endpoint that understands only text data MAY send this if it + receives a binary message). + + 1004 + + Reserved. The specific meaning might be defined in the future. + + 1005 + + 1005 is a reserved value and MUST NOT be set as a status code in a + Close control frame by an endpoint. It is designated for use in + applications expecting a status code to indicate that no status + code was actually present. + + 1006 + + 1006 is a reserved value and MUST NOT be set as a status code in a + Close control frame by an endpoint. It is designated for use in + applications expecting a status code to indicate that the + connection was closed abnormally, e.g., without sending or + receiving a Close control frame. + + 1007 + + 1007 indicates that an endpoint is terminating the connection + because it has received data within a message that was not + consistent with the type of the message (e.g., non-UTF-8 [RFC3629] + data within a text message). + + 1008 + + 1008 indicates that an endpoint is terminating the connection + because it has received a message that violates its policy. This + is a generic status code that can be returned when there is no + other more suitable status code (e.g., 1003 or 1009) or if there + is a need to hide specific details about the policy. + + 1009 + + 1009 indicates that an endpoint is terminating the connection + because it has received a message that is too big for it to + process. + + 1010 + + 1010 indicates that an endpoint (client) is terminating the + connection because it has expected the server to negotiate one or + more extension, but the server didn't return them in the response + message of the WebSocket handshake. The list of extensions that + are needed SHOULD appear in the /reason/ part of the Close frame. + Note that this status code is not used by the server, because it + can fail the WebSocket handshake instead. + + 1011 + + 1011 indicates that a server is terminating the connection because + it encountered an unexpected condition that prevented it from + fulfilling the request. + + 1015 + + 1015 is a reserved value and MUST NOT be set as a status code in a + Close control frame by an endpoint. It is designated for use in + applications expecting a status code to indicate that the + connection was closed due to a failure to perform a TLS handshake + (e.g., the server certificate can't be verified). +*/ + +enum lws_close_status { + LWS_CLOSE_STATUS_NOSTATUS = 0, + LWS_CLOSE_STATUS_NORMAL = 1000, + LWS_CLOSE_STATUS_GOINGAWAY = 1001, + LWS_CLOSE_STATUS_PROTOCOL_ERR = 1002, + LWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE = 1003, + LWS_CLOSE_STATUS_RESERVED = 1004, + LWS_CLOSE_STATUS_NO_STATUS = 1005, + LWS_CLOSE_STATUS_ABNORMAL_CLOSE = 1006, + LWS_CLOSE_STATUS_INVALID_PAYLOAD = 1007, + LWS_CLOSE_STATUS_POLICY_VIOLATION = 1008, + LWS_CLOSE_STATUS_MESSAGE_TOO_LARGE = 1009, + LWS_CLOSE_STATUS_EXTENSION_REQUIRED = 1010, + LWS_CLOSE_STATUS_UNEXPECTED_CONDITION = 1011, + LWS_CLOSE_STATUS_TLS_FAILURE = 1015, +}; + +struct libwebsocket; +struct libwebsocket_context; +/* needed even with extensions disabled for create context */ +struct libwebsocket_extension; + +/** + * callback_function() - User server actions + * @context: Websockets context + * @wsi: Opaque websocket instance pointer + * @reason: The reason for the call + * @user: Pointer to per-session user data allocated by library + * @in: Pointer used for some callback reasons + * @len: Length set for some callback reasons + * + * This callback is the way the user controls what is served. All the + * protocol detail is hidden and handled by the library. + * + * For each connection / session there is user data allocated that is + * pointed to by "user". You set the size of this user data area when + * the library is initialized with libwebsocket_create_server. + * + * You get an opportunity to initialize user data when called back with + * LWS_CALLBACK_ESTABLISHED reason. + * + * LWS_CALLBACK_ESTABLISHED: after the server completes a handshake with + * an incoming client + * + * LWS_CALLBACK_CLIENT_CONNECTION_ERROR: the request client connection has + * been unable to complete a handshake with the remote server + * + * LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH: this is the last chance for the + * client user code to examine the http headers + * and decide to reject the connection. If the + * content in the headers is interesting to the + * client (url, etc) it needs to copy it out at + * this point since it will be destroyed before + * the CLIENT_ESTABLISHED call + * + * LWS_CALLBACK_CLIENT_ESTABLISHED: after your client connection completed + * a handshake with the remote server + * + * LWS_CALLBACK_CLOSED: when the websocket session ends + * + * LWS_CALLBACK_RECEIVE: data has appeared for this server endpoint from a + * remote client, it can be found at *in and is + * len bytes long + * + * LWS_CALLBACK_CLIENT_RECEIVE_PONG: if you elected to see PONG packets, + * they appear with this callback reason. PONG + * packets only exist in 04+ protocol + * + * LWS_CALLBACK_CLIENT_RECEIVE: data has appeared from the server for the + * client connection, it can be found at *in and + * is len bytes long + * + * LWS_CALLBACK_HTTP: an http request has come from a client that is not + * asking to upgrade the connection to a websocket + * one. This is a chance to serve http content, + * for example, to send a script to the client + * which will then open the websockets connection. + * @in points to the URI path requested and + * libwebsockets_serve_http_file() makes it very + * simple to send back a file to the client. + * Normally after sending the file you are done + * with the http connection, since the rest of the + * activity will come by websockets from the script + * that was delivered by http, so you will want to + * return 1; to close and free up the connection. + * That's important because it uses a slot in the + * total number of client connections allowed set + * by MAX_CLIENTS. + * + * LWS_CALLBACK_HTTP_WRITEABLE: you can write more down the http protocol + * link now. + * + * LWS_CALLBACK_HTTP_FILE_COMPLETION: a file requested to be send down + * http link has completed. + * + * LWS_CALLBACK_CLIENT_WRITEABLE: + * LWS_CALLBACK_SERVER_WRITEABLE: If you call + * libwebsocket_callback_on_writable() on a connection, you will + * get one of these callbacks coming when the connection socket + * is able to accept another write packet without blocking. + * If it already was able to take another packet without blocking, + * you'll get this callback at the next call to the service loop + * function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE + * and servers get LWS_CALLBACK_SERVER_WRITEABLE. + * + * LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to + * the server at network level; the connection is accepted but then + * passed to this callback to decide whether to hang up immediately + * or not, based on the client IP. @in contains the connection + * socket's descriptor. Return non-zero to terminate + * the connection before sending or receiving anything. + * Because this happens immediately after the network connection + * from the client, there's no websocket protocol selected yet so + * this callback is issued only to protocol 0. + * + * LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: called when the handshake has + * been received and parsed from the client, but the response is + * not sent yet. Return non-zero to disallow the connection. + * @user is a pointer to an array of struct lws_tokens, you can + * use the header enums lws_token_indexes from libwebsockets.h + * to check for and read the supported header presence and + * content before deciding to allow the handshake to proceed or + * to kill the connection. + * + * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS: if configured for + * including OpenSSL support, this callback allows your user code + * to perform extra SSL_CTX_load_verify_locations() or similar + * calls to direct OpenSSL where to find certificates the client + * can use to confirm the remote server identity. @user is the + * OpenSSL SSL_CTX* + * + * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS: if configured for + * including OpenSSL support, this callback allows your user code + * to load extra certifcates into the server which allow it to + * verify the validity of certificates returned by clients. @user + * is the server's OpenSSL SSL_CTX* + * + * LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION: if the + * libwebsockets context was created with the option + * LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this + * callback is generated during OpenSSL verification of the cert + * sent from the client. It is sent to protocol[0] callback as + * no protocol has been negotiated on the connection yet. + * Notice that the libwebsockets context and wsi are both NULL + * during this callback. See + * http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html + * to understand more detail about the OpenSSL callback that + * generates this libwebsockets callback and the meanings of the + * arguments passed. In this callback, @user is the x509_ctx, + * @in is the ssl pointer and @len is preverify_ok + * Notice that this callback maintains libwebsocket return + * conventions, return 0 to mean the cert is OK or 1 to fail it. + * This also means that if you don't handle this callback then + * the default callback action of returning 0 allows the client + * certificates. + * + * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER: this callback happens + * when a client handshake is being compiled. @user is NULL, + * @in is a char **, it's pointing to a char * which holds the + * next location in the header buffer where you can add + * headers, and @len is the remaining space in the header buffer, + * which is typically some hundreds of bytes. So, to add a canned + * cookie, your handler code might look similar to: + * + * char **p = (char **)in; + * + * if (len < 100) + * return 1; + * + * *p += sprintf(*p, "Cookie: a=b\x0d\x0a"); + * + * return 0; + * + * Notice if you add anything, you just have to take care about + * the CRLF on the line you added. Obviously this callback is + * optional, if you don't handle it everything is fine. + * + * Notice the callback is coming to protocols[0] all the time, + * because there is no specific protocol handshook yet. + * + * LWS_CALLBACK_CONFIRM_EXTENSION_OKAY: When the server handshake code + * sees that it does support a requested extension, before + * accepting the extension by additing to the list sent back to + * the client it gives this callback just to check that it's okay + * to use that extension. It calls back to the requested protocol + * and with @in being the extension name, @len is 0 and @user is + * valid. Note though at this time the ESTABLISHED callback hasn't + * happened yet so if you initialize @user content there, @user + * content during this callback might not be useful for anything. + * Notice this callback comes to protocols[0]. + * + * LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: When a client + * connection is being prepared to start a handshake to a server, + * each supported extension is checked with protocols[0] callback + * with this reason, giving the user code a chance to suppress the + * claim to support that extension by returning non-zero. If + * unhandled, by default 0 will be returned and the extension + * support included in the header to the server. Notice this + * callback comes to protocols[0]. + * + * LWS_CALLBACK_PROTOCOL_INIT: One-time call per protocol so it can + * do initial setup / allocations etc + * + * LWS_CALLBACK_PROTOCOL_DESTROY: One-time call per protocol indicating + * this protocol won't get used at all after this callback, the + * context is getting destroyed. Take the opportunity to + * deallocate everything that was allocated by the protocol. + * + * The next four reasons are optional and only need taking care of if you + * will be integrating libwebsockets sockets into an external polling + * array. + * + * LWS_CALLBACK_ADD_POLL_FD: libwebsocket deals with its poll() loop + * internally, but in the case you are integrating with another + * server you will need to have libwebsocket sockets share a + * polling array with the other server. This and the other + * POLL_FD related callbacks let you put your specialized + * poll array interface code in the callback for protocol 0, the + * first protocol you support, usually the HTTP protocol in the + * serving case. This callback happens when a socket needs to be + * added to the polling loop: @in contains the fd, and + * @len is the events bitmap (like, POLLIN). If you are using the + * internal polling loop (the "service" callback), you can just + * ignore these callbacks. + * + * LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor + * needs to be removed from an external polling array. @in is + * the socket desricptor. If you are using the internal polling + * loop, you can just ignore it. + * + * LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets + * wants to modify the events for the socket descriptor in @in. + * The handler should OR @len on to the events member of the pollfd + * struct for this socket descriptor. If you are using the + * internal polling loop, you can just ignore it. + * + * LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets + * wants to modify the events for the socket descriptor in @in. + * The handler should AND ~@len on to the events member of the + * pollfd struct for this socket descriptor. If you are using the + * internal polling loop, you can just ignore it. + */ +LWS_VISIBLE LWS_EXTERN int callback(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, void *user, + void *in, size_t len); + +typedef int (callback_function)(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, void *user, + void *in, size_t len); + +#ifndef LWS_NO_EXTENSIONS +/** + * extension_callback_function() - Hooks to allow extensions to operate + * @context: Websockets context + * @ext: This extension + * @wsi: Opaque websocket instance pointer + * @reason: The reason for the call + * @user: Pointer to per-session user data allocated by library + * @in: Pointer used for some callback reasons + * @len: Length set for some callback reasons + * + * Each extension that is active on a particular connection receives + * callbacks during the connection lifetime to allow the extension to + * operate on websocket data and manage itself. + * + * Libwebsockets takes care of allocating and freeing "user" memory for + * each active extension on each connection. That is what is pointed to + * by the @user parameter. + * + * LWS_EXT_CALLBACK_CONSTRUCT: called when the server has decided to + * select this extension from the list provided by the client, + * just before the server will send back the handshake accepting + * the connection with this extension active. This gives the + * extension a chance to initialize its connection context found + * in @user. + * + * LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: same as LWS_EXT_CALLBACK_CONSTRUCT + * but called when client is instantiating this extension. Some + * extensions will work the same on client and server side and then + * you can just merge handlers for both CONSTRUCTS. + * + * LWS_EXT_CALLBACK_DESTROY: called when the connection the extension was + * being used on is about to be closed and deallocated. It's the + * last chance for the extension to deallocate anything it has + * allocated in the user data (pointed to by @user) before the + * user data is deleted. This same callback is used whether you + * are in client or server instantiation context. + * + * LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: when this extension was active on + * a connection, and a packet of data arrived at the connection, + * it is passed to this callback to give the extension a chance to + * change the data, eg, decompress it. @user is pointing to the + * extension's private connection context data, @in is pointing + * to an lws_tokens struct, it consists of a char * pointer called + * token, and an int called token_len. At entry, these are + * set to point to the received buffer and set to the content + * length. If the extension will grow the content, it should use + * a new buffer allocated in its private user context data and + * set the pointed-to lws_tokens members to point to its buffer. + * + * LWS_EXT_CALLBACK_PACKET_TX_PRESEND: this works the same way as + * LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the + * extension a chance to change websocket data just before it will + * be sent out. Using the same lws_token pointer scheme in @in, + * the extension can change the buffer and the length to be + * transmitted how it likes. Again if it wants to grow the + * buffer safely, it should copy the data into its own buffer and + * set the lws_tokens token pointer to it. + */ +LWS_VISIBLE LWS_EXTERN int extension_callback(struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, + void *user, void *in, size_t len); + +typedef int (extension_callback_function)(struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, + void *user, void *in, size_t len); +#endif + +/** + * struct libwebsocket_protocols - List of protocols and handlers server + * supports. + * @name: Protocol name that must match the one given in the client + * Javascript new WebSocket(url, 'protocol') name + * @callback: The service callback used for this protocol. It allows the + * service action for an entire protocol to be encapsulated in + * the protocol-specific callback + * @per_session_data_size: Each new connection using this protocol gets + * this much memory allocated on connection establishment and + * freed on connection takedown. A pointer to this per-connection + * allocation is passed into the callback in the 'user' parameter + * @rx_buffer_size: if you want atomic frames delivered to the callback, you + * should set this to the size of the biggest legal frame that + * you support. If the frame size is exceeded, there is no + * error, but the buffer will spill to the user callback when + * full, which you can detect by using + * libwebsockets_remaining_packet_payload(). Notice that you + * just talk about frame size here, the LWS_SEND_BUFFER_PRE_PADDING + * and post-padding are automatically also allocated on top. + * @owning_server: the server init call fills in this opaque pointer when + * registering this protocol with the server. + * @protocol_index: which protocol we are starting from zero + * + * This structure represents one protocol supported by the server. An + * array of these structures is passed to libwebsocket_create_server() + * allows as many protocols as you like to be handled by one server. + */ + +struct libwebsocket_protocols { + const char *name; + callback_function *callback; + size_t per_session_data_size; + size_t rx_buffer_size; + + /* + * below are filled in on server init and can be left uninitialized, + * no need for user to use them directly either + */ + + struct libwebsocket_context *owning_server; + int protocol_index; +}; + +#ifndef LWS_NO_EXTENSIONS +/** + * struct libwebsocket_extension - An extension we know how to cope with + * + * @name: Formal extension name, eg, "deflate-stream" + * @callback: Service callback + * @per_session_data_size: Libwebsockets will auto-malloc this much + * memory for the use of the extension, a pointer + * to it comes in the @user callback parameter + * @per_context_private_data: Optional storage for this extension that + * is per-context, so it can track stuff across + * all sessions, etc, if it wants + */ + +struct libwebsocket_extension { + const char *name; + extension_callback_function *callback; + size_t per_session_data_size; + void *per_context_private_data; +}; +#endif + +/** + * struct lws_context_creation_info: parameters to create context with + * + * @port: Port to listen on... you can use 0 to suppress listening on + * any port, that's what you want if you are not running a + * websocket server at all but just using it as a client + * @iface: NULL to bind the listen socket to all interfaces, or the + * interface name, eg, "eth2" + * @protocols: Array of structures listing supported protocols and a protocol- + * specific callback for each one. The list is ended with an + * entry that has a NULL callback pointer. + * It's not const because we write the owning_server member + * @extensions: NULL or array of libwebsocket_extension structs listing the + * extensions this context supports. If you configured with + * --without-extensions, you should give NULL here. + * @ssl_cert_filepath: If libwebsockets was compiled to use ssl, and you want + * to listen using SSL, set to the filepath to fetch the + * server cert from, otherwise NULL for unencrypted + * @ssl_private_key_filepath: filepath to private key if wanting SSL mode, + * else ignored + * @ssl_ca_filepath: CA certificate filepath or NULL + * @ssl_cipher_list: List of valid ciphers to use (eg, + * "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL" + * or you can leave it as NULL to get "DEFAULT" + * @gid: group id to change to after setting listen socket, or -1. + * @uid: user id to change to after setting listen socket, or -1. + * @options: 0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK + * @user: optional user pointer that can be recovered via the context + * pointer using libwebsocket_context_user + * @ka_time: 0 for no keepalive, otherwise apply this keepalive timeout to + * all libwebsocket sockets, client or server + * @ka_probes: if ka_time was nonzero, after the timeout expires how many + * times to try to get a response from the peer before giving up + * and killing the connection + * @ka_interval: if ka_time was nonzero, how long to wait before each ka_probes + * attempt + */ + +struct lws_context_creation_info { + int port; + const char *iface; + struct libwebsocket_protocols *protocols; + struct libwebsocket_extension *extensions; + const char *ssl_cert_filepath; + const char *ssl_private_key_filepath; + const char *ssl_ca_filepath; + const char *ssl_cipher_list; + int gid; + int uid; + unsigned int options; + void *user; + int ka_time; + int ka_probes; + int ka_interval; + +}; + +LWS_VISIBLE LWS_EXTERN +void lws_set_log_level(int level, + void (*log_emit_function)(int level, const char *line)); + +LWS_VISIBLE LWS_EXTERN void +lwsl_emit_syslog(int level, const char *line); + +LWS_VISIBLE LWS_EXTERN struct libwebsocket_context * +libwebsocket_create_context(struct lws_context_creation_info *info); + +LWS_VISIBLE LWS_EXTERN void +libwebsocket_context_destroy(struct libwebsocket_context *context); + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_service(struct libwebsocket_context *context, int timeout_ms); + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_service_fd(struct libwebsocket_context *context, + struct pollfd *pollfd); + +LWS_VISIBLE LWS_EXTERN void * +libwebsocket_context_user(struct libwebsocket_context *context); + +/* + * IMPORTANT NOTICE! + * + * When sending with websocket protocol (LWS_WRITE_TEXT or LWS_WRITE_BINARY) + * the send buffer has to have LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE + * buf, and LWS_SEND_BUFFER_POST_PADDING bytes valid AFTER (buf + len). + * + * This allows us to add protocol info before and after the data, and send as + * one packet on the network without payload copying, for maximum efficiency. + * + * So for example you need this kind of code to use libwebsocket_write with a + * 128-byte payload + * + * char buf[LWS_SEND_BUFFER_PRE_PADDING + 128 + LWS_SEND_BUFFER_POST_PADDING]; + * + * // fill your part of the buffer... for example here it's all zeros + * memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128); + * + * libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128, + * LWS_WRITE_TEXT); + * + * When sending LWS_WRITE_HTTP, there is no protocol addition and you can just + * use the whole buffer without taking care of the above. + */ + +/* + * this is the frame nonce plus two header plus 8 length + * there's an additional two for mux extension per mux nesting level + * 2 byte prepend on close will already fit because control frames cannot use + * the big length style + */ + +#define LWS_SEND_BUFFER_PRE_PADDING (4 + 10 + (2 * MAX_MUX_RECURSION)) +#define LWS_SEND_BUFFER_POST_PADDING 4 + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len, + enum libwebsocket_write_protocol protocol); + +LWS_VISIBLE LWS_EXTERN int +libwebsockets_serve_http_file(struct libwebsocket_context *context, + struct libwebsocket *wsi, const char *file, + const char *content_type); +LWS_VISIBLE LWS_EXTERN int +libwebsockets_serve_http_file_fragment(struct libwebsocket_context *context, + struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN const struct libwebsocket_protocols * +libwebsockets_get_protocol(struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_callback_on_writable(struct libwebsocket_context *context, + struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_callback_on_writable_all_protocol( + const struct libwebsocket_protocols *protocol); + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_get_socket_fd(struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_is_final_fragment(struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN unsigned char +libwebsocket_get_reserved_bits(struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable); + +LWS_VISIBLE LWS_EXTERN void +libwebsocket_rx_flow_allow_all_protocol( + const struct libwebsocket_protocols *protocol); + +LWS_VISIBLE LWS_EXTERN size_t +libwebsockets_remaining_packet_payload(struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN struct libwebsocket * +libwebsocket_client_connect(struct libwebsocket_context *clients, + const char *address, + int port, + int ssl_connection, + const char *path, + const char *host, + const char *origin, + const char *protocol, + int ietf_version_or_minus_one); + +LWS_VISIBLE LWS_EXTERN struct libwebsocket * +libwebsocket_client_connect_extended(struct libwebsocket_context *clients, + const char *address, + int port, + int ssl_connection, + const char *path, + const char *host, + const char *origin, + const char *protocol, + int ietf_version_or_minus_one, + void *userdata); + +LWS_VISIBLE LWS_EXTERN const char * +libwebsocket_canonical_hostname(struct libwebsocket_context *context); + + +LWS_VISIBLE LWS_EXTERN void +libwebsockets_get_peer_addresses(struct libwebsocket_context *context, + struct libwebsocket *wsi, int fd, char *name, int name_len, + char *rip, int rip_len); + +LWS_VISIBLE LWS_EXTERN int +libwebsockets_get_random(struct libwebsocket_context *context, + void *buf, int len); + +LWS_VISIBLE LWS_EXTERN int +lws_daemonize(const char *_lock_path); + +LWS_VISIBLE LWS_EXTERN int +lws_send_pipe_choked(struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN int +lws_frame_is_binary(struct libwebsocket *wsi); + +LWS_VISIBLE LWS_EXTERN unsigned char * +libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md); + +LWS_VISIBLE LWS_EXTERN int +lws_b64_encode_string(const char *in, int in_len, char *out, int out_size); + +LWS_VISIBLE LWS_EXTERN int +lws_b64_decode_string(const char *in, char *out, int out_size); + +LWS_VISIBLE LWS_EXTERN const char * +lws_get_library_version(void); + +/* access to headers... only valid while headers valid */ + +LWS_VISIBLE LWS_EXTERN int +lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h); + +LWS_VISIBLE LWS_EXTERN int +lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len, + enum lws_token_indexes h); + +/* + * Note: this is not normally needed as a user api. It's provided in case it is + * useful when integrating with other app poll loop service code. + */ + +LWS_VISIBLE LWS_EXTERN int +libwebsocket_read(struct libwebsocket_context *context, + struct libwebsocket *wsi, + unsigned char *buf, size_t len); + +#ifndef LWS_NO_EXTENSIONS +LWS_VISIBLE LWS_EXTERN struct libwebsocket_extension *libwebsocket_get_internal_extensions(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/external/libwebsockets/mac/lib/libwebsockets.a.REMOVED.git-id b/external/libwebsockets/mac/lib/libwebsockets.a.REMOVED.git-id new file mode 100644 index 0000000000..bdf504bf24 --- /dev/null +++ b/external/libwebsockets/mac/lib/libwebsockets.a.REMOVED.git-id @@ -0,0 +1 @@ +5d0743ce07a9c865d4367d8e3db161148676f2c8 \ No newline at end of file diff --git a/plugin/plugins/admob/proj.ios/PluginAdmob.xcodeproj/project.pbxproj b/plugin/plugins/admob/proj.ios/PluginAdmob.xcodeproj/project.pbxproj index e1fec66e46..631a665f84 100644 --- a/plugin/plugins/admob/proj.ios/PluginAdmob.xcodeproj/project.pbxproj +++ b/plugin/plugins/admob/proj.ios/PluginAdmob.xcodeproj/project.pbxproj @@ -212,7 +212,10 @@ FADC44B6176EA82000B2D5ED /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/PluginAdmob.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; @@ -229,7 +232,10 @@ FADC44B7176EA82000B2D5ED /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/PluginAdmob.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; diff --git a/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj b/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj index de8213e1d3..560071669c 100644 --- a/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj +++ b/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj @@ -102,7 +102,7 @@ FA09A369168AFD41008C1C7B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0460; ORGANIZATIONNAME = zhangbin; }; buildConfigurationList = FA09A36C168AFD41008C1C7B /* Build configuration list for PBXProject "PluginFlurry" */; @@ -141,6 +141,9 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -167,6 +170,9 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -183,8 +189,10 @@ FA09A381168AFD41008C1C7B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/libPluginFlurry.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; @@ -202,8 +210,10 @@ FA09A382168AFD41008C1C7B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/libPluginFlurry.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; diff --git a/plugin/plugins/twitter/proj.ios/PluginTwitter.xcodeproj/project.pbxproj b/plugin/plugins/twitter/proj.ios/PluginTwitter.xcodeproj/project.pbxproj index 268d4490ba..d3ea4f1cee 100644 --- a/plugin/plugins/twitter/proj.ios/PluginTwitter.xcodeproj/project.pbxproj +++ b/plugin/plugins/twitter/proj.ios/PluginTwitter.xcodeproj/project.pbxproj @@ -179,7 +179,7 @@ FACAD87F1762C1B500D75ADE /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0460; ORGANIZATIONNAME = zhangbin; }; buildConfigurationList = FACAD8821762C1B500D75ADE /* Build configuration list for PBXProject "PluginTwitter" */; @@ -226,6 +226,9 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -251,6 +254,9 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -267,8 +273,10 @@ FACAD8971762C1B500D75ADE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/PluginTwitter.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; @@ -281,8 +289,10 @@ FACAD8981762C1B500D75ADE /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/PluginTwitter.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; diff --git a/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.m b/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.m index 7805586e6b..9260004579 100644 --- a/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.m +++ b/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.m @@ -74,7 +74,11 @@ THE SOFTWARE. - (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap { OUTPUT_LOG(@"Umeng logEventWithParam invoked"); - [MobClick event:eventId attributes:paramMap]; + if (paramMap != nil) { + [MobClick event:eventId attributes:paramMap]; + } else { + [MobClick event:eventId]; + } } - (void) logTimedEventBegin: (NSString*) eventId diff --git a/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj b/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj index ea67c97955..19afde100d 100644 --- a/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj +++ b/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj @@ -100,7 +100,7 @@ FA09A2F8168ADAEC008C1C7B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0460; ORGANIZATIONNAME = zhangbin; }; buildConfigurationList = FA09A2FB168ADAEC008C1C7B /* Build configuration list for PBXProject "PluginUmeng" */; @@ -139,6 +139,9 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -165,6 +168,9 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -181,8 +187,10 @@ FA09A310168ADAEC008C1C7B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/libPluginUmeng.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; @@ -200,8 +208,10 @@ FA09A311168ADAEC008C1C7B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/libPluginUmeng.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; diff --git a/plugin/plugins/weibo/proj.ios/PluginWeibo.xcodeproj/project.pbxproj b/plugin/plugins/weibo/proj.ios/PluginWeibo.xcodeproj/project.pbxproj index 75af6648a9..da7106f327 100644 --- a/plugin/plugins/weibo/proj.ios/PluginWeibo.xcodeproj/project.pbxproj +++ b/plugin/plugins/weibo/proj.ios/PluginWeibo.xcodeproj/project.pbxproj @@ -142,7 +142,7 @@ FAE27527175D9D2900F5DA8E /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0460; ORGANIZATIONNAME = zhangbin; }; buildConfigurationList = FAE2752A175D9D2900F5DA8E /* Build configuration list for PBXProject "PluginWeibo" */; @@ -184,6 +184,9 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -209,6 +212,9 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -225,9 +231,10 @@ FAE2753F175D9D2B00F5DA8E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/PluginWeibo.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; @@ -240,9 +247,10 @@ FAE27540175D9D2B00F5DA8E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; DSTROOT = /tmp/PluginWeibo.dst; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; diff --git a/plugin/samples/HelloShare/proj.ios/AppController.h b/plugin/protocols/platform/ios/InterfaceUser.h similarity index 76% rename from plugin/samples/HelloShare/proj.ios/AppController.h rename to plugin/protocols/platform/ios/InterfaceUser.h index ab7abff7d2..f6d08bb00a 100644 --- a/plugin/samples/HelloShare/proj.ios/AppController.h +++ b/plugin/protocols/platform/ios/InterfaceUser.h @@ -1,35 +1,36 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ - -#import - -@class RootViewController; - -@interface AppController : NSObject { - UIWindow *window; - RootViewController *viewController; -} - -@end - +/**************************************************************************** +Copyright (c) 2012+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. +****************************************************************************/ + +@protocol InterfaceUser + +- (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo; +- (void) login; +- (void) logout; +- (BOOL) isLogined; +- (NSString*) getSessionID; +- (void) setDebugMode: (BOOL) debug; +- (NSString*) getSDKVersion; +- (NSString*) getPluginVersion; + +@end diff --git a/plugin/protocols/platform/ios/ProtocolUser.mm b/plugin/protocols/platform/ios/ProtocolUser.mm new file mode 100644 index 0000000000..ab3f2ed58a --- /dev/null +++ b/plugin/protocols/platform/ios/ProtocolUser.mm @@ -0,0 +1,80 @@ +/**************************************************************************** +Copyright (c) 2012-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. +****************************************************************************/ +#include "ProtocolUser.h" +#include "PluginUtilsIOS.h" +#import "InterfaceUser.h" + +namespace cocos2d { namespace plugin { + +ProtocolUser::ProtocolUser() +: _listener(NULL) +{ +} + +ProtocolUser::~ProtocolUser() +{ +} + +void ProtocolUser::configDeveloperInfo(TUserDeveloperInfo devInfo) +{ + if (devInfo.empty()) + { + PluginUtilsIOS::outputLog("The developer info is empty for %s!", this->getPluginName()); + return; + } + else + { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceUser)]) { + NSObject* curObj = ocObj; + NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo); + [curObj configDeveloperInfo:pDict]; + } + } +} + +void ProtocolUser::login() +{ + PluginUtilsIOS::callOCFunctionWithName(this, "login"); +} + +void ProtocolUser::logout() +{ + PluginUtilsIOS::callOCFunctionWithName(this, "logout"); +} + +bool ProtocolUser::isLogined() +{ + return PluginUtilsIOS::callOCBoolFunctionWithName(this, "isLogined"); +} + +std::string ProtocolUser::getSessionID() +{ + return PluginUtilsIOS::callOCStringFunctionWithName(this, "getSessionID"); +} + +}} // namespace cocos2d { namespace plugin { diff --git a/plugin/samples/HelloShare/proj.ios/RootViewController.h b/plugin/protocols/platform/ios/UserWrapper.h similarity index 76% rename from plugin/samples/HelloShare/proj.ios/RootViewController.h rename to plugin/protocols/platform/ios/UserWrapper.h index b346fa122d..02c21f2c0d 100644 --- a/plugin/samples/HelloShare/proj.ios/RootViewController.h +++ b/plugin/protocols/platform/ios/UserWrapper.h @@ -1,32 +1,40 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ - -#import - - -@interface RootViewController : UIViewController { - -} - -@end +/**************************************************************************** +Copyright (c) 2012+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. +****************************************************************************/ + +#import + +typedef enum { + kLoginSucceed = 0, + kLoginFailed, + kLogoutSucceed, +} UserActionResult; + +@interface UserWrapper : NSObject +{ + +} + ++ (void) onActionResult:(id) obj withRet:(UserActionResult) ret withMsg:(NSString*) msg; + +@end diff --git a/plugin/samples/HelloIAP/proj.android/src/org/cocos2dx/helloIAP/HelloIAP.java b/plugin/protocols/platform/ios/UserWrapper.mm similarity index 54% rename from plugin/samples/HelloIAP/proj.android/src/org/cocos2dx/helloIAP/HelloIAP.java rename to plugin/protocols/platform/ios/UserWrapper.mm index f13450365d..117398abab 100644 --- a/plugin/samples/HelloIAP/proj.android/src/org/cocos2dx/helloIAP/HelloIAP.java +++ b/plugin/protocols/platform/ios/UserWrapper.mm @@ -1,43 +1,53 @@ -/**************************************************************************** -Copyright (c) 2010-2012 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.helloIAP; - -import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.plugin.PluginWrapper; - -import android.os.Bundle; - -public class HelloIAP extends Cocos2dxActivity{ - - protected void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - PluginWrapper.init(this); - PluginWrapper.setGLSurfaceView(Cocos2dxGLSurfaceView.getInstance()); - } - - static { - System.loadLibrary("game"); - } -} +/**************************************************************************** +Copyright (c) 2012+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. +****************************************************************************/ + +#import "UserWrapper.h" +#include "PluginUtilsIOS.h" +#include "ProtocolUser.h" + +using namespace cocos2d::plugin; + +@implementation UserWrapper + ++ (void) onActionResult:(id) obj withRet:(UserActionResult) ret withMsg:(NSString*) msg +{ + PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj); + ProtocolUser* pUser = dynamic_cast(pPlugin); + if (pUser) { + UserActionListener* listener = pUser->getActionListener(); + if (NULL != listener) + { + const char* chMsg = [msg UTF8String]; + listener->onActionResult(pUser, (UserActionResultCode) ret, chMsg); + } + else + { + PluginUtilsIOS::outputLog("Listener of plugin %s not set correctly", pPlugin->getPluginName()); + } + } else { + PluginUtilsIOS::outputLog("Can't find the C++ object of the User plugin"); + } +} + +@end diff --git a/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj b/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj index cbf537f92e..d25e99c866 100644 --- a/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj +++ b/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF991755D93600C90D89 /* PluginProtocol.mm */; }; FAC2A7F91777F8C200035D22 /* ProtocolShare.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */; }; FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */; }; + FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551D177D1FA900968F54 /* ProtocolUser.mm */; }; + FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551F177D1FA900968F54 /* UserWrapper.mm */; }; FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */; }; /* End PBXBuildFile section */ @@ -63,6 +65,11 @@ FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolShare.mm; sourceTree = ""; }; FAC2A7F71777F8C200035D22 /* ShareWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareWrapper.h; sourceTree = ""; }; FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShareWrapper.mm; sourceTree = ""; }; + FAD5551C177D1FA900968F54 /* InterfaceUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceUser.h; sourceTree = ""; }; + FAD5551D177D1FA900968F54 /* ProtocolUser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolUser.mm; sourceTree = ""; }; + FAD5551E177D1FA900968F54 /* UserWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserWrapper.h; sourceTree = ""; }; + FAD5551F177D1FA900968F54 /* UserWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserWrapper.mm; sourceTree = ""; }; + FAD55522177D213F00968F54 /* ProtocolUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolUser.h; sourceTree = ""; }; FADC44C8176EABCF00B2D5ED /* AdsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsWrapper.h; sourceTree = ""; }; FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AdsWrapper.mm; sourceTree = ""; }; /* End PBXFileReference section */ @@ -112,6 +119,7 @@ FA09A336168ADC05008C1C7B /* include */ = { isa = PBXGroup; children = ( + FAD55522177D213F00968F54 /* ProtocolUser.h */, FAC2A7F41777F88700035D22 /* ProtocolShare.h */, FAB6DF931755D7D100C90D89 /* PluginFactory.h */, FAB6DF941755D7D100C90D89 /* PluginParam.h */, @@ -128,6 +136,10 @@ FA0CB8B5168D3CC200E36B11 /* ios */ = { isa = PBXGroup; children = ( + FAD5551C177D1FA900968F54 /* InterfaceUser.h */, + FAD5551D177D1FA900968F54 /* ProtocolUser.mm */, + FAD5551E177D1FA900968F54 /* UserWrapper.h */, + FAD5551F177D1FA900968F54 /* UserWrapper.mm */, FAC2A7F51777F8C200035D22 /* InterfaceShare.h */, FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */, FAC2A7F71777F8C200035D22 /* ShareWrapper.h */, @@ -212,6 +224,8 @@ FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */, FAC2A7F91777F8C200035D22 /* ProtocolShare.mm in Sources */, FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */, + FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */, + FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -273,8 +287,10 @@ FA09A330168ADBC2008C1C7B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; DSTROOT = /tmp/PluginProtocol.dst; + GCC_C_LANGUAGE_STANDARD = c99; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginProtocol-Prefix.pch"; OTHER_LDFLAGS = "-ObjC"; @@ -286,8 +302,10 @@ FA09A331168ADBC2008C1C7B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; DSTROOT = /tmp/PluginProtocol.dst; + GCC_C_LANGUAGE_STANDARD = c99; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PluginProtocol-Prefix.pch"; OTHER_LDFLAGS = "-ObjC"; diff --git a/plugin/samples/HelloAds/Classes/AppDelegate.cpp b/plugin/samples/HelloAds/Classes/AppDelegate.cpp deleted file mode 100644 index 3586f8267f..0000000000 --- a/plugin/samples/HelloAds/Classes/AppDelegate.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ -#include "AppDelegate.h" -#include "HelloWorldScene.h" - -USING_NS_CC; - -AppDelegate::AppDelegate() { - -} - -AppDelegate::~AppDelegate() -{ -} - -bool AppDelegate::applicationDidFinishLaunching() { - // initialize director - Director* pDirector = Director::sharedDirector(); - EGLView* pEGLView = EGLView::sharedOpenGLView(); - - pDirector->setOpenGLView(pEGLView); - - pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder); - - // turn on display FPS - pDirector->setDisplayStats(true); - - // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); - - // create a scene. it's an autorelease object - Scene *pScene = HelloWorld::scene(); - - // run - pDirector->runWithScene(pScene); - - return true; -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() { - Director::sharedDirector()->stopAnimation(); - - // if you use SimpleAudioEngine, it must be pause - // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() { - Director::sharedDirector()->startAnimation(); - - // if you use SimpleAudioEngine, it must resume here - // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -} diff --git a/plugin/samples/HelloAds/Classes/AppDelegate.h b/plugin/samples/HelloAds/Classes/AppDelegate.h deleted file mode 100644 index e3885d961d..0000000000 --- a/plugin/samples/HelloAds/Classes/AppDelegate.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ -#ifndef _APP_DELEGATE_H_ -#define _APP_DELEGATE_H_ - -#include "cocos2d.h" - -/** -@brief The cocos2d Application. - -The reason for implement as private inheritance is to hide some interface call by Director. -*/ -class AppDelegate : private cocos2d::Application -{ -public: - AppDelegate(); - virtual ~AppDelegate(); - - /** - @brief Implement Director and Scene init code here. - @return true Initialize success, app continue. - @return false Initialize failed, app terminate. - */ - virtual bool applicationDidFinishLaunching(); - - /** - @brief The function be called when the application enter background - @param the pointer of the application - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function be called when the application enter foreground - @param the pointer of the application - */ - virtual void applicationWillEnterForeground(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/plugin/samples/HelloAds/proj.android/.classpath b/plugin/samples/HelloAds/proj.android/.classpath deleted file mode 100644 index 9f9f31f70f..0000000000 --- a/plugin/samples/HelloAds/proj.android/.classpath +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloAds/proj.android/.project b/plugin/samples/HelloAds/proj.android/.project deleted file mode 100644 index f731d7c4b7..0000000000 --- a/plugin/samples/HelloAds/proj.android/.project +++ /dev/null @@ -1,45 +0,0 @@ - - - HelloAds - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - plugin-x - 2 - PARENT-3-PROJECT_LOC/publish - - - diff --git a/plugin/samples/HelloAds/proj.android/AndroidManifest.xml b/plugin/samples/HelloAds/proj.android/AndroidManifest.xml deleted file mode 100644 index 804a1bc20a..0000000000 --- a/plugin/samples/HelloAds/proj.android/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloAds/proj.android/build.xml b/plugin/samples/HelloAds/proj.android/build.xml deleted file mode 100644 index 693f927946..0000000000 --- a/plugin/samples/HelloAds/proj.android/build.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloAds/proj.android/jni/Android.mk b/plugin/samples/HelloAds/proj.android/jni/Android.mk deleted file mode 100644 index 49fb10bb3c..0000000000 --- a/plugin/samples/HelloAds/proj.android/jni/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos2dcpp_shared - -LOCAL_MODULE_FILENAME := libcocos2dcpp - -LOCAL_SRC_FILES := hellocpp/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static \ -PluginProtocolStatic - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) -$(call import-module,protocols/android) diff --git a/plugin/samples/HelloAds/proj.android/project.properties b/plugin/samples/HelloAds/proj.android/project.properties deleted file mode 100644 index db4ff43492..0000000000 --- a/plugin/samples/HelloAds/proj.android/project.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-13 - -android.library.reference.1=../../../../cocos2dx/platform/android/java diff --git a/plugin/samples/HelloAnalytics/Classes/AppDelegate.cpp b/plugin/samples/HelloAnalytics/Classes/AppDelegate.cpp deleted file mode 100644 index dacb18f155..0000000000 --- a/plugin/samples/HelloAnalytics/Classes/AppDelegate.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ -#include "AppDelegate.h" -#include "cocos2d.h" -#include "HelloWorldScene.h" -#include "PluginManager.h" -#include "ProtocolAnalytics.h" - -using namespace cocos2d::plugin; -USING_NS_CC; - -// The app key of flurry -#define FLURRY_KEY_IOS "KMGG7CD9WPK2TW4X9VR8" -#define FLURRY_KEY_ANDROID "SPKFH8KMPGHMMBWRBT5W" -#define UMENG_KEY_IOS "50d2b18c5270152187000097" -#define UMENG_KEY_ANDROID "" // umeng key for android is setted in AndroidManifest.xml - -ProtocolAnalytics* g_pAnalytics = NULL; -std::string s_strAppKey = ""; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ - -} - -void AppDelegate::loadAnalyticsPlugin() -{ - PluginProtocol* pPlugin = NULL; - ccLanguageType langType = Application::sharedApplication()->getCurrentLanguage(); - - std::string umengKey = ""; - std::string flurryKey = ""; - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - umengKey = UMENG_KEY_IOS; - flurryKey = FLURRY_KEY_IOS; -#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - umengKey = UMENG_KEY_ANDROID; - flurryKey = FLURRY_KEY_ANDROID; -#endif - - if (kLanguageChinese == langType) - { - pPlugin = PluginManager::getInstance()->loadPlugin("AnalyticsUmeng"); - s_strAppKey = umengKey; - } - else - { - pPlugin = PluginManager::getInstance()->loadPlugin("AnalyticsFlurry"); - s_strAppKey = flurryKey; - } - - g_pAnalytics = dynamic_cast(pPlugin); -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - loadAnalyticsPlugin(); - g_pAnalytics->setDebugMode(true); - g_pAnalytics->startSession(s_strAppKey.c_str()); - g_pAnalytics->setCaptureUncaughtException(true); - g_pAnalytics->setSessionContinueMillis(10000); - - const char* sdkVer = g_pAnalytics->getSDKVersion().c_str(); - CCLog("SDK version : %s", sdkVer); - - g_pAnalytics->callFuncWithParam("updateOnlineConfig", NULL); - - PluginParam pParam1(true); - g_pAnalytics->callFuncWithParam("setReportLocation", &pParam1, NULL); - - g_pAnalytics->callFuncWithParam("logPageView", NULL); - - PluginParam pParam2("1.1"); - g_pAnalytics->callFuncWithParam("setVersionName", &pParam2, NULL); - - PluginParam pParam3(20); - g_pAnalytics->callFuncWithParam("setAge", &pParam3, NULL); - - PluginParam pParam4(1); - g_pAnalytics->callFuncWithParam("setGender", &pParam4, NULL); - - PluginParam pParam5("123456"); - g_pAnalytics->callFuncWithParam("setUserId", &pParam5, NULL); - - PluginParam pParam6(false); - g_pAnalytics->callFuncWithParam("setUseHttps", &pParam6, NULL); - - // initialize director - Director *pDirector = Director::sharedDirector(); - pDirector->setOpenGLView(EGLView::sharedOpenGLView()); - - // turn on display FPS - //pDirector->setDisplayStats(true); - - // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); - - // create a scene. it's an autorelease object - Scene *pScene = HelloWorld::scene(); - - // run - pDirector->runWithScene(pScene); - - return true; -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() -{ - Director::sharedDirector()->pause(); - - // if you use SimpleAudioEngine, it must be pause - // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - g_pAnalytics->stopSession(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - Director::sharedDirector()->resume(); - if (g_pAnalytics) - { - g_pAnalytics->startSession(s_strAppKey.c_str()); - } - - // if you use SimpleAudioEngine, it must resume here - // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -} diff --git a/plugin/samples/HelloAnalytics/Classes/AppDelegate.h b/plugin/samples/HelloAnalytics/Classes/AppDelegate.h deleted file mode 100644 index d11ba56a3f..0000000000 --- a/plugin/samples/HelloAnalytics/Classes/AppDelegate.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ -#ifndef _APP_DELEGATE_H_ -#define _APP_DELEGATE_H_ - -#include "CCApplication.h" - -/** -@brief The cocos2d Application. - -The reason for implement as private inheritance is to hide some interface call by Director. -*/ -class AppDelegate : private cocos2d::Application -{ -public: - AppDelegate(); - virtual ~AppDelegate(); - - /** - @brief Implement Director and Scene init code here. - @return true Initialize success, app continue. - @return false Initialize failed, app terminate. - */ - virtual bool applicationDidFinishLaunching(); - - /** - @brief The function be called when the application enter background - @param the pointer of the application - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function be called when the application enter foreground - @param the pointer of the application - */ - virtual void applicationWillEnterForeground(); - - static void loadAnalyticsPlugin(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/plugin/samples/HelloAnalytics/proj.android/.classpath b/plugin/samples/HelloAnalytics/proj.android/.classpath deleted file mode 100644 index e6251b7af1..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/plugin/samples/HelloAnalytics/proj.android/.project b/plugin/samples/HelloAnalytics/proj.android/.project deleted file mode 100644 index 242b4d396f..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/.project +++ /dev/null @@ -1,45 +0,0 @@ - - - HelloAnalytics - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - publish - 2 - PARENT-3-PROJECT_LOC/publish - - - diff --git a/plugin/samples/HelloAnalytics/proj.android/AndroidManifest.xml b/plugin/samples/HelloAnalytics/proj.android/AndroidManifest.xml deleted file mode 100644 index eb2eb922e3..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/AndroidManifest.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloAnalytics/proj.android/ant.properties b/plugin/samples/HelloAnalytics/proj.android/ant.properties deleted file mode 100644 index b0971e891e..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/plugin/samples/HelloAnalytics/proj.android/build.xml b/plugin/samples/HelloAnalytics/proj.android/build.xml deleted file mode 100644 index 80abad0ab0..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloAnalytics/proj.android/build_native.sh b/plugin/samples/HelloAnalytics/proj.android/build_native.sh deleted file mode 100755 index 7b388a1442..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/build_native.sh +++ /dev/null @@ -1,81 +0,0 @@ -APPNAME="HelloAnalytics" - -# options - -buildexternalsfromsource= - -usage(){ -cat << EOF -usage: $0 [options] - -Build C/C++ code for $APPNAME using Android NDK - -OPTIONS: --s Build externals from source --h this help -EOF -} - -while getopts "sh" OPTION; do -case "$OPTION" in -s) -buildexternalsfromsource=1 -;; -h) -usage -exit 0 -;; -esac -done - -# paths - -if [ -z "${NDK_ROOT+aaa}" ];then -echo "please define NDK_ROOT" -exit 1 -fi - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# ... use paths relative to current directory -PLUGIN_ROOT="$DIR/../../.." -COCOS2DX_ROOT="$DIR/../../../.." -APP_ROOT="$DIR/.." -APP_ANDROID_ROOT="$DIR" - -echo "PLUGIN_ROOT = $PLUGIN_ROOT" -echo "NDK_ROOT = $NDK_ROOT" -echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" -echo "APP_ROOT = $APP_ROOT" -echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" -echo "---------------------------------------------------------" - -# make sure assets is exist -if [ -d "$APP_ANDROID_ROOT"/assets ]; then - rm -rf "$APP_ANDROID_ROOT"/assets -fi - -mkdir "$APP_ANDROID_ROOT"/assets - -# copy resources -for file in "$APP_ROOT"/Resources/* -do -if [ -d "$file" ]; then - cp -rf "$file" "$APP_ANDROID_ROOT"/assets -fi - -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/assets -fi -done - -if [[ "$buildexternalsfromsource" ]]; then - echo "Building external dependencies from source" - set -x - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" -else - echo "Using prebuilt externals" - set -x - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" -fi diff --git a/plugin/samples/HelloAnalytics/proj.android/jni/Android.mk b/plugin/samples/HelloAnalytics/proj.android/jni/Android.mk deleted file mode 100644 index 6940ebe855..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/jni/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := game_shared - -LOCAL_MODULE_FILENAME := libgame - -LOCAL_SRC_FILES := hellocpp/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \ - PluginProtocolStatic - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) \ -$(call import-module,protocols/android) diff --git a/plugin/samples/HelloAnalytics/proj.android/jni/Application.mk b/plugin/samples/HelloAnalytics/proj.android/jni/Application.mk deleted file mode 100644 index 488132832e..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/jni/Application.mk +++ /dev/null @@ -1,3 +0,0 @@ -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -std=c++11 -NDK_TOOLCHAIN_VERSION=4.7 diff --git a/plugin/samples/HelloAnalytics/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloAnalytics/proj.android/jni/hellocpp/main.cpp deleted file mode 100644 index edb9402593..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/jni/hellocpp/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "AppDelegate.h" -#include "platform/android/jni/JniHelper.h" -#include "PluginJniHelper.h" -#include -#include - -#include "HelloWorldScene.h" - -#define LOG_TAG "main" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) - -using namespace cocos2d; - -extern "C" -{ - -jint JNI_OnLoad(JavaVM *vm, void *reserved) -{ - JniHelper::setJavaVM(vm); - PluginJniHelper::setJavaVM(vm); - - return JNI_VERSION_1_4; -} - -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) -{ - if (!Director::sharedDirector()->getOpenGLView()) - { - EGLView *view = EGLView::sharedOpenGLView(); - view->setFrameSize(w, h); - - AppDelegate *pAppDelegate = new AppDelegate(); - Application::sharedApplication()->run(); - } - else - { - ccDrawInit(); - ccGLInvalidateStateCache(); - - ShaderCache::sharedShaderCache()->reloadDefaultShaders(); - TextureCache::reloadAllTextures(); - NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); - Director::sharedDirector()->setGLDefaultValues(); - } -} - -} diff --git a/plugin/samples/HelloAnalytics/proj.android/ndkgdb.sh b/plugin/samples/HelloAnalytics/proj.android/ndkgdb.sh deleted file mode 100755 index e706c46ad3..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/ndkgdb.sh +++ /dev/null @@ -1,47 +0,0 @@ -APPNAME="HelloAnalytics" -APP_ANDROID_NAME="org.cocos2dx.helloanalytics" - -if [ -z "${SDK_ROOT+aaa}" ]; then -# ... if SDK_ROOT is not set, use "$HOME/bin/android-sdk" - SDK_ROOT="$HOME/bin/android-sdk" -fi - -if [ -z "${NDK_ROOT+aaa}" ]; then -# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk" - NDK_ROOT="$HOME/bin/android-ndk" -fi - -if [ -z "${COCOS2DX_ROOT+aaa}" ]; then -# ... if COCOS2DX_ROOT is not set -# ... find current working directory - DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# ... use paths relative to current directory - COCOS2DX_ROOT="$DIR/../.." - APP_ROOT="$DIR/.." - APP_ANDROID_ROOT="$DIR" -else - APP_ROOT="$COCOS2DX_ROOT/$APPNAME" - APP_ANDROID_ROOT="$COCOS2DX_ROOT/$APPNAME/proj.android" -fi - -echo "NDK_ROOT = $NDK_ROOT" -echo "SDK_ROOT = $SDK_ROOT" -echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" -echo "APP_ROOT = $APP_ROOT" -echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" -echo "APP_ANDROID_NAME = $APP_ANDROID_NAME" - -echo -echo "Killing and restarting ${APP_ANDROID_NAME}" -echo - -set -x - -"${SDK_ROOT}"/platform-tools/adb shell am force-stop "${APP_ANDROID_NAME}" - -NDK_MODULE_PATH="${COCOS2DX_ROOT}":"${COCOS2DX_ROOT}"/cocos2dx/platform/third_party/android/prebuilt \ - "${NDK_ROOT}"/ndk-gdb \ - --adb="${SDK_ROOT}"/platform-tools/adb \ - --verbose \ - --start \ - --force diff --git a/plugin/samples/HelloAnalytics/proj.android/proguard-project.txt b/plugin/samples/HelloAnalytics/proj.android/proguard-project.txt deleted file mode 100644 index b60ae7ea07..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/plugin/samples/HelloAnalytics/proj.android/project.properties b/plugin/samples/HelloAnalytics/proj.android/project.properties deleted file mode 100644 index e4ad2bf52d..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java diff --git a/plugin/samples/HelloAnalytics/proj.android/res/values/strings.xml b/plugin/samples/HelloAnalytics/proj.android/res/values/strings.xml deleted file mode 100644 index 5d8f1e706b..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - HelloAnalytics - diff --git a/plugin/samples/HelloAnalytics/proj.android/src/org/cocos2dx/helloanalytics/HelloAnalytics.java b/plugin/samples/HelloAnalytics/proj.android/src/org/cocos2dx/helloanalytics/HelloAnalytics.java deleted file mode 100644 index 1ec319368f..0000000000 --- a/plugin/samples/HelloAnalytics/proj.android/src/org/cocos2dx/helloanalytics/HelloAnalytics.java +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 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.helloanalytics; - -import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.plugin.PluginWrapper; - -import android.os.Bundle; - -public class HelloAnalytics extends Cocos2dxActivity{ - - protected void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - PluginWrapper.init(this); - } - - static { - System.loadLibrary("game"); - } -} diff --git a/plugin/samples/HelloAnalytics/proj.ios/AppController.mm b/plugin/samples/HelloAnalytics/proj.ios/AppController.mm deleted file mode 100644 index 9ce66c9aa1..0000000000 --- a/plugin/samples/HelloAnalytics/proj.ios/AppController.mm +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010 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. - ****************************************************************************/ -#import -#import "AppController.h" -#import "cocos2d.h" -#import "EAGLView.h" -#import "AppDelegate.h" - -#import "RootViewController.h" - -@implementation AppController - -#pragma mark - -#pragma mark Application lifecycle - -// cocos2d application instance -static AppDelegate s_sharedApplication; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - // Override point for customization after application launch. - - // Add the view controller's view to the window and display. - window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - CCEAGLView *__glView = [CCEAGLView viewWithFrame: [window bounds] - pixelFormat: kEAGLColorFormatRGBA8 - depthFormat: GL_DEPTH_COMPONENT16 - preserveBackbuffer: NO - sharegroup:nil - multiSampling:NO - numberOfSamples:0]; - - // Use RootViewController manage CCEAGLView - viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; - viewController.wantsFullScreenLayout = YES; - viewController.view = __glView; - - // Set RootViewController to window - if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) - { - // warning: addSubView doesn't work on iOS6 - [window addSubview: viewController.view]; - } - else - { - // use this method on ios6 - [window setRootViewController:viewController]; - } - - [window makeKeyAndVisible]; - - [[UIApplication sharedApplication] setStatusBarHidden: YES]; - - cocos2d::Application::sharedApplication()->run(); - return YES; -} - - -- (void)applicationWillResignActive:(UIApplication *)application { - /* - Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - */ - cocos2d::Director::sharedDirector()->pause(); -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - /* - Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - */ - cocos2d::Director::sharedDirector()->resume(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - If your application supports background execution, called instead of applicationWillTerminate: when the user quits. - */ - cocos2d::Application::sharedApplication()->applicationDidEnterBackground(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. - */ - cocos2d::Application::sharedApplication()->applicationWillEnterForeground(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { - /* - Called when the application is about to terminate. - See also applicationDidEnterBackground:. - */ -} - - -#pragma mark - -#pragma mark Memory management - -- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - /* - Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. - */ -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end - diff --git a/plugin/samples/HelloAnalytics/proj.ios/Default-568h@2x.png.REMOVED.git-id b/plugin/samples/HelloAnalytics/proj.ios/Default-568h@2x.png.REMOVED.git-id deleted file mode 100644 index 8f5838f3a8..0000000000 --- a/plugin/samples/HelloAnalytics/proj.ios/Default-568h@2x.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/plugin/samples/HelloAnalytics/proj.ios/Default@2x.png.REMOVED.git-id b/plugin/samples/HelloAnalytics/proj.ios/Default@2x.png.REMOVED.git-id deleted file mode 100644 index 8843505b20..0000000000 --- a/plugin/samples/HelloAnalytics/proj.ios/Default@2x.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/plugin/samples/HelloAnalytics/proj.ios/HelloAnalytics.xcodeproj/project.pbxproj b/plugin/samples/HelloAnalytics/proj.ios/HelloAnalytics.xcodeproj/project.pbxproj deleted file mode 100755 index eff302a4ad..0000000000 --- a/plugin/samples/HelloAnalytics/proj.ios/HelloAnalytics.xcodeproj/project.pbxproj +++ /dev/null @@ -1,582 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; - 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; - 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; - BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492D4B1289302400A09262 /* OpenGLES.framework */; }; - BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492C21128924A800A09262 /* libxml2.dylib */; }; - BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492B6912891AC600A09262 /* libz.dylib */; }; - BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF137426128A8E4600D9F789 /* QuartzCore.framework */; }; - BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; }; - BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; }; - D446FD79161028E9000ADA7B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD78161028E9000ADA7B /* Default.png */; }; - D446FD7B161028ED000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD7A161028ED000ADA7B /* Default@2x.png */; }; - D446FD7D161028F4000ADA7B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD7C161028F4000ADA7B /* Default-568h@2x.png */; }; - D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; }; - D4EF94E815BD319200D803EB /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E715BD319200D803EB /* Icon-57.png */; }; - D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E915BD319500D803EB /* Icon-114.png */; }; - D4EF94EC15BD319B00D803EB /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94EB15BD319B00D803EB /* Icon-72.png */; }; - D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94ED15BD319D00D803EB /* Icon-144.png */; }; - FA0CB877168D2F5400E36B11 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0CB873168D2F5400E36B11 /* AppDelegate.cpp */; }; - FA0CB878168D2F5400E36B11 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0CB875168D2F5400E36B11 /* HelloWorldScene.cpp */; }; - FA0CB87E168D2FB200E36B11 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA0CB87D168D2FB200E36B11 /* SystemConfiguration.framework */; }; - FA0CB8A6168D31EA00E36B11 /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = FA0CB8A3168D31EA00E36B11 /* CloseNormal.png */; }; - FA0CB8A7168D31EA00E36B11 /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = FA0CB8A4168D31EA00E36B11 /* CloseSelected.png */; }; - FA3FC131168D6AF400F56319 /* libPluginProtocol.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA3FC12E168D6ADD00F56319 /* libPluginProtocol.a */; }; - FA7C6D1817251CD5008A0ECC /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA7C6CF517251BEA008A0ECC /* libcocos2dx.a */; }; - FA7C6D1917251CD5008A0ECC /* libPluginFlurry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA7C6D0817251C10008A0ECC /* libPluginFlurry.a */; }; - FA7C6D1A17251CD5008A0ECC /* libPluginUmeng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA7C6D1117251C17008A0ECC /* libPluginUmeng.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - FA3FC12D168D6ADD00F56319 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = FA09A321168ADBC2008C1C7B; - remoteInfo = PluginProtocol; - }; - FA3FC12F168D6AEB00F56319 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = FA09A320168ADBC2008C1C7B; - remoteInfo = PluginProtocol; - }; - FA7C6CF417251BEA008A0ECC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 1551A33F158F2AB200E66CFE; - remoteInfo = cocos2dx; - }; - FA7C6D0717251C10008A0ECC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = FA09A372168AFD41008C1C7B; - remoteInfo = PluginFlurry; - }; - FA7C6D1017251C17008A0ECC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = FA09A301168ADAEC008C1C7B; - remoteInfo = PluginUmeng; - }; - FA7C6D1217251C30008A0ECC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = FA09A371168AFD41008C1C7B; - remoteInfo = PluginFlurry; - }; - FA7C6D1417251C30008A0ECC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = FA09A300168ADAEC008C1C7B; - remoteInfo = PluginUmeng; - }; - FA7C6D1617251C30008A0ECC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 1551A33E158F2AB200E66CFE; - remoteInfo = cocos2dx; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 1D6058910D05DD3D006BFB54 /* HelloAnalytics.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloAnalytics.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; - 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 781C33B11547F06B00633F88 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; - 781C33B31547F06B00633F88 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; - 781C33B51547F06B00633F88 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; - BF137426128A8E4600D9F789 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - BF365AA612A103F70050DCF4 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; - BF365AA712A103F70050DCF4 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; - BF492B6912891AC600A09262 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; - BF492C21128924A800A09262 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; - BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; - BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; - BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; - D446FD78161028E9000ADA7B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = ../proj.ios/Default.png; sourceTree = ""; }; - D446FD7A161028ED000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../proj.ios/Default@2x.png"; sourceTree = ""; }; - D446FD7C161028F4000ADA7B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../proj.ios/Default-568h@2x.png"; sourceTree = ""; }; - D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - D4EF94E715BD319200D803EB /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "../proj.ios/Icon-57.png"; sourceTree = ""; }; - D4EF94E915BD319500D803EB /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-114.png"; path = "../proj.ios/Icon-114.png"; sourceTree = ""; }; - D4EF94EB15BD319B00D803EB /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "../proj.ios/Icon-72.png"; sourceTree = ""; }; - D4EF94ED15BD319D00D803EB /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "../proj.ios/Icon-144.png"; sourceTree = ""; }; - FA0CB873168D2F5400E36B11 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; - FA0CB874168D2F5400E36B11 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - FA0CB875168D2F5400E36B11 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HelloWorldScene.cpp; sourceTree = ""; }; - FA0CB876168D2F5400E36B11 /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloWorldScene.h; sourceTree = ""; }; - FA0CB87D168D2FB200E36B11 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - FA0CB8A3168D31EA00E36B11 /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = ""; }; - FA0CB8A4168D31EA00E36B11 /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = ""; }; - FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginProtocol.xcodeproj; path = ../../../protocols/proj.ios/PluginProtocol.xcodeproj; sourceTree = ""; }; - FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; - FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginFlurry.xcodeproj; path = ../../../plugins/flurry/proj.ios/PluginFlurry.xcodeproj; sourceTree = ""; }; - FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginUmeng.xcodeproj; path = ../../../plugins/umeng/proj.ios/PluginUmeng.xcodeproj; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - FA7C6D1817251CD5008A0ECC /* libcocos2dx.a in Frameworks */, - FA7C6D1917251CD5008A0ECC /* libPluginFlurry.a in Frameworks */, - FA7C6D1A17251CD5008A0ECC /* libPluginUmeng.a in Frameworks */, - FA3FC131168D6AF400F56319 /* libPluginProtocol.a in Frameworks */, - FA0CB87E168D2FB200E36B11 /* SystemConfiguration.framework in Frameworks */, - 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, - 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, - 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, - BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */, - BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */, - BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */, - BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 19C28FACFE9D520D11CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 1D6058910D05DD3D006BFB54 /* HelloAnalytics.app */, - ); - name = Products; - sourceTree = ""; - }; - 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { - isa = PBXGroup; - children = ( - FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */, - FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */, - FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */, - FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */, - FA0CB872168D2F5400E36B11 /* Classes */, - 29B97323FDCFA39411CA2CEA /* Frameworks */, - BF5681CC1313A84D0055EEAC /* ios */, - 19C28FACFE9D520D11CA2CBB /* Products */, - 784521C214EBA449009D533B /* Resources */, - ); - name = CustomTemplate; - sourceTree = ""; - }; - 29B97323FDCFA39411CA2CEA /* Frameworks */ = { - isa = PBXGroup; - children = ( - FA0CB87D168D2FB200E36B11 /* SystemConfiguration.framework */, - BF492B6912891AC600A09262 /* libz.dylib */, - BF137426128A8E4600D9F789 /* QuartzCore.framework */, - BF492D4B1289302400A09262 /* OpenGLES.framework */, - BF492C21128924A800A09262 /* libxml2.dylib */, - 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, - 1D30AB110D05D00D00671497 /* Foundation.framework */, - 288765A40DF7441C002DB57D /* CoreGraphics.framework */, - 781C33B11547F06B00633F88 /* OpenAL.framework */, - 781C33B31547F06B00633F88 /* AudioToolbox.framework */, - 781C33B51547F06B00633F88 /* AVFoundation.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - 784521C214EBA449009D533B /* Resources */ = { - isa = PBXGroup; - children = ( - FA0CB8A3168D31EA00E36B11 /* CloseNormal.png */, - FA0CB8A4168D31EA00E36B11 /* CloseSelected.png */, - D4EF94ED15BD319D00D803EB /* Icon-144.png */, - D4EF94EB15BD319B00D803EB /* Icon-72.png */, - D4EF94E915BD319500D803EB /* Icon-114.png */, - D4EF94E715BD319200D803EB /* Icon-57.png */, - D446FD7C161028F4000ADA7B /* Default-568h@2x.png */, - D446FD7A161028ED000ADA7B /* Default@2x.png */, - D446FD78161028E9000ADA7B /* Default.png */, - ); - name = Resources; - path = ../Resources; - sourceTree = ""; - }; - BF5681CC1313A84D0055EEAC /* ios */ = { - isa = PBXGroup; - children = ( - D4ABB4B213B4395300552E6E /* main.m */, - BF365AA612A103F70050DCF4 /* AppController.h */, - BF365AA712A103F70050DCF4 /* AppController.mm */, - BF4DE6AB138BB89600CF907D /* RootViewController.h */, - BF4DE6AC138BB89600CF907D /* RootViewController.mm */, - ); - name = ios; - sourceTree = ""; - }; - FA0CB872168D2F5400E36B11 /* Classes */ = { - isa = PBXGroup; - children = ( - FA0CB873168D2F5400E36B11 /* AppDelegate.cpp */, - FA0CB874168D2F5400E36B11 /* AppDelegate.h */, - FA0CB875168D2F5400E36B11 /* HelloWorldScene.cpp */, - FA0CB876168D2F5400E36B11 /* HelloWorldScene.h */, - ); - name = Classes; - path = ../Classes; - sourceTree = ""; - }; - FA3FC127168D6ADC00F56319 /* Products */ = { - isa = PBXGroup; - children = ( - FA3FC12E168D6ADD00F56319 /* libPluginProtocol.a */, - ); - name = Products; - sourceTree = ""; - }; - FA7C6CEE17251BEA008A0ECC /* Products */ = { - isa = PBXGroup; - children = ( - FA7C6CF517251BEA008A0ECC /* libcocos2dx.a */, - ); - name = Products; - sourceTree = ""; - }; - FA7C6D0117251C10008A0ECC /* Products */ = { - isa = PBXGroup; - children = ( - FA7C6D0817251C10008A0ECC /* libPluginFlurry.a */, - ); - name = Products; - sourceTree = ""; - }; - FA7C6D0A17251C16008A0ECC /* Products */ = { - isa = PBXGroup; - children = ( - FA7C6D1117251C17008A0ECC /* libPluginUmeng.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 1D6058900D05DD3D006BFB54 /* HelloAnalytics */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloAnalytics" */; - buildPhases = ( - 1D60588D0D05DD3D006BFB54 /* Resources */, - 1D60588E0D05DD3D006BFB54 /* Sources */, - 1D60588F0D05DD3D006BFB54 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - FA7C6D1317251C30008A0ECC /* PBXTargetDependency */, - FA7C6D1517251C30008A0ECC /* PBXTargetDependency */, - FA7C6D1717251C30008A0ECC /* PBXTargetDependency */, - FA3FC130168D6AEB00F56319 /* PBXTargetDependency */, - ); - name = HelloAnalytics; - productName = HelloWorld; - productReference = 1D6058910D05DD3D006BFB54 /* HelloAnalytics.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 29B97313FDCFA39411CA2CEA /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0450; - }; - buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloAnalytics" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = FA7C6CEE17251BEA008A0ECC /* Products */; - ProjectRef = FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */; - }, - { - ProductGroup = FA7C6D0117251C10008A0ECC /* Products */; - ProjectRef = FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */; - }, - { - ProductGroup = FA3FC127168D6ADC00F56319 /* Products */; - ProjectRef = FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */; - }, - { - ProductGroup = FA7C6D0A17251C16008A0ECC /* Products */; - ProjectRef = FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 1D6058900D05DD3D006BFB54 /* HelloAnalytics */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - FA3FC12E168D6ADD00F56319 /* libPluginProtocol.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libPluginProtocol.a; - remoteRef = FA3FC12D168D6ADD00F56319 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - FA7C6CF517251BEA008A0ECC /* libcocos2dx.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libcocos2dx.a; - remoteRef = FA7C6CF417251BEA008A0ECC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - FA7C6D0817251C10008A0ECC /* libPluginFlurry.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libPluginFlurry.a; - remoteRef = FA7C6D0717251C10008A0ECC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - FA7C6D1117251C17008A0ECC /* libPluginUmeng.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libPluginUmeng.a; - remoteRef = FA7C6D1017251C17008A0ECC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXResourcesBuildPhase section */ - 1D60588D0D05DD3D006BFB54 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D4EF94E815BD319200D803EB /* Icon-57.png in Resources */, - D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */, - D4EF94EC15BD319B00D803EB /* Icon-72.png in Resources */, - D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */, - D446FD79161028E9000ADA7B /* Default.png in Resources */, - D446FD7B161028ED000ADA7B /* Default@2x.png in Resources */, - D446FD7D161028F4000ADA7B /* Default-568h@2x.png in Resources */, - FA0CB8A6168D31EA00E36B11 /* CloseNormal.png in Resources */, - FA0CB8A7168D31EA00E36B11 /* CloseSelected.png in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 1D60588E0D05DD3D006BFB54 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BF365AA812A103F70050DCF4 /* AppController.mm in Sources */, - BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */, - D4ABB4B313B4395300552E6E /* main.m in Sources */, - FA0CB877168D2F5400E36B11 /* AppDelegate.cpp in Sources */, - FA0CB878168D2F5400E36B11 /* HelloWorldScene.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - FA3FC130168D6AEB00F56319 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = PluginProtocol; - targetProxy = FA3FC12F168D6AEB00F56319 /* PBXContainerItemProxy */; - }; - FA7C6D1317251C30008A0ECC /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = PluginFlurry; - targetProxy = FA7C6D1217251C30008A0ECC /* PBXContainerItemProxy */; - }; - FA7C6D1517251C30008A0ECC /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = PluginUmeng; - targetProxy = FA7C6D1417251C30008A0ECC /* PBXContainerItemProxy */; - }; - FA7C6D1717251C30008A0ECC /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = cocos2dx; - targetProxy = FA7C6D1617251C30008A0ECC /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 1D6058940D05DD3E006BFB54 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = HelloAnalytics_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - USE_FILE32API, - CC_TARGET_OS_IPHONE, - "COCOS2D_DEBUG=1", - ); - GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_VERSION = ""; - HEADER_SEARCH_PATHS = ( - "\"$(SDKROOT)/usr/include/libxml2/\"", - "\"$(SRCROOT)/../../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../../cocos2dx\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/ios\"", - "\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../../external/chipmunk/include/chipmunk\"", - "\"$(SRCROOT)/../../../protocols/include\"", - "\"$(SRCROOT)/../../../plugins/flurry/include\"", - "\"$(SRCROOT)/../../../plugins/umeng/include\"", - ); - INFOPLIST_FILE = "HelloAnalytics-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/../../../plugins/flurry/platform/ios\"", - "\"$(SRCROOT)/../../../plugins/umeng/platform/ios\"", - ); - "OTHER_LDFLAGS[arch=*]" = "-ObjC"; - PRODUCT_NAME = HelloAnalytics; - PROVISIONING_PROFILE = ""; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALID_ARCHS = "armv6 armv7 i386"; - }; - name = Debug; - }; - 1D6058950D05DD3E006BFB54 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = YES; - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = HelloAnalytics_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - USE_FILE32API, - CC_TARGET_OS_IPHONE, - ); - GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_VERSION = ""; - HEADER_SEARCH_PATHS = ( - "\"$(SDKROOT)/usr/include/libxml2/\"", - "\"$(SRCROOT)/../../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../../cocos2dx\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/ios\"", - "\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../../external/chipmunk/include/chipmunk\"", - "\"$(SRCROOT)/../../../protocols/include\"", - "\"$(SRCROOT)/../../../plugins/flurry/include\"", - "\"$(SRCROOT)/../../../plugins/umeng/include\"", - ); - INFOPLIST_FILE = "HelloAnalytics-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/../../../plugins/flurry/platform/ios\"", - "\"$(SRCROOT)/../../../plugins/umeng/platform/ios\"", - ); - "OTHER_LDFLAGS[arch=*]" = "-ObjC"; - PRODUCT_NAME = HelloAnalytics; - PROVISIONING_PROFILE = ""; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VALID_ARCHS = "armv6 armv7 i386"; - }; - name = Release; - }; - C01FCF4F08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CLANG_CXX_LIBRARY = "libc++"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_VERSION = ""; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - "INFOPLIST_PREFIX_HEADER[sdk=*]" = ""; - SDKROOT = iphoneos; - VALID_ARCHS = "armv6 armv7 i386"; - }; - name = Debug; - }; - C01FCF5008A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CLANG_CXX_LIBRARY = "libc++"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_VERSION = ""; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - SDKROOT = iphoneos; - VALID_ARCHS = "armv6 armv7 i386"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloAnalytics" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1D6058940D05DD3E006BFB54 /* Debug */, - 1D6058950D05DD3E006BFB54 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloAnalytics" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4F08A954540054247B /* Debug */, - C01FCF5008A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; -} diff --git a/plugin/samples/HelloAnalytics/proj.ios/HelloAnalytics_Prefix.pch b/plugin/samples/HelloAnalytics/proj.ios/HelloAnalytics_Prefix.pch deleted file mode 100755 index b8914281d2..0000000000 --- a/plugin/samples/HelloAnalytics/proj.ios/HelloAnalytics_Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the 'HelloWorld' target in the 'HelloWorld' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/plugin/samples/HelloAnalytics/proj.ios/RootViewController.mm b/plugin/samples/HelloAnalytics/proj.ios/RootViewController.mm deleted file mode 100755 index ae2156e3f0..0000000000 --- a/plugin/samples/HelloAnalytics/proj.ios/RootViewController.mm +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org - Copyright (c) 2010 Ricardo Quesada - - 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. - ****************************************************************************/ - -#import "RootViewController.h" - - -@implementation RootViewController - -/* - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { - // Custom initialization - } - return self; -} -*/ - -/* -// Implement loadView to create a view hierarchy programmatically, without using a nib. -- (void)loadView { -} -*/ - -/* -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad { - [super viewDidLoad]; -} - -*/ -// Override to allow orientations other than the default portrait orientation. -// This method is deprecated on ios6 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsPortrait( interfaceOrientation ); -} - -// For ios6.0 and higher, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations -{ -#ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskAllButUpsideDown; -#endif -} - -- (BOOL) shouldAutorotate { - return YES; -} - - - - -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end diff --git a/plugin/samples/HelloAnalytics/proj.ios/main.m b/plugin/samples/HelloAnalytics/proj.ios/main.m deleted file mode 100755 index bd2771a33d..0000000000 --- a/plugin/samples/HelloAnalytics/proj.ios/main.m +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ - -#import - -int main(int argc, char *argv[]) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); - [pool release]; - return retVal; -} diff --git a/plugin/samples/HelloIAP/Classes/AppDelegate.cpp b/plugin/samples/HelloIAP/Classes/AppDelegate.cpp deleted file mode 100644 index abbe0d4951..0000000000 --- a/plugin/samples/HelloIAP/Classes/AppDelegate.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ -#include "AppDelegate.h" -#include "cocos2d.h" -#include "HelloWorldScene.h" -#include "PluginManager.h" -#include "MyPurchase.h" - -using namespace cocos2d::plugin; -USING_NS_CC; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ - -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - MyPurchase::sharedPurchase()->loadIAPPlugin(); - - // initialize director - Director *pDirector = Director::sharedDirector(); - pDirector->setOpenGLView(EGLView::sharedOpenGLView()); - EGLView* pEGLView = EGLView::sharedOpenGLView(); - pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder); - // turn on display FPS - pDirector->setDisplayStats(true); - - // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); - - // create a scene. it's an autorelease object - Scene *pScene = HelloWorld::scene(); - - // run - pDirector->runWithScene(pScene); - - return true; -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() -{ - Director::sharedDirector()->pause(); - - // if you use SimpleAudioEngine, it must be pause - // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - Director::sharedDirector()->resume(); - - // if you use SimpleAudioEngine, it must resume here - // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -} diff --git a/plugin/samples/HelloIAP/Classes/AppDelegate.h b/plugin/samples/HelloIAP/Classes/AppDelegate.h deleted file mode 100644 index 946b4fca90..0000000000 --- a/plugin/samples/HelloIAP/Classes/AppDelegate.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ -#ifndef _APP_DELEGATE_H_ -#define _APP_DELEGATE_H_ - -#include "CCApplication.h" - -/** -@brief The cocos2d Application. - -The reason for implement as private inheritance is to hide some interface call by Director. -*/ -class AppDelegate : private cocos2d::Application -{ -public: - AppDelegate(); - virtual ~AppDelegate(); - - /** - @brief Implement Director and Scene init code here. - @return true Initialize success, app continue. - @return false Initialize failed, app terminate. - */ - virtual bool applicationDidFinishLaunching(); - - /** - @brief The function be called when the application enter background - @param the pointer of the application - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function be called when the application enter foreground - @param the pointer of the application - */ - virtual void applicationWillEnterForeground(); - - static void loadAnalyticsPlugin(); -}; - -#endif // _APP_DELEGATE_H_ diff --git a/plugin/samples/HelloIAP/Resources/alipay_plugin.apk.REMOVED.git-id b/plugin/samples/HelloIAP/Resources/alipay_plugin.apk.REMOVED.git-id deleted file mode 100644 index e7115f0d77..0000000000 --- a/plugin/samples/HelloIAP/Resources/alipay_plugin.apk.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -db46ceaf2554c8d9e48cdaec3a4cdf5519bb8896 \ No newline at end of file diff --git a/plugin/samples/HelloIAP/Resources/background.png.REMOVED.git-id b/plugin/samples/HelloIAP/Resources/background.png.REMOVED.git-id deleted file mode 100644 index 15b10523a1..0000000000 --- a/plugin/samples/HelloIAP/Resources/background.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -b2e4ae6ce873ef4a74cf0230693ef26e939d2778 \ No newline at end of file diff --git a/plugin/samples/HelloIAP/proj.android/.classpath b/plugin/samples/HelloIAP/proj.android/.classpath deleted file mode 100644 index 2519c88ef3..0000000000 --- a/plugin/samples/HelloIAP/proj.android/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/plugin/samples/HelloIAP/proj.android/.project b/plugin/samples/HelloIAP/proj.android/.project deleted file mode 100644 index 7bae797dfe..0000000000 --- a/plugin/samples/HelloIAP/proj.android/.project +++ /dev/null @@ -1,45 +0,0 @@ - - - HelloIAP - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - publish - 2 - PARENT-3-PROJECT_LOC/publish - - - diff --git a/plugin/samples/HelloIAP/proj.android/AndroidManifest.xml b/plugin/samples/HelloIAP/proj.android/AndroidManifest.xml deleted file mode 100644 index 0c9510d06c..0000000000 --- a/plugin/samples/HelloIAP/proj.android/AndroidManifest.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloIAP/proj.android/ant.properties b/plugin/samples/HelloIAP/proj.android/ant.properties deleted file mode 100644 index b0971e891e..0000000000 --- a/plugin/samples/HelloIAP/proj.android/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/plugin/samples/HelloIAP/proj.android/build.xml b/plugin/samples/HelloIAP/proj.android/build.xml deleted file mode 100644 index 80abad0ab0..0000000000 --- a/plugin/samples/HelloIAP/proj.android/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloIAP/proj.android/build_native.sh b/plugin/samples/HelloIAP/proj.android/build_native.sh deleted file mode 100755 index 7b388a1442..0000000000 --- a/plugin/samples/HelloIAP/proj.android/build_native.sh +++ /dev/null @@ -1,81 +0,0 @@ -APPNAME="HelloAnalytics" - -# options - -buildexternalsfromsource= - -usage(){ -cat << EOF -usage: $0 [options] - -Build C/C++ code for $APPNAME using Android NDK - -OPTIONS: --s Build externals from source --h this help -EOF -} - -while getopts "sh" OPTION; do -case "$OPTION" in -s) -buildexternalsfromsource=1 -;; -h) -usage -exit 0 -;; -esac -done - -# paths - -if [ -z "${NDK_ROOT+aaa}" ];then -echo "please define NDK_ROOT" -exit 1 -fi - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# ... use paths relative to current directory -PLUGIN_ROOT="$DIR/../../.." -COCOS2DX_ROOT="$DIR/../../../.." -APP_ROOT="$DIR/.." -APP_ANDROID_ROOT="$DIR" - -echo "PLUGIN_ROOT = $PLUGIN_ROOT" -echo "NDK_ROOT = $NDK_ROOT" -echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" -echo "APP_ROOT = $APP_ROOT" -echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" -echo "---------------------------------------------------------" - -# make sure assets is exist -if [ -d "$APP_ANDROID_ROOT"/assets ]; then - rm -rf "$APP_ANDROID_ROOT"/assets -fi - -mkdir "$APP_ANDROID_ROOT"/assets - -# copy resources -for file in "$APP_ROOT"/Resources/* -do -if [ -d "$file" ]; then - cp -rf "$file" "$APP_ANDROID_ROOT"/assets -fi - -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/assets -fi -done - -if [[ "$buildexternalsfromsource" ]]; then - echo "Building external dependencies from source" - set -x - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" -else - echo "Using prebuilt externals" - set -x - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" -fi diff --git a/plugin/samples/HelloIAP/proj.android/jni/Android.mk b/plugin/samples/HelloIAP/proj.android/jni/Android.mk deleted file mode 100644 index a51de9683d..0000000000 --- a/plugin/samples/HelloIAP/proj.android/jni/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := game_shared - -LOCAL_MODULE_FILENAME := libgame - -LOCAL_SRC_FILES := hellocpp/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp \ - ../../Classes/MyPurchase.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \ - PluginProtocolStatic - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) \ -$(call import-module,protocols/android) diff --git a/plugin/samples/HelloIAP/proj.android/jni/Application.mk b/plugin/samples/HelloIAP/proj.android/jni/Application.mk deleted file mode 100644 index 488132832e..0000000000 --- a/plugin/samples/HelloIAP/proj.android/jni/Application.mk +++ /dev/null @@ -1,3 +0,0 @@ -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -std=c++11 -NDK_TOOLCHAIN_VERSION=4.7 diff --git a/plugin/samples/HelloIAP/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloIAP/proj.android/jni/hellocpp/main.cpp deleted file mode 100644 index dc875f6427..0000000000 --- a/plugin/samples/HelloIAP/proj.android/jni/hellocpp/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ -#include "AppDelegate.h" -#include "platform/android/jni/JniHelper.h" -#include "PluginJniHelper.h" -#include -#include - -#include "HelloWorldScene.h" - -#define LOG_TAG "main" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) - -using namespace cocos2d; - -extern "C" -{ - -jint JNI_OnLoad(JavaVM *vm, void *reserved) -{ - JniHelper::setJavaVM(vm); - PluginJniHelper::setJavaVM(vm); - - return JNI_VERSION_1_4; -} - -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) -{ - if (!Director::sharedDirector()->getOpenGLView()) - { - EGLView *view = EGLView::sharedOpenGLView(); - view->setFrameSize(w, h); - - AppDelegate *pAppDelegate = new AppDelegate(); - Application::sharedApplication()->run(); - } - else - { - ccDrawInit(); - ccGLInvalidateStateCache(); - - ShaderCache::sharedShaderCache()->reloadDefaultShaders(); - TextureCache::reloadAllTextures(); - NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); - Director::sharedDirector()->setGLDefaultValues(); - } -} - -} diff --git a/plugin/samples/HelloIAP/proj.android/proguard-project.txt b/plugin/samples/HelloIAP/proj.android/proguard-project.txt deleted file mode 100644 index b60ae7ea07..0000000000 --- a/plugin/samples/HelloIAP/proj.android/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/plugin/samples/HelloIAP/proj.android/project.properties b/plugin/samples/HelloIAP/proj.android/project.properties deleted file mode 100644 index f6ee30d13d..0000000000 --- a/plugin/samples/HelloIAP/proj.android/project.properties +++ /dev/null @@ -1,16 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java -android.library.reference.2=../../../publish/plugins/nd91/android/DependProject diff --git a/plugin/samples/HelloIAP/proj.android/res/values/strings.xml b/plugin/samples/HelloIAP/proj.android/res/values/strings.xml deleted file mode 100644 index 1827f14e1a..0000000000 --- a/plugin/samples/HelloIAP/proj.android/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - HelloIAP - diff --git a/plugin/samples/HelloUser/Classes/AppDelegate.cpp b/plugin/samples/HelloPlugins/Classes/AppDelegate.cpp similarity index 94% rename from plugin/samples/HelloUser/Classes/AppDelegate.cpp rename to plugin/samples/HelloPlugins/Classes/AppDelegate.cpp index d48938c82b..a2dd2e6d34 100644 --- a/plugin/samples/HelloUser/Classes/AppDelegate.cpp +++ b/plugin/samples/HelloPlugins/Classes/AppDelegate.cpp @@ -1,6 +1,5 @@ #include "AppDelegate.h" #include "HelloWorldScene.h" -#include "MyUserManager.h" USING_NS_CC; @@ -13,8 +12,6 @@ AppDelegate::~AppDelegate() } bool AppDelegate::applicationDidFinishLaunching() { - MyUserManager::sharedManager()->loadPlugin(); - // initialize director Director* pDirector = Director::sharedDirector(); EGLView* pEGLView = EGLView::sharedOpenGLView(); @@ -22,6 +19,7 @@ bool AppDelegate::applicationDidFinishLaunching() { pDirector->setOpenGLView(pEGLView); pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder); + // turn on display FPS pDirector->setDisplayStats(true); diff --git a/plugin/samples/HelloUser/Classes/AppDelegate.h b/plugin/samples/HelloPlugins/Classes/AppDelegate.h similarity index 100% rename from plugin/samples/HelloUser/Classes/AppDelegate.h rename to plugin/samples/HelloPlugins/Classes/AppDelegate.h diff --git a/plugin/samples/HelloPlugins/Classes/HelloWorldScene.cpp b/plugin/samples/HelloPlugins/Classes/HelloWorldScene.cpp new file mode 100644 index 0000000000..f698bbe745 --- /dev/null +++ b/plugin/samples/HelloPlugins/Classes/HelloWorldScene.cpp @@ -0,0 +1,115 @@ +#include "HelloWorldScene.h" +#include "TestAdsScene.h" +#include "TestAnalyticsScene.h" +#include "TestShareScene.h" +#include "TestIAPScene.h" +#include "TestUserScene.h" + +USING_NS_CC; + +std::string g_testCases[] = { + "Test Ads", + "Test Analytics", + "Test Share", +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + "Test IAP", + "Test User", +#endif +}; + +Scene* HelloWorld::scene() +{ + // 'scene' is an autorelease object + Scene *scene = Scene::create(); + + // 'layer' is an autorelease object + HelloWorld *layer = HelloWorld::create(); + + // add layer as a child to scene + scene->addChild(layer); + + // return the scene + return scene; +} + +// on "init" you need to initialize your instance +bool HelloWorld::init() +{ + ////////////////////////////// + // 1. super init first + if ( !Layer::init() ) + { + return false; + } + + Size visibleSize = Director::sharedDirector()->getVisibleSize(); + Point origin = Director::sharedDirector()->getVisibleOrigin(); + + ///////////////////////////// + // 2. add a menu item with "X" image, which is clicked to quit the program + // you may modify it. + + // add a "close" icon to exit the progress. it's an autorelease object + MenuItemImage *pCloseItem = MenuItemImage::create( + "CloseNormal.png", + "CloseSelected.png", + CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); + + pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 , + origin.y + pCloseItem->getContentSize().height/2)); + + // create menu, it's an autorelease object + Menu* pMenu = Menu::create(pCloseItem, NULL); + pMenu->setPosition(PointZero); + this->addChild(pMenu, 1); + + Point beginPos = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - 50); + float step = 60.0f; + int nCaseCount = sizeof(g_testCases) / sizeof(std::string); + for (int i = 0; i < nCaseCount; ++i) { + std::string caseName = g_testCases[i]; + MenuItemFont *pItem = MenuItemFont::create(caseName.c_str(), CC_CALLBACK_1(HelloWorld::menuCallback, this)); + pItem->setTag(i); + pItem->setPosition(ccp(beginPos.x, beginPos.y - i * step)); + pMenu->addChild(pItem); + } + return true; +} + +void HelloWorld::menuCallback(Object* pSender) +{ + MenuItemFont *pItem = (MenuItemFont*) pSender; + Scene* newScene = NULL; + switch (pItem->getTag()) { + case 0: + newScene = TestAds::scene(); + break; + case 1: + newScene = TestAnalytics::scene(); + break; + case 2: + newScene = TestShare::scene(); + break; + case 3: + newScene = TestIAP::scene(); + break; + case 4: + newScene = TestUser::scene(); + break; + default: + break; + } + + if (newScene) { + Director::sharedDirector()->replaceScene(newScene); + } +} + +void HelloWorld::menuCloseCallback(Object* pSender) +{ + Director::sharedDirector()->end(); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + exit(0); +#endif +} diff --git a/plugin/samples/HelloUser/Classes/HelloWorldScene.h b/plugin/samples/HelloPlugins/Classes/HelloWorldScene.h similarity index 76% rename from plugin/samples/HelloUser/Classes/HelloWorldScene.h rename to plugin/samples/HelloPlugins/Classes/HelloWorldScene.h index 948b144d61..8171df0f4c 100644 --- a/plugin/samples/HelloUser/Classes/HelloWorldScene.h +++ b/plugin/samples/HelloPlugins/Classes/HelloWorldScene.h @@ -14,17 +14,10 @@ public: // a selector callback void menuCloseCallback(Object* pSender); - void testLogin(Object* pSender); - void testLogout(Object* pSender); + void menuCallback(Object* pSender); - void caseChanged(Object* pSender); - // implement the "static node()" method manually CREATE_FUNC(HelloWorld); - -private: - cocos2d::MenuItemToggle* _caseItem; - int _selectedCase; }; #endif // __HELLOWORLD_SCENE_H__ diff --git a/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp similarity index 81% rename from plugin/samples/HelloAds/Classes/HelloWorldScene.cpp rename to plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp index f3a8f4e261..f0edf50bf4 100644 --- a/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp @@ -21,8 +21,9 @@ 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 "HelloWorldScene.h" +#include "TestAdsScene.h" #include "PluginManager.h" +#include "HelloWorldScene.h" USING_NS_CC; using namespace cocos2d::plugin; @@ -47,13 +48,13 @@ const std::string s_aTestPoses[] = { "Pos: BottomRight", }; -Scene* HelloWorld::scene() +Scene* TestAds::scene() { // 'scene' is an autorelease object Scene *scene = Scene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::create(); + TestAds *layer = TestAds::create(); // add layer as a child to scene scene->addChild(layer); @@ -63,7 +64,7 @@ Scene* HelloWorld::scene() } // on "init" you need to initialize your instance -bool HelloWorld::init() +bool TestAds::init() { ////////////////////////////// // 1. super init first @@ -89,39 +90,36 @@ bool HelloWorld::init() Size visibleSize = Director::sharedDirector()->getVisibleSize(); Point origin = Director::sharedDirector()->getVisibleOrigin(); Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); + Point posBR = ccp(origin.x + visibleSize.width, origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *pCloseItem = MenuItemImage::create( - "CloseNormal.png", - "CloseSelected.png", - CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - - pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 , - origin.y + pCloseItem->getContentSize().height/2)); + MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAds::menuBackCallback, this)); + Size backSize = pBackItem->getContentSize(); + pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); - pMenu->setPosition(PointZero); + Menu* pMenu = Menu::create(pBackItem, NULL); + pMenu->setPosition( PointZero ); LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24); - MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(HelloWorld::testShow, this)); + MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this)); pItemShow->setAnchorPoint(ccp(0.5f, 0)); pMenu->addChild(pItemShow, 0); pItemShow->setPosition(ccpAdd(posMid, ccp(-100, -120))); LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24); - MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(HelloWorld::testHide, this)); + MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(TestAds::testHide, this)); pItemHide->setAnchorPoint(ccp(0.5f, 0)); pMenu->addChild(pItemHide, 0); pItemHide->setPosition(ccpAdd(posMid, ccp(100, -120))); // create optional menu // cases item - _caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::caseChanged, this), + _caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::caseChanged, this), MenuItemFont::create( s_aTestCases[0].c_str() ), NULL ); int caseLen = sizeof(s_aTestCases) / sizeof(std::string); @@ -133,7 +131,7 @@ bool HelloWorld::init() pMenu->addChild(_caseItem); // type item - _typeItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::typeChanged, this), + _typeItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::typeChanged, this), MenuItemFont::create( s_aTestTypes[0].c_str() ), NULL ); int typeLen = sizeof(s_aTestTypes) / sizeof(std::string); @@ -145,7 +143,7 @@ bool HelloWorld::init() pMenu->addChild(_typeItem); // poses item - _posItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::posChanged, this), + _posItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::posChanged, this), MenuItemFont::create( s_aTestPoses[0].c_str() ), NULL ); int posLen = sizeof(s_aTestPoses) / sizeof(std::string); @@ -166,7 +164,7 @@ bool HelloWorld::init() return true; } -void HelloWorld::testShow(Object* pSender) +void TestAds::testShow(Object* pSender) { int nSize = 0; if (_ads == _admob) @@ -180,17 +178,18 @@ void HelloWorld::testShow(Object* pSender) } } -void HelloWorld::testHide(Object* pSender) +void TestAds::testHide(Object* pSender) { _ads->hideAds(_type); } -void HelloWorld::menuCloseCallback(Object* pSender) +void TestAds::menuBackCallback(Object* pSender) { - Director::sharedDirector()->end(); - if (_admob != NULL) { + _admob->hideAds(ProtocolAds::kBannerAd); + _admob->hideAds(ProtocolAds::kFullScreenAd); + _admob->hideAds(ProtocolAds::kMoreApp); PluginManager::getInstance()->unloadPlugin("AdsAdmob"); _admob = NULL; } @@ -201,13 +200,11 @@ void HelloWorld::menuCloseCallback(Object* pSender) _listener = NULL; } - PluginManager::end(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif + Scene* newScene = HelloWorld::scene(); + Director::sharedDirector()->replaceScene(newScene); } -void HelloWorld::caseChanged(Object* pSender) +void TestAds::caseChanged(Object* pSender) { std::string strLog = ""; switch (_caseItem->getSelectedIndex()) @@ -222,14 +219,14 @@ void HelloWorld::caseChanged(Object* pSender) CCLog("case selected change to : %s", strLog.c_str()); } -void HelloWorld::typeChanged(Object* pSender) +void TestAds::typeChanged(Object* pSender) { int selectIndex = _typeItem->getSelectedIndex(); _type = (ProtocolAds::AdsType) selectIndex; CCLog("type selected change to : %d", _type); } -void HelloWorld::posChanged(Object* pSender) +void TestAds::posChanged(Object* pSender) { int selectIndex = _posItem->getSelectedIndex(); _pos = (ProtocolAds::AdsPos) selectIndex; diff --git a/plugin/samples/HelloAds/Classes/HelloWorldScene.h b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.h similarity index 92% rename from plugin/samples/HelloAds/Classes/HelloWorldScene.h rename to plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.h index 416fba523f..ab3e8af0b5 100644 --- a/plugin/samples/HelloAds/Classes/HelloWorldScene.h +++ b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.h @@ -21,8 +21,8 @@ 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 __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ +#ifndef __TEST_ADS_SCENE_H__ +#define __TEST_ADS_SCENE_H__ #include "cocos2d.h" #include "ProtocolAds.h" @@ -34,7 +34,7 @@ public: virtual void onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points); }; -class HelloWorld : public cocos2d::Layer +class TestAds : public cocos2d::Layer { public: // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone @@ -44,7 +44,7 @@ public: static cocos2d::Scene* scene(); // a selector callback - void menuCloseCallback(Object* pSender); + void menuBackCallback(Object* pSender); void testShow(Object* pSender); void testHide(Object* pSender); @@ -54,7 +54,7 @@ public: void typeChanged(Object* pSender); // implement the "static node()" method manually - CREATE_FUNC(HelloWorld); + CREATE_FUNC(TestAds); private: cocos2d::plugin::ProtocolAds* _admob; @@ -69,4 +69,4 @@ private: cocos2d::plugin::ProtocolAds::AdsType _type; }; -#endif // __HELLOWORLD_SCENE_H__ +#endif // __TEST_ADS_SCENE_H__ diff --git a/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp similarity index 51% rename from plugin/samples/HelloAnalytics/Classes/HelloWorldScene.cpp rename to plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp index 63340d0f8f..817e193eb3 100644 --- a/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp @@ -21,16 +21,18 @@ 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 "HelloWorldScene.h" +#include "TestAnalyticsScene.h" #include "PluginManager.h" -#include "ProtocolAnalytics.h" -#include "AppDelegate.h" +#include "HelloWorldScene.h" using namespace cocos2d; using namespace cocos2d::plugin; -extern ProtocolAnalytics* g_pAnalytics; -extern std::string s_strAppKey; +// The app key of flurry +#define FLURRY_KEY_IOS "KMGG7CD9WPK2TW4X9VR8" +#define FLURRY_KEY_ANDROID "SPKFH8KMPGHMMBWRBT5W" +#define UMENG_KEY_IOS "50d2b18c5270152187000097" +#define UMENG_KEY_ANDROID "" // umeng key for android is setted in AndroidManifest.xml enum { TAG_LOG_EVENT_ID = 0, @@ -57,13 +59,13 @@ static EventMenuItem s_EventMenuItem[] = { {"MakeMeCrash", TAG_MAKE_ME_CRASH} }; -Scene* HelloWorld::scene() +Scene* TestAnalytics::scene() { // 'scene' is an autorelease object Scene *scene = Scene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::create(); + TestAnalytics *layer = TestAnalytics::create(); // add layer as a child to scene scene->addChild(layer); @@ -73,7 +75,7 @@ Scene* HelloWorld::scene() } // on "init" you need to initialize your instance -bool HelloWorld::init() +bool TestAnalytics::init() { ////////////////////////////// // 1. super init first @@ -82,60 +84,53 @@ bool HelloWorld::init() return false; } - Size size = Director::sharedDirector()->getWinSize(); + _pluginAnalytics = NULL; + loadPlugins(); + + Size visibleSize = Director::sharedDirector()->getVisibleSize(); + Point origin = Director::sharedDirector()->getVisibleOrigin(); + Point posBR = ccp(origin.x + visibleSize.width, origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *pCloseItem = MenuItemImage::create( - "CloseNormal.png", - "CloseSelected.png", - this, - menu_selector(HelloWorld::menuCloseCallback) ); - pCloseItem->setPosition( ccp(size.width - 20, 20) ); + MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this)); + Size backSize = pBackItem->getContentSize(); + pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); + Menu* pMenu = Menu::create(pBackItem, NULL); pMenu->setPosition( PointZero ); this->addChild(pMenu, 1); float yPos = 0; for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { LabelTTF* label = LabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24); - MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::eventMenuCallback)); + MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this)); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); - yPos = size.height - 35*i - 100; - pMenuItem->setPosition( ccp(size.width / 2, yPos)); + yPos = visibleSize.height - 35*i - 100; + pMenuItem->setPosition( ccp(visibleSize.width / 2, yPos)); } - std::string strName = g_pAnalytics->getPluginName(); - std::string strVer = g_pAnalytics->getSDKVersion(); + std::string strName = _pluginAnalytics->getPluginName(); + std::string strVer = _pluginAnalytics->getSDKVersion(); char ret[256] = { 0 }; sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str()); - LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(size.width, 0), kTextAlignmentCenter); - pLabel->setPosition(ccp(size.width / 2, yPos - 80)); + LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(visibleSize.width, 0), kTextAlignmentCenter); + pLabel->setPosition(ccp(visibleSize.width / 2, yPos - 80)); addChild(pLabel); - LabelTTF* label = LabelTTF::create("reload all plugins", "Arial", 24); - MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback)); - pMenuItem->setAnchorPoint(ccp(0.5f, 0)); - pMenu->addChild(pMenuItem, 0); - pMenuItem->setPosition( ccp(size.width / 2, 0)); - return true; } -void HelloWorld::reloadPluginMenuCallback(Object* pSender) +void TestAnalytics::onExit() { - PluginManager::getInstance()->unloadPlugin("AnalyticsFlurry"); - PluginManager::getInstance()->unloadPlugin("AnalyticsUmeng"); - - AppDelegate::loadAnalyticsPlugin(); + unloadPlugins(); } -void HelloWorld::eventMenuCallback(Object* pSender) +void TestAnalytics::eventMenuCallback(Object* pSender) { MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender; @@ -143,8 +138,8 @@ void HelloWorld::eventMenuCallback(Object* pSender) { case TAG_LOG_EVENT_ID: { - g_pAnalytics->logEvent("click"); - g_pAnalytics->logEvent("music"); + _pluginAnalytics->logEvent("click"); + _pluginAnalytics->logEvent("music"); } break; case TAG_LOG_EVENT_ID_KV: @@ -152,25 +147,25 @@ void HelloWorld::eventMenuCallback(Object* pSender) LogEventParamMap paramMap; paramMap.insert(LogEventParamPair("type", "popular")); paramMap.insert(LogEventParamPair("artist", "JJLin")); - g_pAnalytics->logEvent("music", ¶mMap); + _pluginAnalytics->logEvent("music", ¶mMap); } break; case TAG_LOG_ONLINE_CONFIG: { PluginParam param("abc"); - CCLog("Online config = %s", g_pAnalytics->callStringFuncWithParam("getConfigParams", ¶m, NULL).c_str()); + CCLog("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", ¶m, NULL).c_str()); } break; case TAG_LOG_EVENT_ID_DURATION: { PluginParam event1("book"); PluginParam dura1(12000); - g_pAnalytics->callFuncWithParam("logEventWithDuration", &event1, &dura1, NULL); + _pluginAnalytics->callFuncWithParam("logEventWithDuration", &event1, &dura1, NULL); PluginParam event2("book"); PluginParam dura2(12000); PluginParam label("chapter1"); - g_pAnalytics->callFuncWithParam("logEventWithDurationLabel", &event2, &dura2, &label, NULL); + _pluginAnalytics->callFuncWithParam("logEventWithDurationLabel", &event2, &dura2, &label, NULL); PluginParam event3("music"); PluginParam dura3(2330000); @@ -178,16 +173,16 @@ void HelloWorld::eventMenuCallback(Object* pSender) paramMap.insert(LogEventParamPair("type", "popular")); paramMap.insert(LogEventParamPair("artist", "JJLin")); PluginParam mapValue(paramMap); - g_pAnalytics->callFuncWithParam("logEventWithDurationParams", &event3, &dura3, &mapValue, NULL); + _pluginAnalytics->callFuncWithParam("logEventWithDurationParams", &event3, &dura3, &mapValue, NULL); } break; case TAG_LOG_EVENT_BEGIN: { - g_pAnalytics->logTimedEventBegin("music"); + _pluginAnalytics->logTimedEventBegin("music"); PluginParam event1("music"); PluginParam label1("one"); - g_pAnalytics->callFuncWithParam("logTimedEventWithLabelBegin", &event1, &label1, NULL); + _pluginAnalytics->callFuncWithParam("logTimedEventWithLabelBegin", &event1, &label1, NULL); PluginParam event2("music"); PluginParam label2("flag0"); @@ -195,26 +190,26 @@ void HelloWorld::eventMenuCallback(Object* pSender) paramMap.insert(LogEventParamPair("type", "popular")); paramMap.insert(LogEventParamPair("artist", "JJLin")); PluginParam mapValue(paramMap); - g_pAnalytics->callFuncWithParam("logTimedKVEventBegin", &event2, &label2, &mapValue, NULL); + _pluginAnalytics->callFuncWithParam("logTimedKVEventBegin", &event2, &label2, &mapValue, NULL); PluginParam event3("music-kv"); - g_pAnalytics->callFuncWithParam("logTimedEventBeginWithParams", &event3, &mapValue, NULL); + _pluginAnalytics->callFuncWithParam("logTimedEventBeginWithParams", &event3, &mapValue, NULL); } break; case TAG_LOG_EVENT_END: { - g_pAnalytics->logTimedEventEnd("music"); + _pluginAnalytics->logTimedEventEnd("music"); PluginParam event1("music"); PluginParam label1("one"); - g_pAnalytics->callFuncWithParam("logTimedEventWithLabelEnd", &event1, &label1, NULL); + _pluginAnalytics->callFuncWithParam("logTimedEventWithLabelEnd", &event1, &label1, NULL); PluginParam event2("music"); PluginParam label2("flag0"); - g_pAnalytics->callFuncWithParam("logTimedKVEventEnd", &event2, &label2, NULL); + _pluginAnalytics->callFuncWithParam("logTimedKVEventEnd", &event2, &label2, NULL); PluginParam event3("music-kv"); - g_pAnalytics->callFuncWithParam("logTimedEventEnd", &event3, NULL); + _pluginAnalytics->callFuncWithParam("logTimedEventEnd", &event3, NULL); } break; case TAG_MAKE_ME_CRASH: @@ -228,14 +223,81 @@ void HelloWorld::eventMenuCallback(Object* pSender) } } -void HelloWorld::menuCloseCallback(Object* pSender) +void TestAnalytics::loadPlugins() { - if (g_pAnalytics) - g_pAnalytics->stopSession(); - - PluginManager::end(); - Director::sharedDirector()->end(); + ccLanguageType langType = Application::sharedApplication()->getCurrentLanguage(); + + std::string umengKey = ""; + std::string flurryKey = ""; + std::string pluginName = ""; + std::string strAppKey = ""; + #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); + umengKey = UMENG_KEY_IOS; + flurryKey = FLURRY_KEY_IOS; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + umengKey = UMENG_KEY_ANDROID; + flurryKey = FLURRY_KEY_ANDROID; #endif + + if (kLanguageChinese == langType) + { + pluginName = "AnalyticsUmeng"; + strAppKey = umengKey; + } + else + { + pluginName = "AnalyticsFlurry"; + strAppKey = flurryKey; + } + + _pluginAnalytics = dynamic_cast (PluginManager::getInstance()->loadPlugin(pluginName.c_str())); + + _pluginAnalytics->setDebugMode(true); + _pluginAnalytics->startSession(strAppKey.c_str()); + _pluginAnalytics->setCaptureUncaughtException(true); + _pluginAnalytics->setSessionContinueMillis(10000); + + const char* sdkVer = _pluginAnalytics->getSDKVersion().c_str(); + CCLog("SDK version : %s", sdkVer); + + _pluginAnalytics->callFuncWithParam("updateOnlineConfig", NULL); + + PluginParam pParam1(true); + _pluginAnalytics->callFuncWithParam("setReportLocation", &pParam1, NULL); + + _pluginAnalytics->callFuncWithParam("logPageView", NULL); + + PluginParam pParam2("1.1"); + _pluginAnalytics->callFuncWithParam("setVersionName", &pParam2, NULL); + + PluginParam pParam3(20); + _pluginAnalytics->callFuncWithParam("setAge", &pParam3, NULL); + + PluginParam pParam4(1); + _pluginAnalytics->callFuncWithParam("setGender", &pParam4, NULL); + + PluginParam pParam5("123456"); + _pluginAnalytics->callFuncWithParam("setUserId", &pParam5, NULL); + + PluginParam pParam6(false); + _pluginAnalytics->callFuncWithParam("setUseHttps", &pParam6, NULL); + +} + +void TestAnalytics::unloadPlugins() +{ + if (NULL != _pluginAnalytics) { + _pluginAnalytics->stopSession(); + + std::string pluginName = _pluginAnalytics->getPluginName(); + PluginManager::getInstance()->unloadPlugin(pluginName.c_str()); + _pluginAnalytics = NULL; + } +} + +void TestAnalytics::menuBackCallback(Object* pSender) +{ + Scene* newScene = HelloWorld::scene(); + Director::sharedDirector()->replaceScene(newScene); } diff --git a/plugin/samples/HelloShare/Classes/HelloWorldScene.h b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.h similarity index 79% rename from plugin/samples/HelloShare/Classes/HelloWorldScene.h rename to plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.h index 1b5c1191ea..cecde70cee 100644 --- a/plugin/samples/HelloShare/Classes/HelloWorldScene.h +++ b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.h @@ -21,27 +21,34 @@ 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 __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ +#ifndef __TEST_ANALYTICS_SCENE_H__ +#define __TEST_ANALYTICS_SCENE_H__ #include "cocos2d.h" +#include "ProtocolAnalytics.h" -class HelloWorld : public cocos2d::Layer +class TestAnalytics : public cocos2d::Layer { public: // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone - virtual bool init(); + virtual bool init(); + virtual void onExit(); // there's no 'id' in cpp, so we recommand to return the exactly class pointer static cocos2d::Scene* scene(); // a selector callback - void menuCloseCallback(Object* pSender); + void menuBackCallback(Object* pSender); void eventMenuCallback(Object* pSender); - void reloadPluginMenuCallback(Object* pSender); + + void loadPlugins(); + void unloadPlugins(); // implement the "static node()" method manually - CREATE_FUNC(HelloWorld); + CREATE_FUNC(TestAnalytics); + +private: + cocos2d::plugin::ProtocolAnalytics* _pluginAnalytics; }; -#endif // __HELLOWORLD_SCENE_H__ +#endif // __TEST_ANALYTICS_SCENE_H__ diff --git a/plugin/samples/HelloIAP/Classes/MyPurchase.cpp b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp similarity index 100% rename from plugin/samples/HelloIAP/Classes/MyPurchase.cpp rename to plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp diff --git a/plugin/samples/HelloIAP/Classes/MyPurchase.h b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h similarity index 100% rename from plugin/samples/HelloIAP/Classes/MyPurchase.h rename to plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h diff --git a/plugin/samples/HelloIAP/Classes/HelloWorldScene.cpp b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp similarity index 71% rename from plugin/samples/HelloIAP/Classes/HelloWorldScene.cpp rename to plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp index 0e2513dbc0..1111a4e989 100644 --- a/plugin/samples/HelloIAP/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp @@ -21,10 +21,11 @@ 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 "HelloWorldScene.h" +#include "TestIAPScene.h" #include "PluginManager.h" #include "AppDelegate.h" #include "MyPurchase.h" +#include "HelloWorldScene.h" using namespace cocos2d; using namespace cocos2d::plugin; @@ -44,13 +45,13 @@ static EventMenuItem s_EventMenuItem[] = { {"BtnND91.png", TAG_PAY_BY_ND91}, }; -Scene* HelloWorld::scene() +Scene* TestIAP::scene() { // 'scene' is an autorelease object Scene *scene = Scene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::create(); + TestIAP *layer = TestIAP::create(); // add layer as a child to scene scene->addChild(layer); @@ -60,7 +61,7 @@ Scene* HelloWorld::scene() } // on "init" you need to initialize your instance -bool HelloWorld::init() +bool TestIAP::init() { ////////////////////////////// // 1. super init first @@ -69,11 +70,8 @@ bool HelloWorld::init() return false; } - Size size = Director::sharedDirector()->getWinSize(); + MyPurchase::sharedPurchase()->loadIAPPlugin(); - Sprite* pBackground = Sprite::create("background.png"); - pBackground->setPosition(ccp(size.width / 2, size.height / 2)); - addChild(pBackground); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. @@ -83,15 +81,12 @@ bool HelloWorld::init() Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *pCloseItem = MenuItemImage::create( - "CloseNormal.png", - "CloseSelected.png", - this, - menu_selector(HelloWorld::menuCloseCallback) ); - pCloseItem->setPosition( ccp(posBR.x - 20, posBR.y + 20) ); + MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this)); + Size backSize = pBackItem->getContentSize(); + pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); + Menu* pMenu = Menu::create(pBackItem, NULL); pMenu->setPosition( PointZero ); this->addChild(pMenu, 1); @@ -101,7 +96,7 @@ bool HelloWorld::init() int row = 0; for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), - this, menu_selector(HelloWorld::eventMenuCallback)); + CC_CALLBACK_1(TestIAP::eventMenuCallback, this)); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); @@ -116,22 +111,10 @@ bool HelloWorld::init() pMenuItem->setPosition(pos); } - LabelTTF* label = LabelTTF::create("reload all plugins", "Arial", 24); - MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback)); - pMenuItem->setAnchorPoint(ccp(0.5f, 0)); - pMenu->addChild(pMenuItem, 0); - pMenuItem->setPosition( ccp(size.width / 2, 0)); - return true; } -void HelloWorld::reloadPluginMenuCallback(Object* pSender) -{ - MyPurchase::sharedPurchase()->unloadIAPPlugin(); - MyPurchase::sharedPurchase()->loadIAPPlugin(); -} - -void HelloWorld::eventMenuCallback(Object* pSender) +void TestIAP::eventMenuCallback(Object* pSender) { MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender; TProductInfo pInfo; @@ -143,12 +126,10 @@ void HelloWorld::eventMenuCallback(Object* pSender) MyPurchase::sharedPurchase()->payByMode(pInfo, mode); } -void HelloWorld::menuCloseCallback(Object* pSender) +void TestIAP::menuBackCallback(Object* pSender) { MyPurchase::purgePurchase(); - Director::sharedDirector()->end(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif + Scene* newScene = HelloWorld::scene(); + Director::sharedDirector()->replaceScene(newScene); } diff --git a/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.h b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.h similarity index 86% rename from plugin/samples/HelloAnalytics/Classes/HelloWorldScene.h rename to plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.h index 1b5c1191ea..4929bdfd40 100644 --- a/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.h +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.h @@ -21,12 +21,12 @@ 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 __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ +#ifndef __TEST_IAP_SCENE_H__ +#define __TEST_IAP_SCENE_H__ #include "cocos2d.h" -class HelloWorld : public cocos2d::Layer +class TestIAP : public cocos2d::Layer { public: // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone @@ -36,12 +36,11 @@ public: static cocos2d::Scene* scene(); // a selector callback - void menuCloseCallback(Object* pSender); + void menuBackCallback(Object* pSender); void eventMenuCallback(Object* pSender); - void reloadPluginMenuCallback(Object* pSender); // implement the "static node()" method manually - CREATE_FUNC(HelloWorld); + CREATE_FUNC(TestIAP); }; -#endif // __HELLOWORLD_SCENE_H__ +#endif // __TEST_IAP_SCENE_H__ diff --git a/plugin/samples/HelloShare/Classes/MyShareManager.cpp b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp similarity index 95% rename from plugin/samples/HelloShare/Classes/MyShareManager.cpp rename to plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp index d431ff9ed2..97f6d34174 100644 --- a/plugin/samples/HelloShare/Classes/MyShareManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp @@ -48,7 +48,7 @@ MyShareManager::~MyShareManager() } } -MyShareManager* MyShareManager::sharedShareManager() +MyShareManager* MyShareManager::sharedManager() { if (s_pManager == NULL) { s_pManager = new MyShareManager(); diff --git a/plugin/samples/HelloShare/Classes/MyShareManager.h b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h similarity index 97% rename from plugin/samples/HelloShare/Classes/MyShareManager.h rename to plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h index 32aadd666a..4521a57b6c 100755 --- a/plugin/samples/HelloShare/Classes/MyShareManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h @@ -35,7 +35,7 @@ public: class MyShareManager { public: - static MyShareManager* sharedShareManager(); + static MyShareManager* sharedManager(); static void purgeManager(); typedef enum { diff --git a/plugin/samples/HelloShare/Classes/HelloWorldScene.cpp b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp similarity index 66% rename from plugin/samples/HelloShare/Classes/HelloWorldScene.cpp rename to plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp index 90013730f6..5b9d8043e2 100644 --- a/plugin/samples/HelloShare/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp @@ -21,10 +21,11 @@ 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 "HelloWorldScene.h" +#include "TestShareScene.h" #include "PluginManager.h" #include "AppDelegate.h" #include "MyShareManager.h" +#include "HelloWorldScene.h" using namespace cocos2d; using namespace cocos2d::plugin; @@ -44,13 +45,13 @@ static EventMenuItem s_EventMenuItem[] = { {"weibo.png", TAG_SHARE_BY_WEIBO} }; -Scene* HelloWorld::scene() +Scene* TestShare::scene() { // 'scene' is an autorelease object Scene *scene = Scene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::create(); + TestShare *layer = TestShare::create(); // add layer as a child to scene scene->addChild(layer); @@ -60,7 +61,7 @@ Scene* HelloWorld::scene() } // on "init" you need to initialize your instance -bool HelloWorld::init() +bool TestShare::init() { ////////////////////////////// // 1. super init first @@ -69,30 +70,23 @@ bool HelloWorld::init() return false; } - Size size = Director::sharedDirector()->getVisibleSize(); + MyShareManager::sharedManager()->loadSharePlugin(); - Sprite* pBackground = Sprite::create("background.png"); - pBackground->setPosition(ccp(size.width / 2, size.height / 2)); - addChild(pBackground); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. EGLView* pEGLView = EGLView::sharedOpenGLView(); Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y); - Point posBC = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width/2, pEGLView->getVisibleOrigin().y); Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *pCloseItem = MenuItemImage::create( - "CloseNormal.png", - "CloseSelected.png", - this, - menu_selector(HelloWorld::menuCloseCallback) ); - pCloseItem->setPosition( ccp(posBR.x - 20, posBR.y + 20) ); + MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestShare::menuBackCallback, this)); + Size backSize = pBackItem->getContentSize(); + pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); + Menu* pMenu = Menu::create(pBackItem, NULL); pMenu->setPosition( PointZero ); this->addChild(pMenu, 1); @@ -101,8 +95,7 @@ bool HelloWorld::init() int line = 0; int row = 0; for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { - MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), - this, menu_selector(HelloWorld::eventMenuCallback)); + MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), CC_CALLBACK_1(TestShare::eventMenuCallback, this)); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); @@ -117,36 +110,22 @@ bool HelloWorld::init() pMenuItem->setPosition(pos); } - LabelTTF* label = LabelTTF::create("Reload all plugins", "Arial", 24); - MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback)); - pMenuItem->setAnchorPoint(ccp(0.5f, 0)); - pMenu->addChild(pMenuItem, 0); - pMenuItem->setPosition(posBC); - return true; } -void HelloWorld::reloadPluginMenuCallback(Object* pSender) -{ - MyShareManager::sharedShareManager()->unloadSharePlugin(); - MyShareManager::sharedShareManager()->loadSharePlugin(); -} - -void HelloWorld::eventMenuCallback(Object* pSender) +void TestShare::eventMenuCallback(Object* pSender) { MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender; TShareInfo pInfo; pInfo["SharedText"] = "Share message : HelloShare!"; // pInfo["SharedImagePath"] = "Full/path/to/image"; MyShareManager::MyShareMode mode = (MyShareManager::MyShareMode) (pMenuItem->getTag() - TAG_SHARE_BY_TWWITER + 1); - MyShareManager::sharedShareManager()->shareByMode(pInfo, mode); + MyShareManager::sharedManager()->shareByMode(pInfo, mode); } -void HelloWorld::menuCloseCallback(Object* pSender) +void TestShare::menuBackCallback(Object* pSender) { MyShareManager::purgeManager(); - Director::sharedDirector()->end(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif + Scene* newScene = HelloWorld::scene(); + Director::sharedDirector()->replaceScene(newScene); } diff --git a/plugin/samples/HelloIAP/Classes/HelloWorldScene.h b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.h similarity index 86% rename from plugin/samples/HelloIAP/Classes/HelloWorldScene.h rename to plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.h index 1b5c1191ea..c49da10706 100644 --- a/plugin/samples/HelloIAP/Classes/HelloWorldScene.h +++ b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.h @@ -21,12 +21,12 @@ 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 __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ +#ifndef __TEST_SHARE_SCENE_H__ +#define __TEST_SHARE_SCENE_H__ #include "cocos2d.h" -class HelloWorld : public cocos2d::Layer +class TestShare : public cocos2d::Layer { public: // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone @@ -36,12 +36,11 @@ public: static cocos2d::Scene* scene(); // a selector callback - void menuCloseCallback(Object* pSender); + void menuBackCallback(Object* pSender); void eventMenuCallback(Object* pSender); - void reloadPluginMenuCallback(Object* pSender); // implement the "static node()" method manually - CREATE_FUNC(HelloWorld); + CREATE_FUNC(TestShare); }; -#endif // __HELLOWORLD_SCENE_H__ +#endif // __TEST_SHARE_SCENE_H__ diff --git a/plugin/samples/HelloUser/Classes/MyUserManager.cpp b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp similarity index 100% rename from plugin/samples/HelloUser/Classes/MyUserManager.cpp rename to plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp diff --git a/plugin/samples/HelloUser/Classes/MyUserManager.h b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h similarity index 100% rename from plugin/samples/HelloUser/Classes/MyUserManager.h rename to plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h diff --git a/plugin/samples/HelloUser/Classes/HelloWorldScene.cpp b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp similarity index 71% rename from plugin/samples/HelloUser/Classes/HelloWorldScene.cpp rename to plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp index 4d6326ff8f..fc18b4b597 100644 --- a/plugin/samples/HelloUser/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp @@ -1,5 +1,6 @@ -#include "HelloWorldScene.h" +#include "TestUserScene.h" #include "MyUserManager.h" +#include "HelloWorldScene.h" USING_NS_CC; @@ -8,13 +9,13 @@ const std::string s_aTestCases[] = { "ND91", }; -Scene* HelloWorld::scene() +Scene* TestUser::scene() { // 'scene' is an autorelease object Scene *scene = Scene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::create(); + TestUser *layer = TestUser::create(); // add layer as a child to scene scene->addChild(layer); @@ -24,7 +25,7 @@ Scene* HelloWorld::scene() } // on "init" you need to initialize your instance -bool HelloWorld::init() +bool TestUser::init() { ////////////////////////////// // 1. super init first @@ -33,42 +34,40 @@ bool HelloWorld::init() return false; } + MyUserManager::sharedManager()->loadPlugin(); Size visibleSize = Director::sharedDirector()->getVisibleSize(); Point origin = Director::sharedDirector()->getVisibleOrigin(); Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); + Point posBR = ccp(origin.x + visibleSize.width, origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *pCloseItem = MenuItemImage::create( - "CloseNormal.png", - "CloseSelected.png", - CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - - pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 , - origin.y + pCloseItem->getContentSize().height/2)); + MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestUser::menuBackCallback, this)); + Size backSize = pBackItem->getContentSize(); + pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); + Menu* pMenu = Menu::create(pBackItem, NULL); pMenu->setPosition(PointZero); LabelTTF* label1 = LabelTTF::create("Login", "Arial", 32); - MenuItemLabel* pItemLogin = MenuItemLabel::create(label1, CC_CALLBACK_1(HelloWorld::testLogin, this)); + MenuItemLabel* pItemLogin = MenuItemLabel::create(label1, CC_CALLBACK_1(TestUser::testLogin, this)); pItemLogin->setAnchorPoint(ccp(0.5f, 0)); pMenu->addChild(pItemLogin, 0); pItemLogin->setPosition(ccpAdd(posMid, ccp(-100, -120))); LabelTTF* label2 = LabelTTF::create("Logout", "Arial", 32); - MenuItemLabel* pItemLogout = MenuItemLabel::create(label2, CC_CALLBACK_1(HelloWorld::testLogout, this)); + MenuItemLabel* pItemLogout = MenuItemLabel::create(label2, CC_CALLBACK_1(TestUser::testLogout, this)); pItemLogout->setAnchorPoint(ccp(0.5f, 0)); pMenu->addChild(pItemLogout, 0); pItemLogout->setPosition(ccpAdd(posMid, ccp(100, -120))); // create optional menu // cases item - _caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::caseChanged, this), + _caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestUser::caseChanged, this), MenuItemFont::create( s_aTestCases[0].c_str() ), NULL ); int caseLen = sizeof(s_aTestCases) / sizeof(std::string); @@ -85,26 +84,25 @@ bool HelloWorld::init() return true; } -void HelloWorld::caseChanged(Object* pSender) +void TestUser::caseChanged(Object* pSender) { _selectedCase = _caseItem->getSelectedIndex(); } -void HelloWorld::testLogin(Object* pSender) +void TestUser::testLogin(Object* pSender) { MyUserManager::sharedManager()->loginByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); } -void HelloWorld::testLogout(Object* pSender) +void TestUser::testLogout(Object* pSender) { MyUserManager::sharedManager()->logoutByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); } -void HelloWorld::menuCloseCallback(Object* pSender) +void TestUser::menuBackCallback(Object* pSender) { - Director::sharedDirector()->end(); + MyUserManager::purgeManager(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif + Scene* newScene = HelloWorld::scene(); + Director::sharedDirector()->replaceScene(newScene); } diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.h b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.h new file mode 100644 index 0000000000..f146d7b0ec --- /dev/null +++ b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.h @@ -0,0 +1,30 @@ +#ifndef __TEST_USER_SCENE_H__ +#define __TEST_USER_SCENE_H__ + +#include "cocos2d.h" + +class TestUser : public cocos2d::Layer +{ +public: + // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone + virtual bool init(); + + // there's no 'id' in cpp, so we recommend returning the class instance pointer + static cocos2d::Scene* scene(); + + // a selector callback + void menuBackCallback(Object* pSender); + void testLogin(Object* pSender); + void testLogout(Object* pSender); + + void caseChanged(Object* pSender); + + // implement the "static node()" method manually + CREATE_FUNC(TestUser); + +private: + cocos2d::MenuItemToggle* _caseItem; + int _selectedCase; +}; + +#endif // __TEST_USER_SCENE_H__ diff --git a/plugin/samples/HelloShare/proj.android/.classpath b/plugin/samples/HelloPlugins/proj.android/.classpath old mode 100755 new mode 100644 similarity index 50% rename from plugin/samples/HelloShare/proj.android/.classpath rename to plugin/samples/HelloPlugins/proj.android/.classpath index 4ace7547e1..78c6a50901 --- a/plugin/samples/HelloShare/proj.android/.classpath +++ b/plugin/samples/HelloPlugins/proj.android/.classpath @@ -4,13 +4,25 @@ + + + + + + + + + + + - + + diff --git a/plugin/samples/HelloUser/proj.android/.project b/plugin/samples/HelloPlugins/proj.android/.project similarity index 97% rename from plugin/samples/HelloUser/proj.android/.project rename to plugin/samples/HelloPlugins/proj.android/.project index b8d9f4a665..866cd15eb9 100644 --- a/plugin/samples/HelloUser/proj.android/.project +++ b/plugin/samples/HelloPlugins/proj.android/.project @@ -1,6 +1,6 @@ - HelloUser + HelloPlugins diff --git a/plugin/samples/HelloPlugins/proj.android/AndroidManifest.xml b/plugin/samples/HelloPlugins/proj.android/AndroidManifest.xml new file mode 100644 index 0000000000..4e3f48d5d7 --- /dev/null +++ b/plugin/samples/HelloPlugins/proj.android/AndroidManifest.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugin/samples/HelloAds/proj.android/README.md b/plugin/samples/HelloPlugins/proj.android/README.md similarity index 100% rename from plugin/samples/HelloAds/proj.android/README.md rename to plugin/samples/HelloPlugins/proj.android/README.md diff --git a/plugin/samples/HelloAds/proj.android/ant.properties b/plugin/samples/HelloPlugins/proj.android/ant.properties similarity index 100% rename from plugin/samples/HelloAds/proj.android/ant.properties rename to plugin/samples/HelloPlugins/proj.android/ant.properties diff --git a/plugin/samples/HelloUser/proj.android/build.xml b/plugin/samples/HelloPlugins/proj.android/build.xml similarity index 98% rename from plugin/samples/HelloUser/proj.android/build.xml rename to plugin/samples/HelloPlugins/proj.android/build.xml index 28a0fcf8df..6b1565b670 100644 --- a/plugin/samples/HelloUser/proj.android/build.xml +++ b/plugin/samples/HelloPlugins/proj.android/build.xml @@ -1,5 +1,5 @@ - + - - - diff --git a/plugin/samples/HelloShare/proj.android/ant.properties b/plugin/samples/HelloShare/proj.android/ant.properties deleted file mode 100755 index b0971e891e..0000000000 --- a/plugin/samples/HelloShare/proj.android/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/plugin/samples/HelloShare/proj.android/build.xml b/plugin/samples/HelloShare/proj.android/build.xml deleted file mode 100755 index b3f20e0181..0000000000 --- a/plugin/samples/HelloShare/proj.android/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloShare/proj.android/build_native.sh b/plugin/samples/HelloShare/proj.android/build_native.sh deleted file mode 100755 index 0e800b7d70..0000000000 --- a/plugin/samples/HelloShare/proj.android/build_native.sh +++ /dev/null @@ -1,81 +0,0 @@ -APPNAME="HelloSocial" - -# options - -buildexternalsfromsource= - -usage(){ -cat << EOF -usage: $0 [options] - -Build C/C++ code for $APPNAME using Android NDK - -OPTIONS: --s Build externals from source --h this help -EOF -} - -while getopts "sh" OPTION; do -case "$OPTION" in -s) -buildexternalsfromsource=1 -;; -h) -usage -exit 0 -;; -esac -done - -# paths - -if [ -z "${NDK_ROOT+aaa}" ];then -echo "please define NDK_ROOT" -exit 1 -fi - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# ... use paths relative to current directory -PLUGIN_ROOT="$DIR/../../.." -COCOS2DX_ROOT="$DIR/../../../.." -APP_ROOT="$DIR/.." -APP_ANDROID_ROOT="$DIR" - -echo "PLUGIN_ROOT = $PLUGIN_ROOT" -echo "NDK_ROOT = $NDK_ROOT" -echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" -echo "APP_ROOT = $APP_ROOT" -echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" -echo "---------------------------------------------------------" - -# make sure assets is exist -if [ -d "$APP_ANDROID_ROOT"/assets ]; then - rm -rf "$APP_ANDROID_ROOT"/assets -fi - -mkdir "$APP_ANDROID_ROOT"/assets - -# copy resources -for file in "$APP_ROOT"/Resources/* -do -if [ -d "$file" ]; then - cp -rf "$file" "$APP_ANDROID_ROOT"/assets -fi - -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/assets -fi -done - -if [[ "$buildexternalsfromsource" ]]; then - echo "Building external dependencies from source" - set -x - "$NDK_ROOT"/ndk-build -j 4 -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" -else - echo "Using prebuilt externals" - set -x - "$NDK_ROOT"/ndk-build -j 4 -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" -fi diff --git a/plugin/samples/HelloShare/proj.android/jni/Android.mk b/plugin/samples/HelloShare/proj.android/jni/Android.mk deleted file mode 100755 index 61b1a4fef2..0000000000 --- a/plugin/samples/HelloShare/proj.android/jni/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := game_shared - -LOCAL_MODULE_FILENAME := libgame - -LOCAL_SRC_FILES := hellocpp/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp \ - ../../Classes/MyShareManager.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \ - PluginProtocolStatic - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) -$(call import-module,protocols/android) diff --git a/plugin/samples/HelloShare/proj.android/jni/Application.mk b/plugin/samples/HelloShare/proj.android/jni/Application.mk deleted file mode 100755 index 488132832e..0000000000 --- a/plugin/samples/HelloShare/proj.android/jni/Application.mk +++ /dev/null @@ -1,3 +0,0 @@ -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -std=c++11 -NDK_TOOLCHAIN_VERSION=4.7 diff --git a/plugin/samples/HelloShare/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloShare/proj.android/jni/hellocpp/main.cpp deleted file mode 100644 index edb9402593..0000000000 --- a/plugin/samples/HelloShare/proj.android/jni/hellocpp/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "AppDelegate.h" -#include "platform/android/jni/JniHelper.h" -#include "PluginJniHelper.h" -#include -#include - -#include "HelloWorldScene.h" - -#define LOG_TAG "main" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) - -using namespace cocos2d; - -extern "C" -{ - -jint JNI_OnLoad(JavaVM *vm, void *reserved) -{ - JniHelper::setJavaVM(vm); - PluginJniHelper::setJavaVM(vm); - - return JNI_VERSION_1_4; -} - -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) -{ - if (!Director::sharedDirector()->getOpenGLView()) - { - EGLView *view = EGLView::sharedOpenGLView(); - view->setFrameSize(w, h); - - AppDelegate *pAppDelegate = new AppDelegate(); - Application::sharedApplication()->run(); - } - else - { - ccDrawInit(); - ccGLInvalidateStateCache(); - - ShaderCache::sharedShaderCache()->reloadDefaultShaders(); - TextureCache::reloadAllTextures(); - NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); - Director::sharedDirector()->setGLDefaultValues(); - } -} - -} diff --git a/plugin/samples/HelloShare/proj.android/proguard-project.txt b/plugin/samples/HelloShare/proj.android/proguard-project.txt deleted file mode 100755 index b60ae7ea07..0000000000 --- a/plugin/samples/HelloShare/proj.android/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/plugin/samples/HelloShare/proj.android/project.properties b/plugin/samples/HelloShare/proj.android/project.properties deleted file mode 100755 index e4ad2bf52d..0000000000 --- a/plugin/samples/HelloShare/proj.android/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-10 -android.library.reference.1=../../../../cocos2dx/platform/android/java diff --git a/plugin/samples/HelloShare/proj.android/res/values/strings.xml b/plugin/samples/HelloShare/proj.android/res/values/strings.xml deleted file mode 100755 index bd727b6167..0000000000 --- a/plugin/samples/HelloShare/proj.android/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - HelloShare - diff --git a/plugin/samples/HelloShare/proj.android/src/org/cocos2dx/helloShare/HelloShare.java b/plugin/samples/HelloShare/proj.android/src/org/cocos2dx/helloShare/HelloShare.java deleted file mode 100755 index af2033f677..0000000000 --- a/plugin/samples/HelloShare/proj.android/src/org/cocos2dx/helloShare/HelloShare.java +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 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.helloShare; - -import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.plugin.PluginWrapper; - -import android.os.Bundle; - -public class HelloShare extends Cocos2dxActivity{ - - protected void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - PluginWrapper.init(this); - PluginWrapper.setGLSurfaceView(Cocos2dxGLSurfaceView.getInstance()); - } - - static { - System.loadLibrary("game"); - } -} diff --git a/plugin/samples/HelloShare/proj.ios/AppController.mm b/plugin/samples/HelloShare/proj.ios/AppController.mm deleted file mode 100644 index e7dece6458..0000000000 --- a/plugin/samples/HelloShare/proj.ios/AppController.mm +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ - -#import "AppController.h" -#import "EAGLView.h" -#import "cocos2d.h" -#import "AppDelegate.h" -#import "RootViewController.h" - -@implementation AppController - -#pragma mark - -#pragma mark Application lifecycle - -// cocos2d application instance -static AppDelegate s_sharedApplication; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - // Override point for customization after application launch. - - // Add the view controller's view to the window and display. - window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - - // Init the CCEAGLView - CCEAGLView *__glView = [CCEAGLView viewWithFrame: [window bounds] - pixelFormat: kEAGLColorFormatRGB565 - depthFormat: GL_DEPTH24_STENCIL8_OES - preserveBackbuffer: NO - sharegroup: nil - multiSampling: NO - numberOfSamples: 0]; - [__glView setMultipleTouchEnabled:YES]; - - // Use RootViewController manage CCEAGLView - viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; - viewController.wantsFullScreenLayout = YES; - viewController.view = __glView; - - // Set RootViewController to window - if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) - { - // warning: addSubView doesn't work on iOS6 - [window addSubview: viewController.view]; - } - else - { - // use this method on ios6 - [window setRootViewController:viewController]; - } - - [window makeKeyAndVisible]; - - [[UIApplication sharedApplication] setStatusBarHidden:true]; - - cocos2d::Application::sharedApplication()->run(); - - return YES; -} - - -- (void)applicationWillResignActive:(UIApplication *)application { - /* - Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - */ - cocos2d::Director::sharedDirector()->pause(); -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - /* - Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - */ - cocos2d::Director::sharedDirector()->resume(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - If your application supports background execution, called instead of applicationWillTerminate: when the user quits. - */ - cocos2d::Application::sharedApplication()->applicationDidEnterBackground(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. - */ - cocos2d::Application::sharedApplication()->applicationWillEnterForeground(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { - /* - Called when the application is about to terminate. - See also applicationDidEnterBackground:. - */ -} - - -#pragma mark - -#pragma mark Memory management - -- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - /* - Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. - */ -} - - -- (void)dealloc { - [window release]; - [super dealloc]; -} - - -@end diff --git a/plugin/samples/HelloShare/proj.ios/Default-568h@2x.png.REMOVED.git-id b/plugin/samples/HelloShare/proj.ios/Default-568h@2x.png.REMOVED.git-id deleted file mode 100644 index 8f5838f3a8..0000000000 --- a/plugin/samples/HelloShare/proj.ios/Default-568h@2x.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/plugin/samples/HelloShare/proj.ios/Default@2x.png.REMOVED.git-id b/plugin/samples/HelloShare/proj.ios/Default@2x.png.REMOVED.git-id deleted file mode 100644 index 8843505b20..0000000000 --- a/plugin/samples/HelloShare/proj.ios/Default@2x.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/plugin/samples/HelloShare/proj.ios/HelloShare.xcodeproj/project.pbxproj b/plugin/samples/HelloShare/proj.ios/HelloShare.xcodeproj/project.pbxproj deleted file mode 100644 index 08b0d37600..0000000000 --- a/plugin/samples/HelloShare/proj.ios/HelloShare.xcodeproj/project.pbxproj +++ /dev/null @@ -1,605 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 15A3DAEB1682F8A6002FB0C5 /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 15A3DA861682F8A6002FB0C5 /* CDAudioManager.m */; }; - 15A3DAEC1682F8A6002FB0C5 /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 15A3DA891682F8A6002FB0C5 /* CDOpenALSupport.m */; }; - 15A3DAED1682F8A6002FB0C5 /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 15A3DA8B1682F8A6002FB0C5 /* CocosDenshion.m */; }; - 15A3DAEE1682F8A6002FB0C5 /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15A3DA8C1682F8A6002FB0C5 /* SimpleAudioEngine.mm */; }; - 15A3DAEF1682F8A6002FB0C5 /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 15A3DA8E1682F8A6002FB0C5 /* SimpleAudioEngine_objc.m */; }; - 1AC3624916D4A1E8000847F2 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AC3624316D4A1E8000847F2 /* AppController.mm */; }; - 1AC3624B16D4A1E8000847F2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AC3624516D4A1E8000847F2 /* main.m */; }; - 1AFAF8B716D35DE700DB1158 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */; }; - 1AFAF8B816D35DE700DB1158 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B516D35DE700DB1158 /* HelloWorldScene.cpp */; }; - 1AFAF8BC16D35E4900DB1158 /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B916D35E4900DB1158 /* CloseNormal.png */; }; - 1AFAF8BD16D35E4900DB1158 /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8BA16D35E4900DB1158 /* CloseSelected.png */; }; - 1AFCDA8216D4A25900906EA6 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AFCDA8116D4A25900906EA6 /* RootViewController.mm */; }; - 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; - 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; - 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; - 7855E0E1153FEF240059DD9A /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 7855E0DF153FEF240059DD9A /* Default.png */; }; - BF171245129291EC00B8313A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF170DB012928DE900B8313A /* OpenGLES.framework */; }; - BF1712461292920000B8313A /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF170DB212928DE900B8313A /* libxml2.dylib */; }; - BF1712471292920000B8313A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF170DB412928DE900B8313A /* libz.dylib */; }; - BF1C47F01293687400B63C5D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF1C47EA1293683800B63C5D /* QuartzCore.framework */; }; - D41A0AD1160F154A004552AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D41A0AD0160F154A004552AE /* Default-568h@2x.png */; }; - D446FD6E16102124000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD6D16102124000ADA7B /* Default@2x.png */; }; - D44C620C132DFF330009C878 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D44C620B132DFF330009C878 /* OpenAL.framework */; }; - D44C620E132DFF430009C878 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D44C620D132DFF430009C878 /* AVFoundation.framework */; }; - D4EF949A15BD2D8B00D803EB /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949915BD2D8B00D803EB /* Icon-57.png */; }; - D4EF949C15BD2D8E00D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949B15BD2D8E00D803EB /* Icon-114.png */; }; - D4EF949E15BD2D9600D803EB /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949D15BD2D9600D803EB /* Icon-72.png */; }; - D4EF94A015BD2D9800D803EB /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949F15BD2D9800D803EB /* Icon-144.png */; }; - FAC2A80B1777FAEA00035D22 /* MyShareManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A8091777FAEA00035D22 /* MyShareManager.cpp */; }; - FACAD8F61763061F00D75ADE /* libPluginTwitter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */; }; - FACAD8F81763070D00D75ADE /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */; }; - FAE27583175DEC8600F5DA8E /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27580175DEC8600F5DA8E /* background.png */; }; - FAE27584175DEC8600F5DA8E /* twitter.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FAE27581175DEC8600F5DA8E /* twitter.jpeg */; }; - FAE27585175DEC8600F5DA8E /* weibo.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27582175DEC8600F5DA8E /* weibo.png */; }; - FAE27598175DEE1900F5DA8E /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE2757F175DEC0D00F5DA8E /* libcocos2dx.a */; }; - FAE27599175DEE1900F5DA8E /* libPluginProtocol.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE2758E175DED1700F5DA8E /* libPluginProtocol.a */; }; - FAE2759A175DEE1900F5DA8E /* libPluginWeibo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE27597175DED2400F5DA8E /* libPluginWeibo.a */; }; - FAE275A1175DEEF500F5DA8E /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE275A0175DEEF500F5DA8E /* AudioToolbox.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - FACAD8F41762DC3A00D75ADE /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = FACAD8881762C1B500D75ADE; - remoteInfo = PluginTwitter; - }; - FAE2757E175DEC0D00F5DA8E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 1551A33F158F2AB200E66CFE; - remoteInfo = cocos2dx; - }; - FAE2758D175DED1700F5DA8E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = FA09A321168ADBC2008C1C7B; - remoteInfo = PluginProtocol; - }; - FAE27596175DED2400F5DA8E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = FAE27530175D9D2900F5DA8E; - remoteInfo = PluginWeibo; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 15A3DA821682F8A6002FB0C5 /* Export.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; - 15A3DA831682F8A6002FB0C5 /* SimpleAudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine.h; sourceTree = ""; }; - 15A3DA851682F8A6002FB0C5 /* CDAudioManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDAudioManager.h; sourceTree = ""; }; - 15A3DA861682F8A6002FB0C5 /* CDAudioManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDAudioManager.m; sourceTree = ""; }; - 15A3DA871682F8A6002FB0C5 /* CDConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDConfig.h; sourceTree = ""; }; - 15A3DA881682F8A6002FB0C5 /* CDOpenALSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDOpenALSupport.h; sourceTree = ""; }; - 15A3DA891682F8A6002FB0C5 /* CDOpenALSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDOpenALSupport.m; sourceTree = ""; }; - 15A3DA8A1682F8A6002FB0C5 /* CocosDenshion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosDenshion.h; sourceTree = ""; }; - 15A3DA8B1682F8A6002FB0C5 /* CocosDenshion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocosDenshion.m; sourceTree = ""; }; - 15A3DA8C1682F8A6002FB0C5 /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = ""; }; - 15A3DA8D1682F8A6002FB0C5 /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = ""; }; - 15A3DA8E1682F8A6002FB0C5 /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = ""; }; - 1AC3624216D4A1E8000847F2 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = SOURCE_ROOT; }; - 1AC3624316D4A1E8000847F2 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = SOURCE_ROOT; }; - 1AC3624516D4A1E8000847F2 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; - 1AC3624616D4A1E8000847F2 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; }; - 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppDelegate.cpp; path = ../Classes/AppDelegate.cpp; sourceTree = ""; }; - 1AFAF8B416D35DE700DB1158 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../Classes/AppDelegate.h; sourceTree = ""; }; - 1AFAF8B516D35DE700DB1158 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HelloWorldScene.cpp; path = ../Classes/HelloWorldScene.cpp; sourceTree = ""; }; - 1AFAF8B616D35DE700DB1158 /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HelloWorldScene.h; path = ../Classes/HelloWorldScene.h; sourceTree = ""; }; - 1AFAF8B916D35E4900DB1158 /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = ""; }; - 1AFAF8BA16D35E4900DB1158 /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = ""; }; - 1AFCDA8016D4A25900906EA6 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = SOURCE_ROOT; }; - 1AFCDA8116D4A25900906EA6 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = SOURCE_ROOT; }; - 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 1D6058910D05DD3D006BFB54 /* HelloShare.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloShare.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; - 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 7855E0DF153FEF240059DD9A /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; }; - BF170DB012928DE900B8313A /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; - BF170DB212928DE900B8313A /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; - BF170DB412928DE900B8313A /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; - BF1C47EA1293683800B63C5D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - D41A0AD0160F154A004552AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../proj.ios/Default-568h@2x.png"; sourceTree = ""; }; - D446FD6D16102124000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../proj.ios/Default@2x.png"; sourceTree = ""; }; - D44C620B132DFF330009C878 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; - D44C620D132DFF430009C878 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; - D4EF949915BD2D8B00D803EB /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "../proj.ios/Icon-57.png"; sourceTree = ""; }; - D4EF949B15BD2D8E00D803EB /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-114.png"; path = "../proj.ios/Icon-114.png"; sourceTree = ""; }; - D4EF949D15BD2D9600D803EB /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "../proj.ios/Icon-72.png"; sourceTree = ""; }; - D4EF949F15BD2D9800D803EB /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "../proj.ios/Icon-144.png"; sourceTree = ""; }; - D4F9F37B12E54555005CA6D2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; - FAC2A8091777FAEA00035D22 /* MyShareManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MyShareManager.cpp; path = ../Classes/MyShareManager.cpp; sourceTree = ""; }; - FAC2A80A1777FAEA00035D22 /* MyShareManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyShareManager.h; path = ../Classes/MyShareManager.h; sourceTree = ""; }; - FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginTwitter.xcodeproj; path = ../../../plugins/twitter/proj.ios/PluginTwitter.xcodeproj; sourceTree = ""; }; - FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; - FAE27580175DEC8600F5DA8E /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = ""; }; - FAE27581175DEC8600F5DA8E /* twitter.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = twitter.jpeg; sourceTree = ""; }; - FAE27582175DEC8600F5DA8E /* weibo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = weibo.png; sourceTree = ""; }; - FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginProtocol.xcodeproj; path = ../../../protocols/proj.ios/PluginProtocol.xcodeproj; sourceTree = ""; }; - FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginWeibo.xcodeproj; path = ../../../plugins/weibo/proj.ios/PluginWeibo.xcodeproj; sourceTree = ""; }; - FAE275A0175DEEF500F5DA8E /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - FACAD8F81763070D00D75ADE /* SystemConfiguration.framework in Frameworks */, - FACAD8F61763061F00D75ADE /* libPluginTwitter.a in Frameworks */, - FAE275A1175DEEF500F5DA8E /* AudioToolbox.framework in Frameworks */, - FAE27598175DEE1900F5DA8E /* libcocos2dx.a in Frameworks */, - FAE27599175DEE1900F5DA8E /* libPluginProtocol.a in Frameworks */, - FAE2759A175DEE1900F5DA8E /* libPluginWeibo.a in Frameworks */, - 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, - 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, - 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, - BF171245129291EC00B8313A /* OpenGLES.framework in Frameworks */, - BF1712461292920000B8313A /* libxml2.dylib in Frameworks */, - BF1712471292920000B8313A /* libz.dylib in Frameworks */, - BF1C47F01293687400B63C5D /* QuartzCore.framework in Frameworks */, - D44C620C132DFF330009C878 /* OpenAL.framework in Frameworks */, - D44C620E132DFF430009C878 /* AVFoundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 080E96DDFE201D6D7F000001 /* ios */ = { - isa = PBXGroup; - children = ( - 1AC3624216D4A1E8000847F2 /* AppController.h */, - 1AC3624316D4A1E8000847F2 /* AppController.mm */, - D4F9F37B12E54555005CA6D2 /* Info.plist */, - 1AC3624516D4A1E8000847F2 /* main.m */, - 1AC3624616D4A1E8000847F2 /* Prefix.pch */, - 1AFCDA8016D4A25900906EA6 /* RootViewController.h */, - 1AFCDA8116D4A25900906EA6 /* RootViewController.mm */, - ); - name = ios; - path = Classes; - sourceTree = ""; - }; - 15A3DA6B1682F8A6002FB0C5 /* CocosDenshion */ = { - isa = PBXGroup; - children = ( - 15A3DA811682F8A6002FB0C5 /* include */, - 15A3DA841682F8A6002FB0C5 /* ios */, - ); - name = CocosDenshion; - path = ../../../../CocosDenshion; - sourceTree = ""; - }; - 15A3DA811682F8A6002FB0C5 /* include */ = { - isa = PBXGroup; - children = ( - 15A3DA821682F8A6002FB0C5 /* Export.h */, - 15A3DA831682F8A6002FB0C5 /* SimpleAudioEngine.h */, - ); - path = include; - sourceTree = ""; - }; - 15A3DA841682F8A6002FB0C5 /* ios */ = { - isa = PBXGroup; - children = ( - 15A3DA851682F8A6002FB0C5 /* CDAudioManager.h */, - 15A3DA861682F8A6002FB0C5 /* CDAudioManager.m */, - 15A3DA871682F8A6002FB0C5 /* CDConfig.h */, - 15A3DA881682F8A6002FB0C5 /* CDOpenALSupport.h */, - 15A3DA891682F8A6002FB0C5 /* CDOpenALSupport.m */, - 15A3DA8A1682F8A6002FB0C5 /* CocosDenshion.h */, - 15A3DA8B1682F8A6002FB0C5 /* CocosDenshion.m */, - 15A3DA8C1682F8A6002FB0C5 /* SimpleAudioEngine.mm */, - 15A3DA8D1682F8A6002FB0C5 /* SimpleAudioEngine_objc.h */, - 15A3DA8E1682F8A6002FB0C5 /* SimpleAudioEngine_objc.m */, - ); - path = ios; - sourceTree = ""; - }; - 15AA9C4015B7EC450033D6C2 /* Classes */ = { - isa = PBXGroup; - children = ( - FAC2A8091777FAEA00035D22 /* MyShareManager.cpp */, - FAC2A80A1777FAEA00035D22 /* MyShareManager.h */, - 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */, - 1AFAF8B416D35DE700DB1158 /* AppDelegate.h */, - 1AFAF8B516D35DE700DB1158 /* HelloWorldScene.cpp */, - 1AFAF8B616D35DE700DB1158 /* HelloWorldScene.h */, - ); - name = Classes; - path = ../classes; - sourceTree = ""; - }; - 19C28FACFE9D520D11CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 1D6058910D05DD3D006BFB54 /* HelloShare.app */, - ); - name = Products; - sourceTree = ""; - }; - 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { - isa = PBXGroup; - children = ( - FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */, - FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */, - FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */, - FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */, - 15AA9C4015B7EC450033D6C2 /* Classes */, - 15A3DA6B1682F8A6002FB0C5 /* CocosDenshion */, - 29B97323FDCFA39411CA2CEA /* Frameworks */, - 080E96DDFE201D6D7F000001 /* ios */, - 19C28FACFE9D520D11CA2CBB /* Products */, - 78C7DDAA14EBA5050085D0C2 /* Resources */, - ); - name = CustomTemplate; - sourceTree = ""; - }; - 29B97323FDCFA39411CA2CEA /* Frameworks */ = { - isa = PBXGroup; - children = ( - FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */, - FAE275A0175DEEF500F5DA8E /* AudioToolbox.framework */, - BF170DB212928DE900B8313A /* libxml2.dylib */, - BF170DB412928DE900B8313A /* libz.dylib */, - D44C620D132DFF430009C878 /* AVFoundation.framework */, - 288765A40DF7441C002DB57D /* CoreGraphics.framework */, - 1D30AB110D05D00D00671497 /* Foundation.framework */, - D44C620B132DFF330009C878 /* OpenAL.framework */, - BF170DB012928DE900B8313A /* OpenGLES.framework */, - BF1C47EA1293683800B63C5D /* QuartzCore.framework */, - 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - 78C7DDAA14EBA5050085D0C2 /* Resources */ = { - isa = PBXGroup; - children = ( - FAE27580175DEC8600F5DA8E /* background.png */, - FAE27581175DEC8600F5DA8E /* twitter.jpeg */, - FAE27582175DEC8600F5DA8E /* weibo.png */, - 1AFAF8B916D35E4900DB1158 /* CloseNormal.png */, - 1AFAF8BA16D35E4900DB1158 /* CloseSelected.png */, - D41A0AD0160F154A004552AE /* Default-568h@2x.png */, - 7855E0DF153FEF240059DD9A /* Default.png */, - D446FD6D16102124000ADA7B /* Default@2x.png */, - D4EF949B15BD2D8E00D803EB /* Icon-114.png */, - D4EF949F15BD2D9800D803EB /* Icon-144.png */, - D4EF949915BD2D8B00D803EB /* Icon-57.png */, - D4EF949D15BD2D9600D803EB /* Icon-72.png */, - ); - name = Resources; - path = ../Resources; - sourceTree = ""; - }; - FACAD8EE1762DC3A00D75ADE /* Products */ = { - isa = PBXGroup; - children = ( - FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */, - ); - name = Products; - sourceTree = ""; - }; - FAE27578175DEC0C00F5DA8E /* Products */ = { - isa = PBXGroup; - children = ( - FAE2757F175DEC0D00F5DA8E /* libcocos2dx.a */, - ); - name = Products; - sourceTree = ""; - }; - FAE27587175DED1700F5DA8E /* Products */ = { - isa = PBXGroup; - children = ( - FAE2758E175DED1700F5DA8E /* libPluginProtocol.a */, - ); - name = Products; - sourceTree = ""; - }; - FAE27590175DED2300F5DA8E /* Products */ = { - isa = PBXGroup; - children = ( - FAE27597175DED2400F5DA8E /* libPluginWeibo.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 1D6058900D05DD3D006BFB54 /* HelloShare */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloShare" */; - buildPhases = ( - 1D60588D0D05DD3D006BFB54 /* Resources */, - 1D60588E0D05DD3D006BFB54 /* Sources */, - 1D60588F0D05DD3D006BFB54 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = HelloShare; - productName = iphone; - productReference = 1D6058910D05DD3D006BFB54 /* HelloShare.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 29B97313FDCFA39411CA2CEA /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0430; - }; - buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloShare" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = FAE27578175DEC0C00F5DA8E /* Products */; - ProjectRef = FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */; - }, - { - ProductGroup = FAE27587175DED1700F5DA8E /* Products */; - ProjectRef = FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */; - }, - { - ProductGroup = FACAD8EE1762DC3A00D75ADE /* Products */; - ProjectRef = FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */; - }, - { - ProductGroup = FAE27590175DED2300F5DA8E /* Products */; - ProjectRef = FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 1D6058900D05DD3D006BFB54 /* HelloShare */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libPluginTwitter.a; - remoteRef = FACAD8F41762DC3A00D75ADE /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - FAE2757F175DEC0D00F5DA8E /* libcocos2dx.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libcocos2dx.a; - remoteRef = FAE2757E175DEC0D00F5DA8E /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - FAE2758E175DED1700F5DA8E /* libPluginProtocol.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libPluginProtocol.a; - remoteRef = FAE2758D175DED1700F5DA8E /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - FAE27597175DED2400F5DA8E /* libPluginWeibo.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libPluginWeibo.a; - remoteRef = FAE27596175DED2400F5DA8E /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXResourcesBuildPhase section */ - 1D60588D0D05DD3D006BFB54 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 7855E0E1153FEF240059DD9A /* Default.png in Resources */, - D4EF949A15BD2D8B00D803EB /* Icon-57.png in Resources */, - D4EF949C15BD2D8E00D803EB /* Icon-114.png in Resources */, - D4EF949E15BD2D9600D803EB /* Icon-72.png in Resources */, - D4EF94A015BD2D9800D803EB /* Icon-144.png in Resources */, - D41A0AD1160F154A004552AE /* Default-568h@2x.png in Resources */, - D446FD6E16102124000ADA7B /* Default@2x.png in Resources */, - 1AFAF8BC16D35E4900DB1158 /* CloseNormal.png in Resources */, - 1AFAF8BD16D35E4900DB1158 /* CloseSelected.png in Resources */, - FAE27583175DEC8600F5DA8E /* background.png in Resources */, - FAE27584175DEC8600F5DA8E /* twitter.jpeg in Resources */, - FAE27585175DEC8600F5DA8E /* weibo.png in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 1D60588E0D05DD3D006BFB54 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 15A3DAEB1682F8A6002FB0C5 /* CDAudioManager.m in Sources */, - 15A3DAEC1682F8A6002FB0C5 /* CDOpenALSupport.m in Sources */, - 15A3DAED1682F8A6002FB0C5 /* CocosDenshion.m in Sources */, - 15A3DAEE1682F8A6002FB0C5 /* SimpleAudioEngine.mm in Sources */, - 15A3DAEF1682F8A6002FB0C5 /* SimpleAudioEngine_objc.m in Sources */, - 1AFAF8B716D35DE700DB1158 /* AppDelegate.cpp in Sources */, - 1AFAF8B816D35DE700DB1158 /* HelloWorldScene.cpp in Sources */, - 1AC3624916D4A1E8000847F2 /* AppController.mm in Sources */, - 1AC3624B16D4A1E8000847F2 /* main.m in Sources */, - 1AFCDA8216D4A25900906EA6 /* RootViewController.mm in Sources */, - FAC2A80B1777FAEA00035D22 /* MyShareManager.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 1D6058940D05DD3E006BFB54 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = ""; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - USE_FILE32API, - CC_TARGET_OS_IPHONE, - "COCOS2D_DEBUG=1", - CC_ENABLE_CHIPMUNK_INTEGRATION, - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_VERSION = ""; - HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../../../CocosDenshion/include", - "\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../../cocos2dx\"", - "\"$(SRCROOT)/../../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/ios\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/ios\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/ios/Simulation\"", - "\"$(SRCROOT)/../../../protocols/include", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\""; - OTHER_CFLAGS = "-O2"; - "OTHER_LDFLAGS[arch=*]" = "-ObjC"; - PRODUCT_NAME = HelloShare; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; - VALID_ARCHS = "armv6 armv7 i386"; - }; - name = Debug; - }; - 1D6058950D05DD3E006BFB54 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = ""; - COPY_PHASE_STRIP = YES; - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - USE_FILE32API, - CC_TARGET_OS_IPHONE, - CC_ENABLE_CHIPMUNK_INTEGRATION, - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_VERSION = ""; - HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../../../CocosDenshion/include", - "\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../../cocos2dx\"", - "\"$(SRCROOT)/../../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/ios\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/ios\"", - "\"$(SRCROOT)/../../../../cocos2dx/platform/ios/Simulation\"", - "\"$(SRCROOT)/../../../protocols/include", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\""; - "OTHER_LDFLAGS[arch=*]" = "-ObjC"; - PRODUCT_NAME = HelloShare; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - C01FCF4F08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = ""; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_VERSION = ""; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - SDKROOT = iphoneos; - VALID_ARCHS = "armv6 armv7 i386"; - }; - name = Debug; - }; - C01FCF5008A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CODE_SIGN_IDENTITY = ""; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_VERSION = ""; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - SDKROOT = iphoneos; - VALID_ARCHS = "armv6 armv7 i386"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloShare" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1D6058940D05DD3E006BFB54 /* Debug */, - 1D6058950D05DD3E006BFB54 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Debug; - }; - C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloShare" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4F08A954540054247B /* Debug */, - C01FCF5008A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Debug; - }; -/* End XCConfigurationList section */ - }; - rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; -} diff --git a/plugin/samples/HelloShare/proj.ios/Prefix.pch b/plugin/samples/HelloShare/proj.ios/Prefix.pch deleted file mode 100644 index 5b4e2fd9e1..0000000000 --- a/plugin/samples/HelloShare/proj.ios/Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the 'iphone' target in the 'iphone' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/plugin/samples/HelloShare/proj.ios/RootViewController.mm b/plugin/samples/HelloShare/proj.ios/RootViewController.mm deleted file mode 100644 index bdadc9ced7..0000000000 --- a/plugin/samples/HelloShare/proj.ios/RootViewController.mm +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ - -#import "RootViewController.h" - - -@implementation RootViewController - -/* - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { - // Custom initialization - } - return self; -} -*/ - -/* -// Implement loadView to create a view hierarchy programmatically, without using a nib. -- (void)loadView { -} -*/ - -/* -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad { - [super viewDidLoad]; -} - -*/ -// Override to allow orientations other than the default portrait orientation. -// This method is deprecated on ios6 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsLandscape( interfaceOrientation ); -} - -// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations{ -#ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskAllButUpsideDown; -#endif -} - -- (BOOL) shouldAutorotate { - return YES; -} - -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end diff --git a/plugin/samples/HelloShare/proj.ios/main.m b/plugin/samples/HelloShare/proj.ios/main.m deleted file mode 100644 index f607c969a3..0000000000 --- a/plugin/samples/HelloShare/proj.ios/main.m +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012-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. -****************************************************************************/ - -#import - -// Under iOS and the Simulator, we can use an alternate Accelerometer interface -#import "AccelerometerSimulation.h" - -int main(int argc, char *argv[]) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); - [pool release]; - return retVal; -} diff --git a/plugin/samples/HelloUser/Resources/alipay_plugin.apk.REMOVED.git-id b/plugin/samples/HelloUser/Resources/alipay_plugin.apk.REMOVED.git-id deleted file mode 100644 index 8b0739a130..0000000000 --- a/plugin/samples/HelloUser/Resources/alipay_plugin.apk.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -761ab0ca76abcdc06890e579f77fcdea6afa83c6 \ No newline at end of file diff --git a/plugin/samples/HelloUser/Resources/pro.jar.REMOVED.git-id b/plugin/samples/HelloUser/Resources/pro.jar.REMOVED.git-id deleted file mode 100644 index 23c54c6ba3..0000000000 --- a/plugin/samples/HelloUser/Resources/pro.jar.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -0cb89ef70f9172baa023fcbae9b87da09af2e776 \ No newline at end of file diff --git a/plugin/samples/HelloUser/proj.android/.classpath b/plugin/samples/HelloUser/proj.android/.classpath deleted file mode 100644 index 6cffa0e876..0000000000 --- a/plugin/samples/HelloUser/proj.android/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/plugin/samples/HelloUser/proj.android/AndroidManifest.xml b/plugin/samples/HelloUser/proj.android/AndroidManifest.xml deleted file mode 100644 index 5967950d64..0000000000 --- a/plugin/samples/HelloUser/proj.android/AndroidManifest.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/samples/HelloUser/proj.android/README.md b/plugin/samples/HelloUser/proj.android/README.md deleted file mode 100644 index 312835611a..0000000000 --- a/plugin/samples/HelloUser/proj.android/README.md +++ /dev/null @@ -1,87 +0,0 @@ -## Prerequisites: - -* Android NDK -* Android SDK **OR** Eclipse ADT Bundle -* Android AVD target installed - -## Building project - -There are two ways of building Android projects. - -1. Eclipse -2. Command Line - -### Import Project in Eclipse - -#### Features: - -1. Complete workflow from Eclipse, including: - * Build C++. - * Clean C++. - * Build and Run whole project. - * Logcat view. - * Debug Java code. - * Javascript editor. - * Project management. -2. True C++ editing, including: - * Code completion. - * Jump to definition. - * Refactoring tools etc. - * Quick open C++ files. - - -#### Setup Eclipse Environment (only once) - - -**NOTE:** This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. Skip this section if you've done this before. - -1. Download Eclipse ADT bundle from [Google ADT homepage](http://developer.android.com/sdk/index.html) - - **OR** - - Install Eclipse with Java. Add ADT and CDT plugins. - -2. Only for Windows - 1. Install [Cygwin](http://www.cygwin.com/) with make (select make package from the list during the install). - 2. Add `Cygwin\bin` directory to system PATH variable. - 3. Add this line `none /cygdrive cygdrive binary,noacl,posix=0,user 0 0` to `Cygwin\etc\fstab` file. - -3. Set up Variables: - 1. Path Variable `COCOS2DX`: - * Eclipse->Preferences->General->Workspace->**Linked Resources** - * Click **New** button to add a Path Variable `COCOS2DX` pointing to the root cocos2d-x directory. - ![Example](https://lh5.googleusercontent.com/-oPpk9kg3e5w/UUOYlq8n7aI/AAAAAAAAsdQ/zLA4eghBH9U/s400/cocos2d-x-eclipse-vars.png) - - 2. C/C++ Environment Variable `NDK_ROOT`: - * Eclipse->Preferences->C/C++->Build->**Environment**. - * Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. - ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) - * Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` - -4. Import libcocos2dx library project: - 1. File->New->Project->Android Project From Existing Code. - 2. Click **Browse** button and open `cocos2d-x/cocos2dx/platform/android/java` directory. - 3. Click **Finish** to add project. - -#### Adding and running from Eclipse - -![Example](https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png) ![Import](https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png) - -1. File->New->Project->Android Project From Existing Code -2. **Browse** to your project directory. eg: `cocos2d-x/cocos2dx/samples/Cpp/TestCpp/proj.android/` -3. Add the project -4. Click **Run** or **Debug** to compile C++ followed by Java and to run on connected device or emulator. - - -### Running project from Command Line - - $ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ - $ export NDK_ROOT=/path/to/ndk - $ ./build_native.sh - $ ant debug install - -If the last command results in sdk.dir missing error then do: - - $ android list target - $ android update project -p . -t (id from step 6) - $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6) diff --git a/plugin/samples/HelloUser/proj.android/ant.properties b/plugin/samples/HelloUser/proj.android/ant.properties deleted file mode 100644 index b0971e891e..0000000000 --- a/plugin/samples/HelloUser/proj.android/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/plugin/samples/HelloUser/proj.android/build_native.sh b/plugin/samples/HelloUser/proj.android/build_native.sh deleted file mode 100755 index e1dec28a1d..0000000000 --- a/plugin/samples/HelloUser/proj.android/build_native.sh +++ /dev/null @@ -1,78 +0,0 @@ -APPNAME="HelloUser" - -# options - -buildexternalsfromsource= - -usage(){ -cat << EOF -usage: $0 [options] - -Build C/C++ code for $APPNAME using Android NDK - -OPTIONS: --s Build externals from source --h this help -EOF -} - -while getopts "sh" OPTION; do -case "$OPTION" in -s) -buildexternalsfromsource=1 -;; -h) -usage -exit 0 -;; -esac -done - -# paths - -if [ -z "${NDK_ROOT+aaa}" ];then -echo "please define NDK_ROOT" -exit 1 -fi - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# ... use paths relative to current directory -PLUGIN_ROOT="$DIR/../../.." -COCOS2DX_ROOT="$DIR/../../../.." -APP_ROOT="$DIR/.." -APP_ANDROID_ROOT="$DIR" - -echo "NDK_ROOT = $NDK_ROOT" -echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" -echo "APP_ROOT = $APP_ROOT" -echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" - -# make sure assets is exist -if [ -d "$APP_ANDROID_ROOT"/assets ]; then - rm -rf "$APP_ANDROID_ROOT"/assets -fi - -mkdir "$APP_ANDROID_ROOT"/assets - -# copy resources -for file in "$APP_ROOT"/Resources/* -do -if [ -d "$file" ]; then - cp -rf "$file" "$APP_ANDROID_ROOT"/assets -fi - -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/assets -fi -done - -# run ndk-build -if [[ "$buildexternalsfromsource" ]]; then - echo "Building external dependencies from source" - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" -else - echo "Using prebuilt externals" - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" -fi diff --git a/plugin/samples/HelloUser/proj.android/jni/Android.mk b/plugin/samples/HelloUser/proj.android/jni/Android.mk deleted file mode 100644 index 4679003bc3..0000000000 --- a/plugin/samples/HelloUser/proj.android/jni/Android.mk +++ /dev/null @@ -1,23 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos2dcpp_shared - -LOCAL_MODULE_FILENAME := libcocos2dcpp - -LOCAL_SRC_FILES := hellocpp/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp \ - ../../Classes/MyUserManager.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static \ -PluginProtocolStatic - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) - -$(call import-module,protocols/android) diff --git a/plugin/samples/HelloUser/proj.android/jni/Application.mk b/plugin/samples/HelloUser/proj.android/jni/Application.mk deleted file mode 100644 index 43499d7113..0000000000 --- a/plugin/samples/HelloUser/proj.android/jni/Application.mk +++ /dev/null @@ -1,3 +0,0 @@ -APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -NDK_TOOLCHAIN_VERSION=4.7 diff --git a/plugin/samples/HelloUser/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloUser/proj.android/jni/hellocpp/main.cpp deleted file mode 100644 index 9d2d9ef439..0000000000 --- a/plugin/samples/HelloUser/proj.android/jni/hellocpp/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "AppDelegate.h" -#include "cocos2d.h" -#include "CCEventType.h" -#include "platform/android/jni/JniHelper.h" -#include -#include -#include "PluginJniHelper.h" - -#define LOG_TAG "main" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) - -using namespace cocos2d; - -extern "C" -{ - -jint JNI_OnLoad(JavaVM *vm, void *reserved) -{ - JniHelper::setJavaVM(vm); - PluginJniHelper::setJavaVM(vm); - return JNI_VERSION_1_4; -} - -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) -{ - if (!Director::sharedDirector()->getOpenGLView()) - { - EGLView *view = EGLView::sharedOpenGLView(); - view->setFrameSize(w, h); - - AppDelegate *pAppDelegate = new AppDelegate(); - Application::sharedApplication()->run(); - } - /* - else - { - ccDrawInit(); - ccGLInvalidateStateCache(); - - ShaderCache::sharedShaderCache()->reloadDefaultShaders(); - TextureCache::reloadAllTextures(); - NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); - Director::sharedDirector()->setGLDefaultValues(); - } - */ -} - -} diff --git a/plugin/samples/HelloUser/proj.android/proguard-project.txt b/plugin/samples/HelloUser/proj.android/proguard-project.txt deleted file mode 100644 index f2fe1559a2..0000000000 --- a/plugin/samples/HelloUser/proj.android/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/plugin/samples/HelloUser/proj.android/res/values/strings.xml b/plugin/samples/HelloUser/proj.android/res/values/strings.xml deleted file mode 100644 index 35d82d2614..0000000000 --- a/plugin/samples/HelloUser/proj.android/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - HelloUser - diff --git a/plugin/samples/HelloUser/proj.android/src/org/cocos2dx/HelloUser/HelloUser.java b/plugin/samples/HelloUser/proj.android/src/org/cocos2dx/HelloUser/HelloUser.java deleted file mode 100644 index aeb10ef581..0000000000 --- a/plugin/samples/HelloUser/proj.android/src/org/cocos2dx/HelloUser/HelloUser.java +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 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.HelloUser; - -import org.cocos2dx.lib.Cocos2dxActivity; -import org.cocos2dx.lib.Cocos2dxGLSurfaceView; -import org.cocos2dx.plugin.PluginWrapper; - -import android.os.Bundle; - -public class HelloUser extends Cocos2dxActivity{ - - protected void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - - PluginWrapper.init(this); - PluginWrapper.setGLSurfaceView(Cocos2dxGLSurfaceView.getInstance()); - } - - public Cocos2dxGLSurfaceView onCreateView() { - Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); - // HelloUser should create stencil buffer - glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); - - return glSurfaceView; - } - - static { - System.loadLibrary("cocos2dcpp"); - } -} diff --git a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp index 430260c1f5..f5c8f341c5 100644 --- a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp +++ b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp @@ -1,6 +1,6 @@ #include "KeyboardTest.h" -#ifdef KEYBOARD_SUPPORT +#ifdef CC_KEYBOARD_SUPPORT KeyboardTest::KeyboardTest() { diff --git a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.h b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.h index 2586741b2f..f688037834 100644 --- a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.h +++ b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.h @@ -1,7 +1,7 @@ #ifndef _KEYBOARD_TEST_H_ #define _KEYBOARD_TEST_H_ -#ifdef KEYBOARD_SUPPORT +#ifdef CC_KEYBOARD_SUPPORT #include "cocos2d.h" #include "../testBasic.h" diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp index ee41c03f98..944b50dca2 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp @@ -16,7 +16,9 @@ static std::function createFunctions[] = { CL(LayerTest1), CL(LayerTest2), CL(LayerTestBlend), - CL(LayerGradient), + CL(LayerGradientTest), + CL(LayerGradientTest2), + CL(LayerGradientTest3), CL(LayerIgnoreAnchorPointPos), CL(LayerIgnoreAnchorPointRot), CL(LayerIgnoreAnchorPointScale), @@ -581,7 +583,7 @@ std::string LayerTestBlend::title() //------------------------------------------------------------------ // -// LayerGradient +// LayerGradientTest // //------------------------------------------------------------------ LayerGradientTest::LayerGradientTest() @@ -633,6 +635,51 @@ string LayerGradientTest::subtitle() return "Touch the screen and move your finger"; } +//------------------------------------------------------------------ +// +// LayerGradientTest2 +// +//------------------------------------------------------------------ +LayerGradientTest2::LayerGradientTest2() +{ + LayerGradient* layer = new LayerGradient; + layer->initWithColor(ccc4(255,0,0,255), ccc4(255,255,0,255)); + layer->autorelease(); + addChild(layer); +} + +std::string LayerGradientTest2::title() +{ + return "LayerGradientTest 2"; +} + +string LayerGradientTest2::subtitle() +{ + return "You should see a gradient"; +} + + +//------------------------------------------------------------------ +// +// LayerGradientTest3 +// +//------------------------------------------------------------------ +LayerGradientTest3::LayerGradientTest3() +{ + LayerGradient* layer1 = LayerGradient::create(ccc4(255,0,0,255), ccc4(255,255,0,255)); + addChild(layer1); +} + +std::string LayerGradientTest3::title() +{ + return "LayerGradientTest 3"; +} + +string LayerGradientTest3::subtitle() +{ + return "You should see a gradient"; +} + // LayerIgnoreAnchorPointPos #define kLayerIgnoreAnchorPoint 1000 diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h index 7f3f66188a..7dd3186959 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h @@ -105,6 +105,22 @@ public: void toggleItem(cocos2d::Object *sender); }; +class LayerGradientTest2 : public LayerTest +{ +public: + LayerGradientTest2(); + virtual std::string title(); + virtual std::string subtitle(); +}; + +class LayerGradientTest3 : public LayerTest +{ +public: + LayerGradientTest3(); + virtual std::string title(); + virtual std::string subtitle(); +}; + class LayerIgnoreAnchorPointPos : public LayerTest { public: diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index 46b931a430..e2bc5e59a6 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -49,7 +49,7 @@ struct { { "FileUtilsTest", []() { return new FileUtilsTestScene(); } }, { "FontTest", []() { return new FontTestScene(); } }, { "IntervalTest", [](){return new IntervalTestScene(); } }, -#ifdef KEYBOARD_SUPPORT +#ifdef CC_KEYBOARD_SUPPORT { "KeyboardTest", []() { return new KeyboardTestScene(); } }, #endif #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) diff --git a/samples/Cpp/TestCpp/Classes/tests.h b/samples/Cpp/TestCpp/Classes/tests.h index 7b2b9b2464..c9c119f2cd 100644 --- a/samples/Cpp/TestCpp/Classes/tests.h +++ b/samples/Cpp/TestCpp/Classes/tests.h @@ -29,7 +29,7 @@ #include "EffectsAdvancedTest/EffectsAdvancedTest.h" #include "AccelerometerTest/AccelerometerTest.h" #include "KeypadTest/KeypadTest.h" -#ifdef KEYBOARD_SUPPORT +#ifdef CC_KEYBOARD_SUPPORT #include "KeyboardTest/KeyboardTest.h" #endif #include "PerformanceTest/PerformanceTest.h" diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index 00c2445c4b..62c38a39cc 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -1,6 +1,6 @@ EXECUTABLE = TestCpp -DEFINES += -DKEYBOARD_SUPPORT +DEFINES += -DCC_KEYBOARD_SUPPORT SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ActionManagerTest/ActionManagerTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/Cpp/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 076eec3ddf..8f9958a187 100644 --- a/samples/Cpp/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/Cpp/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -9ae9939f85833280aac46f6be8bddf05b869bab8 \ No newline at end of file +226867e25e3d039a278ae385c4b8822461b82427 \ No newline at end of file diff --git a/plugin/samples/HelloAnalytics/proj.ios/AppController.h b/samples/Javascript/TestJavascript/proj.mac/AppController.h old mode 100755 new mode 100644 similarity index 77% rename from plugin/samples/HelloAnalytics/proj.ios/AppController.h rename to samples/Javascript/TestJavascript/proj.mac/AppController.h index 3d51064ca0..96c717304b --- a/plugin/samples/HelloAnalytics/proj.ios/AppController.h +++ b/samples/Javascript/TestJavascript/proj.mac/AppController.h @@ -22,12 +22,21 @@ THE SOFTWARE. ****************************************************************************/ -@class RootViewController; +#pragma once -@interface AppController : NSObject { - UIWindow *window; - RootViewController *viewController; -} +#import "cocos2d.h" +#import "EAGLView.h" + +@interface AppController : NSObject + { + NSWindow *window; + CCEAGLView *glView; + } + + @property (nonatomic, assign) IBOutlet NSWindow* window; + @property (nonatomic, assign) IBOutlet CCEAGLView* glView; + + -(IBAction) toggleFullScreen:(id)sender; + -(IBAction) exitFullScreen:(id)sender; @end - diff --git a/samples/Javascript/TestJavascript/proj.mac/AppController.mm b/samples/Javascript/TestJavascript/proj.mac/AppController.mm new file mode 100644 index 0000000000..43d05cf28a --- /dev/null +++ b/samples/Javascript/TestJavascript/proj.mac/AppController.mm @@ -0,0 +1,93 @@ +/**************************************************************************** + Copyright (c) 2010 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. + ****************************************************************************/ + +#import "AppController.h" +#import "AppDelegate.h" + +@implementation AppController + + static AppDelegate s_sharedApplication; + + @synthesize window, glView; + + -(void) applicationDidFinishLaunching:(NSNotification *)aNotification + { + // create the window + // note that using NSResizableWindowMask causes the window to be a little + // smaller and therefore ipad graphics are not loaded + NSRect rect = NSMakeRect(100, 100, 800, 450); + window = [[NSWindow alloc] initWithContentRect:rect + styleMask:( NSClosableWindowMask | NSTitledWindowMask ) + backing:NSBackingStoreBuffered + defer:YES]; + + NSOpenGLPixelFormatAttribute attributes[] = { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFADepthSize, 24, + NSOpenGLPFAStencilSize, 8, + 0 + }; + + NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease]; + + // allocate our GL view + // (isn't there already a shared CCEAGLView?) + glView = [[CCEAGLView alloc] initWithFrame:rect pixelFormat:pixelFormat]; + + // set window parameters + [window becomeFirstResponder]; + [window setContentView:glView]; + [window setTitle:@"TestCpp"]; + [window makeKeyAndOrderFront:self]; + [window setAcceptsMouseMovedEvents:NO]; + + cocos2d::Application::sharedApplication()->run(); + } + + -(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication + { + return YES; + } + + -(void) dealloc + { + cocos2d::Director::sharedDirector()->end(); + [super dealloc]; + } + +#pragma mark - +#pragma mark IB Actions + + -(IBAction) toggleFullScreen:(id)sender + { + CCEAGLView* pView = [CCEAGLView sharedEGLView]; + [pView setFullScreen:!pView.isFullScreen]; + } + + -(IBAction) exitFullScreen:(id)sender + { + [[CCEAGLView sharedEGLView] setFullScreen:NO]; + } + +@end diff --git a/samples/Javascript/TestJavascript/proj.mac/Icon.icns b/samples/Javascript/TestJavascript/proj.mac/Icon.icns new file mode 100644 index 0000000000..285dee82b3 Binary files /dev/null and b/samples/Javascript/TestJavascript/proj.mac/Icon.icns differ diff --git a/samples/Javascript/TestJavascript/proj.mac/TestJavascript.xcodeproj/project.pbxproj b/samples/Javascript/TestJavascript/proj.mac/TestJavascript.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..f493c8157b --- /dev/null +++ b/samples/Javascript/TestJavascript/proj.mac/TestJavascript.xcodeproj/project.pbxproj @@ -0,0 +1,825 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 15A3D5631682F20C002FB0C5 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 15A3D4621682F14C002FB0C5 /* main.js */; }; + 15A3D5651682F20C002FB0C5 /* tests_resources-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 15A3D4711682F14C002FB0C5 /* tests_resources-jsb.js */; }; + 15A3D5681682F20C002FB0C5 /* tests-main.js in Resources */ = {isa = PBXBuildFile; fileRef = 15A3D4741682F14C002FB0C5 /* tests-main.js */; }; + 1A4C3F1317784B6000EDFB3B /* libchipmunk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F0E17784B6000EDFB3B /* libchipmunk.a */; }; + 1A4C3F1417784B6000EDFB3B /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F0F17784B6000EDFB3B /* libcocos2dx.a */; }; + 1A4C3F1517784B6000EDFB3B /* libCocosDenshion.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F1017784B6000EDFB3B /* libCocosDenshion.a */; }; + 1A4C3F1617784B6000EDFB3B /* libextensions.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F1117784B6000EDFB3B /* libextensions.a */; }; + 1A4C3F1717784B6000EDFB3B /* libjsbindings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F1217784B6000EDFB3B /* libjsbindings.a */; }; + 1A6B05C517782A2400FFE52B /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A6B05C417782A2400FFE52B /* libsqlite3.dylib */; }; + 1A6B05C717782B0500FFE52B /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A6B05C617782B0500FFE52B /* libz.dylib */; }; + 1A6E468A177812D20055514D /* jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4672177812AF0055514D /* jsb.js */; }; + 1A6E468B177812D20055514D /* jsb_chipmunk.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4673177812AF0055514D /* jsb_chipmunk.js */; }; + 1A6E468C177812D20055514D /* jsb_chipmunk_constants.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4674177812AF0055514D /* jsb_chipmunk_constants.js */; }; + 1A6E468D177812D20055514D /* jsb_cocos2d.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4675177812AF0055514D /* jsb_cocos2d.js */; }; + 1A6E468E177812D20055514D /* jsb_cocos2d_constants.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4676177812AF0055514D /* jsb_cocos2d_constants.js */; }; + 1A6E468F177812D20055514D /* jsb_cocos2d_extension.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4677177812AF0055514D /* jsb_cocos2d_extension.js */; }; + 1A6E4690177812D20055514D /* jsb_cocosbuilder.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4678177812AF0055514D /* jsb_cocosbuilder.js */; }; + 1A6E4691177812D20055514D /* jsb_debugger.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E4679177812AF0055514D /* jsb_debugger.js */; }; + 1A6E4692177812D20055514D /* jsb_opengl.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E467A177812AF0055514D /* jsb_opengl.js */; }; + 1A6E4693177812D20055514D /* jsb_opengl_constants.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E467B177812AF0055514D /* jsb_opengl_constants.js */; }; + 1A6E4694177812D20055514D /* jsb_sys.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E467C177812AF0055514D /* jsb_sys.js */; }; + 1A6E4695177812D20055514D /* main.debug.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6E467D177812AF0055514D /* main.debug.js */; }; + 1A80332A1728DECD00240CC3 /* EffectsAdvancedTest in Resources */ = {isa = PBXBuildFile; fileRef = 1A8033291728DECD00240CC3 /* EffectsAdvancedTest */; }; + 1A80332C1728F1FB00240CC3 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 1A80332B1728F1FB00240CC3 /* res */; }; + 1AA51A9F16F708FA000FDF05 /* ActionManagerTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7816F708FA000FDF05 /* ActionManagerTest */; }; + 1AA51AA016F708FA000FDF05 /* ActionsTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7916F708FA000FDF05 /* ActionsTest */; }; + 1AA51AA116F708FA000FDF05 /* BaseTestLayer in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7A16F708FA000FDF05 /* BaseTestLayer */; }; + 1AA51AA216F708FA000FDF05 /* Box2dTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7B16F708FA000FDF05 /* Box2dTest */; }; + 1AA51AA316F708FA000FDF05 /* ChipmunkTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7C16F708FA000FDF05 /* ChipmunkTest */; }; + 1AA51AA416F708FA000FDF05 /* ClickAndMoveTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7D16F708FA000FDF05 /* ClickAndMoveTest */; }; + 1AA51AA516F708FA000FDF05 /* CocosDenshionTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7E16F708FA000FDF05 /* CocosDenshionTest */; }; + 1AA51AA616F708FA000FDF05 /* CocosNodeTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A7F16F708FA000FDF05 /* CocosNodeTest */; }; + 1AA51AA716F708FA000FDF05 /* CurrentLanguageTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8016F708FA000FDF05 /* CurrentLanguageTest */; }; + 1AA51AA816F708FA000FDF05 /* DrawPrimitivesTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8116F708FA000FDF05 /* DrawPrimitivesTest */; }; + 1AA51AA916F708FA000FDF05 /* EaseActionsTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8216F708FA000FDF05 /* EaseActionsTest */; }; + 1AA51AAA16F708FA000FDF05 /* EffectsTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8316F708FA000FDF05 /* EffectsTest */; }; + 1AA51AAB16F708FA000FDF05 /* EventTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8416F708FA000FDF05 /* EventTest */; }; + 1AA51AAC16F708FA000FDF05 /* ExtensionsTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8516F708FA000FDF05 /* ExtensionsTest */; }; + 1AA51AAD16F708FA000FDF05 /* FileUtils in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8616F708FA000FDF05 /* FileUtils */; }; + 1AA51AAE16F708FA000FDF05 /* FontTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8716F708FA000FDF05 /* FontTest */; }; + 1AA51AAF16F708FA000FDF05 /* IntervalTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8816F708FA000FDF05 /* IntervalTest */; }; + 1AA51AB016F708FA000FDF05 /* LabelTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8916F708FA000FDF05 /* LabelTest */; }; + 1AA51AB116F708FA000FDF05 /* LayerTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8A16F708FA000FDF05 /* LayerTest */; }; + 1AA51AB216F708FA000FDF05 /* MenuTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8B16F708FA000FDF05 /* MenuTest */; }; + 1AA51AB316F708FA000FDF05 /* OpenGLTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8C16F708FA000FDF05 /* OpenGLTest */; }; + 1AA51AB416F708FA000FDF05 /* ParallaxTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8D16F708FA000FDF05 /* ParallaxTest */; }; + 1AA51AB516F708FA000FDF05 /* ParticleTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8E16F708FA000FDF05 /* ParticleTest */; }; + 1AA51AB616F708FA000FDF05 /* PerformanceTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A8F16F708FA000FDF05 /* PerformanceTest */; }; + 1AA51AB716F708FA000FDF05 /* Presentation in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9016F708FA000FDF05 /* Presentation */; }; + 1AA51AB816F708FA000FDF05 /* ProgressActionsTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9116F708FA000FDF05 /* ProgressActionsTest */; }; + 1AA51AB916F708FA000FDF05 /* RenderTextureTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9216F708FA000FDF05 /* RenderTextureTest */; }; + 1AA51ABB16F708FA000FDF05 /* RotateWorldTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9416F708FA000FDF05 /* RotateWorldTest */; }; + 1AA51ABC16F708FA000FDF05 /* SceneTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9516F708FA000FDF05 /* SceneTest */; }; + 1AA51ABD16F708FA000FDF05 /* SchedulerTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9616F708FA000FDF05 /* SchedulerTest */; }; + 1AA51ABE16F708FA000FDF05 /* SpriteTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9716F708FA000FDF05 /* SpriteTest */; }; + 1AA51ABF16F708FA000FDF05 /* SysTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9816F708FA000FDF05 /* SysTest */; }; + 1AA51AC016F708FA000FDF05 /* TextInputTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9916F708FA000FDF05 /* TextInputTest */; }; + 1AA51AC116F708FA000FDF05 /* TextureCacheTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9A16F708FA000FDF05 /* TextureCacheTest */; }; + 1AA51AC216F708FA000FDF05 /* TileMapTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9B16F708FA000FDF05 /* TileMapTest */; }; + 1AA51AC316F708FA000FDF05 /* TouchesTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9C16F708FA000FDF05 /* TouchesTest */; }; + 1AA51AC416F708FA000FDF05 /* TransitionsTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9D16F708FA000FDF05 /* TransitionsTest */; }; + 1AA51AC516F708FA000FDF05 /* UnitTest in Resources */ = {isa = PBXBuildFile; fileRef = 1AA51A9E16F708FA000FDF05 /* UnitTest */; }; + A05FCAC8177C123600BE600E /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAC7177C123600BE600E /* OpenGL.framework */; }; + A05FCAC9177C123F00BE600E /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAC7177C123600BE600E /* OpenGL.framework */; }; + A05FCACC177C125300BE600E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCACB177C125300BE600E /* Cocoa.framework */; }; + A05FCACD177C125800BE600E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCACB177C125300BE600E /* Cocoa.framework */; }; + A05FCAD6177C129100BE600E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A05FCACF177C129100BE600E /* InfoPlist.strings */; }; + A05FCAD7177C129100BE600E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A05FCACF177C129100BE600E /* InfoPlist.strings */; }; + A05FCAD8177C129100BE600E /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A05FCAD1177C129100BE600E /* MainMenu.xib */; }; + A05FCAD9177C129100BE600E /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A05FCAD1177C129100BE600E /* MainMenu.xib */; }; + A05FCADA177C129100BE600E /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = A05FCAD3177C129100BE600E /* Icon.icns */; }; + A05FCADB177C129100BE600E /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = A05FCAD3177C129100BE600E /* Icon.icns */; }; + A05FCAE1177C12B500BE600E /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = A05FCAE0177C12B500BE600E /* AppController.mm */; }; + A05FCAE2177C12B500BE600E /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = A05FCAE0177C12B500BE600E /* AppController.mm */; }; + A05FCAEC177C1FBB00BE600E /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAEB177C1FBB00BE600E /* libcurl.dylib */; }; + A05FCAEE177C208D00BE600E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A05FCAED177C208D00BE600E /* main.m */; }; + A05FCAEF177C208D00BE600E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A05FCAED177C208D00BE600E /* main.m */; }; + A05FCAF1177C273700BE600E /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAF0177C273700BE600E /* ApplicationServices.framework */; }; + A218F7DC1743D97E00F65883 /* XHRTest in Resources */ = {isa = PBXBuildFile; fileRef = A218F7DB1743D97E00F65883 /* XHRTest */; }; + A22656EF1743DCBB00598A2C /* ClippingNodeTest in Resources */ = {isa = PBXBuildFile; fileRef = A22656EE1743DCBB00598A2C /* ClippingNodeTest */; }; + A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275411517C094001B78AA /* QuartzCore.framework */; }; + A92275461517C094001B78AA /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275451517C094001B78AA /* OpenAL.framework */; }; + A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275471517C094001B78AA /* AudioToolbox.framework */; }; + A922754E1517C094001B78AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; + A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; + D401B61116FB637400F2529D /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4545215156E28EF00887EB5 /* AppDelegate.cpp */; }; + D401B67D16FB637400F2529D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275411517C094001B78AA /* QuartzCore.framework */; }; + D401B67F16FB637400F2529D /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275451517C094001B78AA /* OpenAL.framework */; }; + D401B68016FB637400F2529D /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275471517C094001B78AA /* AudioToolbox.framework */; }; + D401B68116FB637400F2529D /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275491517C094001B78AA /* AVFoundation.framework */; }; + D401B68316FB637400F2529D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; + D401B68416FB637400F2529D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; + D401B6D716FBF49A00F2529D /* game.js in Resources */ = {isa = PBXBuildFile; fileRef = D401B6D516FBF48000F2529D /* game.js */; }; + D401B6E016FC072B00F2529D /* tests-boot-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = D401B6DE16FC071100F2529D /* tests-boot-jsb.js */; }; + D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4545215156E28EF00887EB5 /* AppDelegate.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 15A3D4621682F14C002FB0C5 /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = ../../Shared/tests/main.js; sourceTree = ""; }; + 15A3D4711682F14C002FB0C5 /* tests_resources-jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "tests_resources-jsb.js"; path = "../../Shared/tests/tests_resources-jsb.js"; sourceTree = ""; }; + 15A3D4741682F14C002FB0C5 /* tests-main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "tests-main.js"; path = "../../Shared/tests/tests-main.js"; sourceTree = ""; }; + 1A4C3F0E17784B6000EDFB3B /* libchipmunk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libchipmunk.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A4C3F0F17784B6000EDFB3B /* libcocos2dx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libcocos2dx.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A4C3F1017784B6000EDFB3B /* libCocosDenshion.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libCocosDenshion.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A4C3F1117784B6000EDFB3B /* libextensions.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libextensions.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A4C3F1217784B6000EDFB3B /* libjsbindings.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libjsbindings.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A6B05C417782A2400FFE52B /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; + 1A6B05C617782B0500FFE52B /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + 1A6E4672177812AF0055514D /* jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb.js; sourceTree = ""; }; + 1A6E4673177812AF0055514D /* jsb_chipmunk.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_chipmunk.js; sourceTree = ""; }; + 1A6E4674177812AF0055514D /* jsb_chipmunk_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_chipmunk_constants.js; sourceTree = ""; }; + 1A6E4675177812AF0055514D /* jsb_cocos2d.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d.js; sourceTree = ""; }; + 1A6E4676177812AF0055514D /* jsb_cocos2d_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d_constants.js; sourceTree = ""; }; + 1A6E4677177812AF0055514D /* jsb_cocos2d_extension.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d_extension.js; sourceTree = ""; }; + 1A6E4678177812AF0055514D /* jsb_cocosbuilder.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocosbuilder.js; sourceTree = ""; }; + 1A6E4679177812AF0055514D /* jsb_debugger.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_debugger.js; sourceTree = ""; }; + 1A6E467A177812AF0055514D /* jsb_opengl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_opengl.js; sourceTree = ""; }; + 1A6E467B177812AF0055514D /* jsb_opengl_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_opengl_constants.js; sourceTree = ""; }; + 1A6E467C177812AF0055514D /* jsb_sys.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_sys.js; sourceTree = ""; }; + 1A6E467D177812AF0055514D /* main.debug.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = main.debug.js; sourceTree = ""; }; + 1A8033291728DECD00240CC3 /* EffectsAdvancedTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = EffectsAdvancedTest; path = ../../Shared/tests/EffectsAdvancedTest; sourceTree = ""; }; + 1A80332B1728F1FB00240CC3 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = ../../Shared/tests/res; sourceTree = ""; }; + 1AA51A7816F708FA000FDF05 /* ActionManagerTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ActionManagerTest; path = ../../Shared/tests/ActionManagerTest; sourceTree = ""; }; + 1AA51A7916F708FA000FDF05 /* ActionsTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ActionsTest; path = ../../Shared/tests/ActionsTest; sourceTree = ""; }; + 1AA51A7A16F708FA000FDF05 /* BaseTestLayer */ = {isa = PBXFileReference; lastKnownFileType = folder; name = BaseTestLayer; path = ../../Shared/tests/BaseTestLayer; sourceTree = ""; }; + 1AA51A7B16F708FA000FDF05 /* Box2dTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Box2dTest; path = ../../Shared/tests/Box2dTest; sourceTree = ""; }; + 1AA51A7C16F708FA000FDF05 /* ChipmunkTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ChipmunkTest; path = ../../Shared/tests/ChipmunkTest; sourceTree = ""; }; + 1AA51A7D16F708FA000FDF05 /* ClickAndMoveTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ClickAndMoveTest; path = ../../Shared/tests/ClickAndMoveTest; sourceTree = ""; }; + 1AA51A7E16F708FA000FDF05 /* CocosDenshionTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = CocosDenshionTest; path = ../../Shared/tests/CocosDenshionTest; sourceTree = ""; }; + 1AA51A7F16F708FA000FDF05 /* CocosNodeTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = CocosNodeTest; path = ../../Shared/tests/CocosNodeTest; sourceTree = ""; }; + 1AA51A8016F708FA000FDF05 /* CurrentLanguageTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = CurrentLanguageTest; path = ../../Shared/tests/CurrentLanguageTest; sourceTree = ""; }; + 1AA51A8116F708FA000FDF05 /* DrawPrimitivesTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = DrawPrimitivesTest; path = ../../Shared/tests/DrawPrimitivesTest; sourceTree = ""; }; + 1AA51A8216F708FA000FDF05 /* EaseActionsTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = EaseActionsTest; path = ../../Shared/tests/EaseActionsTest; sourceTree = ""; }; + 1AA51A8316F708FA000FDF05 /* EffectsTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = EffectsTest; path = ../../Shared/tests/EffectsTest; sourceTree = ""; }; + 1AA51A8416F708FA000FDF05 /* EventTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = EventTest; path = ../../Shared/tests/EventTest; sourceTree = ""; }; + 1AA51A8516F708FA000FDF05 /* ExtensionsTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ExtensionsTest; path = ../../Shared/tests/ExtensionsTest; sourceTree = ""; }; + 1AA51A8616F708FA000FDF05 /* FileUtils */ = {isa = PBXFileReference; lastKnownFileType = folder; name = FileUtils; path = ../../Shared/tests/FileUtils; sourceTree = ""; }; + 1AA51A8716F708FA000FDF05 /* FontTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = FontTest; path = ../../Shared/tests/FontTest; sourceTree = ""; }; + 1AA51A8816F708FA000FDF05 /* IntervalTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = IntervalTest; path = ../../Shared/tests/IntervalTest; sourceTree = ""; }; + 1AA51A8916F708FA000FDF05 /* LabelTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = LabelTest; path = ../../Shared/tests/LabelTest; sourceTree = ""; }; + 1AA51A8A16F708FA000FDF05 /* LayerTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = LayerTest; path = ../../Shared/tests/LayerTest; sourceTree = ""; }; + 1AA51A8B16F708FA000FDF05 /* MenuTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = MenuTest; path = ../../Shared/tests/MenuTest; sourceTree = ""; }; + 1AA51A8C16F708FA000FDF05 /* OpenGLTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = OpenGLTest; path = ../../Shared/tests/OpenGLTest; sourceTree = ""; }; + 1AA51A8D16F708FA000FDF05 /* ParallaxTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ParallaxTest; path = ../../Shared/tests/ParallaxTest; sourceTree = ""; }; + 1AA51A8E16F708FA000FDF05 /* ParticleTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ParticleTest; path = ../../Shared/tests/ParticleTest; sourceTree = ""; }; + 1AA51A8F16F708FA000FDF05 /* PerformanceTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = PerformanceTest; path = ../../Shared/tests/PerformanceTest; sourceTree = ""; }; + 1AA51A9016F708FA000FDF05 /* Presentation */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Presentation; path = ../../Shared/tests/Presentation; sourceTree = ""; }; + 1AA51A9116F708FA000FDF05 /* ProgressActionsTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ProgressActionsTest; path = ../../Shared/tests/ProgressActionsTest; sourceTree = ""; }; + 1AA51A9216F708FA000FDF05 /* RenderTextureTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = RenderTextureTest; path = ../../Shared/tests/RenderTextureTest; sourceTree = ""; }; + 1AA51A9416F708FA000FDF05 /* RotateWorldTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = RotateWorldTest; path = ../../Shared/tests/RotateWorldTest; sourceTree = ""; }; + 1AA51A9516F708FA000FDF05 /* SceneTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SceneTest; path = ../../Shared/tests/SceneTest; sourceTree = ""; }; + 1AA51A9616F708FA000FDF05 /* SchedulerTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SchedulerTest; path = ../../Shared/tests/SchedulerTest; sourceTree = ""; }; + 1AA51A9716F708FA000FDF05 /* SpriteTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SpriteTest; path = ../../Shared/tests/SpriteTest; sourceTree = ""; }; + 1AA51A9816F708FA000FDF05 /* SysTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SysTest; path = ../../Shared/tests/SysTest; sourceTree = ""; }; + 1AA51A9916F708FA000FDF05 /* TextInputTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TextInputTest; path = ../../Shared/tests/TextInputTest; sourceTree = ""; }; + 1AA51A9A16F708FA000FDF05 /* TextureCacheTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TextureCacheTest; path = ../../Shared/tests/TextureCacheTest; sourceTree = ""; }; + 1AA51A9B16F708FA000FDF05 /* TileMapTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TileMapTest; path = ../../Shared/tests/TileMapTest; sourceTree = ""; }; + 1AA51A9C16F708FA000FDF05 /* TouchesTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TouchesTest; path = ../../Shared/tests/TouchesTest; sourceTree = ""; }; + 1AA51A9D16F708FA000FDF05 /* TransitionsTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TransitionsTest; path = ../../Shared/tests/TransitionsTest; sourceTree = ""; }; + 1AA51A9E16F708FA000FDF05 /* UnitTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = UnitTest; path = ../../Shared/tests/UnitTest; sourceTree = ""; }; + A05FCAC7177C123600BE600E /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; + A05FCACB177C125300BE600E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + A05FCAD0177C129100BE600E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = InfoPlist.strings; sourceTree = ""; }; + A05FCAD2177C129100BE600E /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = MainMenu.xib; sourceTree = ""; }; + A05FCAD3177C129100BE600E /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; + A05FCAD4177C129100BE600E /* Test_Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Test_Info.plist; sourceTree = ""; }; + A05FCAD5177C129100BE600E /* Test_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test_Prefix.pch; sourceTree = ""; }; + A05FCADF177C12B500BE600E /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; + A05FCAE0177C12B500BE600E /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; + A05FCAEB177C1FBB00BE600E /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; + A05FCAED177C208D00BE600E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + A05FCAF0177C273700BE600E /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; }; + A218F7DB1743D97E00F65883 /* XHRTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = XHRTest; path = ../../Shared/tests/XHRTest; sourceTree = ""; }; + A22656EE1743DCBB00598A2C /* ClippingNodeTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ClippingNodeTest; path = ../../Shared/tests/ClippingNodeTest; sourceTree = ""; }; + A922753D1517C094001B78AA /* TestJavascript.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestJavascript.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A92275411517C094001B78AA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + A92275451517C094001B78AA /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + A92275471517C094001B78AA /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + A92275491517C094001B78AA /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + A922754D1517C094001B78AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + A922754F1517C094001B78AA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + D401B5FD16FB199B00F2529D /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; + D401B5FF16FB19A000F2529D /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; + D401B60116FB19A600F2529D /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; + D401B60316FB19A900F2529D /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; + D401B6C816FB637400F2529D /* TestJavascriptObfuscated.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestJavascriptObfuscated.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D401B6D516FBF48000F2529D /* game.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = game.js; path = ../game.js; sourceTree = ""; }; + D401B6DE16FC071100F2529D /* tests-boot-jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "tests-boot-jsb.js"; path = "../../Shared/tests/tests-boot-jsb.js"; sourceTree = ""; }; + D446FDA216102D7D000ADA7B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + D446FDA416102D82000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + D446FDA616102D86000ADA7B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + D4545215156E28EF00887EB5 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; + D4545216156E28EF00887EB5 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A922753A1517C094001B78AA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A05FCAEC177C1FBB00BE600E /* libcurl.dylib in Frameworks */, + 1A4C3F1317784B6000EDFB3B /* libchipmunk.a in Frameworks */, + 1A4C3F1417784B6000EDFB3B /* libcocos2dx.a in Frameworks */, + 1A4C3F1517784B6000EDFB3B /* libCocosDenshion.a in Frameworks */, + 1A4C3F1617784B6000EDFB3B /* libextensions.a in Frameworks */, + 1A4C3F1717784B6000EDFB3B /* libjsbindings.a in Frameworks */, + 1A6B05C717782B0500FFE52B /* libz.dylib in Frameworks */, + 1A6B05C517782A2400FFE52B /* libsqlite3.dylib in Frameworks */, + A92275461517C094001B78AA /* OpenAL.framework in Frameworks */, + A05FCAF1177C273700BE600E /* ApplicationServices.framework in Frameworks */, + A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */, + A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */, + A922754E1517C094001B78AA /* Foundation.framework in Frameworks */, + A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */, + A05FCAC9177C123F00BE600E /* OpenGL.framework in Frameworks */, + A05FCACD177C125800BE600E /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D401B67816FB637400F2529D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A05FCACC177C125300BE600E /* Cocoa.framework in Frameworks */, + A05FCAC8177C123600BE600E /* OpenGL.framework in Frameworks */, + D401B67D16FB637400F2529D /* QuartzCore.framework in Frameworks */, + D401B67F16FB637400F2529D /* OpenAL.framework in Frameworks */, + D401B68016FB637400F2529D /* AudioToolbox.framework in Frameworks */, + D401B68116FB637400F2529D /* AVFoundation.framework in Frameworks */, + D401B68316FB637400F2529D /* Foundation.framework in Frameworks */, + D401B68416FB637400F2529D /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 15628F5B15F0F5C2000CF24B /* Resources */ = { + isa = PBXGroup; + children = ( + 1A6E4671177812AF0055514D /* js */, + 1A80332B1728F1FB00240CC3 /* res */, + D446FDA616102D86000ADA7B /* Default-568h@2x.png */, + D446FDA216102D7D000ADA7B /* Default.png */, + D446FDA416102D82000ADA7B /* Default@2x.png */, + D401B60316FB19A900F2529D /* Icon-144.png */, + D401B60116FB19A600F2529D /* Icon-72.png */, + D401B5FF16FB19A000F2529D /* Icon-114.png */, + D401B5FD16FB199B00F2529D /* Icon-57.png */, + ); + name = Resources; + sourceTree = ""; + }; + 1A6E4671177812AF0055514D /* js */ = { + isa = PBXGroup; + children = ( + 1A6E4672177812AF0055514D /* jsb.js */, + 1A6E4673177812AF0055514D /* jsb_chipmunk.js */, + 1A6E4674177812AF0055514D /* jsb_chipmunk_constants.js */, + 1A6E4675177812AF0055514D /* jsb_cocos2d.js */, + 1A6E4676177812AF0055514D /* jsb_cocos2d_constants.js */, + 1A6E4677177812AF0055514D /* jsb_cocos2d_extension.js */, + 1A6E4678177812AF0055514D /* jsb_cocosbuilder.js */, + 1A6E4679177812AF0055514D /* jsb_debugger.js */, + 1A6E467A177812AF0055514D /* jsb_opengl.js */, + 1A6E467B177812AF0055514D /* jsb_opengl_constants.js */, + 1A6E467C177812AF0055514D /* jsb_sys.js */, + 1A6E467D177812AF0055514D /* main.debug.js */, + ); + name = js; + path = ../../../../scripting/javascript/bindings/js; + sourceTree = ""; + }; + A05FCACE177C129100BE600E /* en.lproj */ = { + isa = PBXGroup; + children = ( + A05FCACF177C129100BE600E /* InfoPlist.strings */, + A05FCAD1177C129100BE600E /* MainMenu.xib */, + ); + path = en.lproj; + sourceTree = ""; + }; + A05FCADE177C129A00BE600E /* mac */ = { + isa = PBXGroup; + children = ( + A05FCAED177C208D00BE600E /* main.m */, + A05FCADF177C12B500BE600E /* AppController.h */, + A05FCAE0177C12B500BE600E /* AppController.mm */, + A05FCACE177C129100BE600E /* en.lproj */, + A05FCAD3177C129100BE600E /* Icon.icns */, + A05FCAD4177C129100BE600E /* Test_Info.plist */, + A05FCAD5177C129100BE600E /* Test_Prefix.pch */, + ); + name = mac; + sourceTree = ""; + }; + A92275321517C094001B78AA = { + isa = PBXGroup; + children = ( + D4545214156E28EF00887EB5 /* Classes */, + A05FCADE177C129A00BE600E /* mac */, + A92275401517C094001B78AA /* Frameworks */, + D401B60716FB632B00F2529D /* js_src_obfuscated */, + D401B5FC16FB169100F2529D /* js_src_raw */, + A922753E1517C094001B78AA /* Products */, + 15628F5B15F0F5C2000CF24B /* Resources */, + ); + sourceTree = ""; + }; + A922753E1517C094001B78AA /* Products */ = { + isa = PBXGroup; + children = ( + A922753D1517C094001B78AA /* TestJavascript.app */, + D401B6C816FB637400F2529D /* TestJavascriptObfuscated.app */, + ); + name = Products; + sourceTree = ""; + }; + A92275401517C094001B78AA /* Frameworks */ = { + isa = PBXGroup; + children = ( + A05FCAEB177C1FBB00BE600E /* libcurl.dylib */, + 1A4C3F0E17784B6000EDFB3B /* libchipmunk.a */, + 1A4C3F0F17784B6000EDFB3B /* libcocos2dx.a */, + 1A4C3F1017784B6000EDFB3B /* libCocosDenshion.a */, + 1A4C3F1117784B6000EDFB3B /* libextensions.a */, + 1A4C3F1217784B6000EDFB3B /* libjsbindings.a */, + 1A6B05C617782B0500FFE52B /* libz.dylib */, + 1A6B05C417782A2400FFE52B /* libsqlite3.dylib */, + A05FCAF0177C273700BE600E /* ApplicationServices.framework */, + A05FCACB177C125300BE600E /* Cocoa.framework */, + A05FCAC7177C123600BE600E /* OpenGL.framework */, + A92275411517C094001B78AA /* QuartzCore.framework */, + A92275451517C094001B78AA /* OpenAL.framework */, + A92275471517C094001B78AA /* AudioToolbox.framework */, + A92275491517C094001B78AA /* AVFoundation.framework */, + A922754D1517C094001B78AA /* Foundation.framework */, + A922754F1517C094001B78AA /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + D401B5FC16FB169100F2529D /* js_src_raw */ = { + isa = PBXGroup; + children = ( + A22656EE1743DCBB00598A2C /* ClippingNodeTest */, + A218F7DB1743D97E00F65883 /* XHRTest */, + 1AA51A7816F708FA000FDF05 /* ActionManagerTest */, + 1AA51A7916F708FA000FDF05 /* ActionsTest */, + 1AA51A7A16F708FA000FDF05 /* BaseTestLayer */, + 1AA51A7B16F708FA000FDF05 /* Box2dTest */, + 1AA51A7C16F708FA000FDF05 /* ChipmunkTest */, + 1AA51A7D16F708FA000FDF05 /* ClickAndMoveTest */, + 1AA51A7E16F708FA000FDF05 /* CocosDenshionTest */, + 1AA51A7F16F708FA000FDF05 /* CocosNodeTest */, + 1AA51A8016F708FA000FDF05 /* CurrentLanguageTest */, + 1AA51A8116F708FA000FDF05 /* DrawPrimitivesTest */, + 1AA51A8216F708FA000FDF05 /* EaseActionsTest */, + 1A8033291728DECD00240CC3 /* EffectsAdvancedTest */, + 1AA51A8316F708FA000FDF05 /* EffectsTest */, + 1AA51A8416F708FA000FDF05 /* EventTest */, + 1AA51A8516F708FA000FDF05 /* ExtensionsTest */, + 1AA51A8616F708FA000FDF05 /* FileUtils */, + 1AA51A8716F708FA000FDF05 /* FontTest */, + 1AA51A8816F708FA000FDF05 /* IntervalTest */, + 1AA51A8916F708FA000FDF05 /* LabelTest */, + 1AA51A8A16F708FA000FDF05 /* LayerTest */, + 1AA51A8B16F708FA000FDF05 /* MenuTest */, + 1AA51A8C16F708FA000FDF05 /* OpenGLTest */, + 1AA51A8D16F708FA000FDF05 /* ParallaxTest */, + 1AA51A8E16F708FA000FDF05 /* ParticleTest */, + 1AA51A8F16F708FA000FDF05 /* PerformanceTest */, + 1AA51A9016F708FA000FDF05 /* Presentation */, + 1AA51A9116F708FA000FDF05 /* ProgressActionsTest */, + 1AA51A9216F708FA000FDF05 /* RenderTextureTest */, + 1AA51A9416F708FA000FDF05 /* RotateWorldTest */, + 1AA51A9516F708FA000FDF05 /* SceneTest */, + 1AA51A9616F708FA000FDF05 /* SchedulerTest */, + 1AA51A9716F708FA000FDF05 /* SpriteTest */, + 1AA51A9816F708FA000FDF05 /* SysTest */, + 1AA51A9916F708FA000FDF05 /* TextInputTest */, + 1AA51A9A16F708FA000FDF05 /* TextureCacheTest */, + 1AA51A9B16F708FA000FDF05 /* TileMapTest */, + 1AA51A9C16F708FA000FDF05 /* TouchesTest */, + 1AA51A9D16F708FA000FDF05 /* TransitionsTest */, + 1AA51A9E16F708FA000FDF05 /* UnitTest */, + 15A3D4621682F14C002FB0C5 /* main.js */, + D401B6DE16FC071100F2529D /* tests-boot-jsb.js */, + 15A3D4741682F14C002FB0C5 /* tests-main.js */, + 15A3D4711682F14C002FB0C5 /* tests_resources-jsb.js */, + ); + name = js_src_raw; + sourceTree = ""; + }; + D401B60716FB632B00F2529D /* js_src_obfuscated */ = { + isa = PBXGroup; + children = ( + D401B6D516FBF48000F2529D /* game.js */, + ); + name = js_src_obfuscated; + sourceTree = ""; + }; + D4545214156E28EF00887EB5 /* Classes */ = { + isa = PBXGroup; + children = ( + D4545215156E28EF00887EB5 /* AppDelegate.cpp */, + D4545216156E28EF00887EB5 /* AppDelegate.h */, + ); + name = Classes; + path = ../Classes; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A922753C1517C094001B78AA /* TestJavascript */ = { + isa = PBXNativeTarget; + buildConfigurationList = A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "TestJavascript" */; + buildPhases = ( + A92275391517C094001B78AA /* Sources */, + A922753A1517C094001B78AA /* Frameworks */, + A922753B1517C094001B78AA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestJavascript; + productName = TestJavascript; + productReference = A922753D1517C094001B78AA /* TestJavascript.app */; + productType = "com.apple.product-type.application"; + }; + D401B60A16FB637400F2529D /* TestJavascriptObfuscated */ = { + isa = PBXNativeTarget; + buildConfigurationList = D401B6C516FB637400F2529D /* Build configuration list for PBXNativeTarget "TestJavascriptObfuscated" */; + buildPhases = ( + D401B60D16FB637400F2529D /* Sources */, + D401B67816FB637400F2529D /* Frameworks */, + D401B6E116FC076200F2529D /* ShellScript */, + D401B68516FB637400F2529D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestJavascriptObfuscated; + productName = TestJavascript; + productReference = D401B6C816FB637400F2529D /* TestJavascriptObfuscated.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A92275341517C094001B78AA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; + buildConfigurationList = A92275371517C094001B78AA /* Build configuration list for PBXProject "TestJavascript" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = A92275321517C094001B78AA; + productRefGroup = A922753E1517C094001B78AA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A922753C1517C094001B78AA /* TestJavascript */, + D401B60A16FB637400F2529D /* TestJavascriptObfuscated */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A922753B1517C094001B78AA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A6E468A177812D20055514D /* jsb.js in Resources */, + 1A6E468B177812D20055514D /* jsb_chipmunk.js in Resources */, + 1A6E468C177812D20055514D /* jsb_chipmunk_constants.js in Resources */, + 1A6E468D177812D20055514D /* jsb_cocos2d.js in Resources */, + 1A6E468E177812D20055514D /* jsb_cocos2d_constants.js in Resources */, + 1A6E468F177812D20055514D /* jsb_cocos2d_extension.js in Resources */, + 1A6E4690177812D20055514D /* jsb_cocosbuilder.js in Resources */, + 1A6E4691177812D20055514D /* jsb_debugger.js in Resources */, + 1A6E4692177812D20055514D /* jsb_opengl.js in Resources */, + 1A6E4693177812D20055514D /* jsb_opengl_constants.js in Resources */, + 1A6E4694177812D20055514D /* jsb_sys.js in Resources */, + 1A6E4695177812D20055514D /* main.debug.js in Resources */, + D401B6E016FC072B00F2529D /* tests-boot-jsb.js in Resources */, + 15A3D5631682F20C002FB0C5 /* main.js in Resources */, + 15A3D5651682F20C002FB0C5 /* tests_resources-jsb.js in Resources */, + 15A3D5681682F20C002FB0C5 /* tests-main.js in Resources */, + 1AA51A9F16F708FA000FDF05 /* ActionManagerTest in Resources */, + 1AA51AA016F708FA000FDF05 /* ActionsTest in Resources */, + 1AA51AA116F708FA000FDF05 /* BaseTestLayer in Resources */, + 1AA51AA216F708FA000FDF05 /* Box2dTest in Resources */, + 1AA51AA316F708FA000FDF05 /* ChipmunkTest in Resources */, + 1AA51AA416F708FA000FDF05 /* ClickAndMoveTest in Resources */, + 1AA51AA516F708FA000FDF05 /* CocosDenshionTest in Resources */, + 1AA51AA616F708FA000FDF05 /* CocosNodeTest in Resources */, + 1AA51AA716F708FA000FDF05 /* CurrentLanguageTest in Resources */, + 1AA51AA816F708FA000FDF05 /* DrawPrimitivesTest in Resources */, + 1AA51AA916F708FA000FDF05 /* EaseActionsTest in Resources */, + 1AA51AAA16F708FA000FDF05 /* EffectsTest in Resources */, + 1AA51AAB16F708FA000FDF05 /* EventTest in Resources */, + 1AA51AAC16F708FA000FDF05 /* ExtensionsTest in Resources */, + 1AA51AAD16F708FA000FDF05 /* FileUtils in Resources */, + 1AA51AAE16F708FA000FDF05 /* FontTest in Resources */, + 1AA51AAF16F708FA000FDF05 /* IntervalTest in Resources */, + 1AA51AB016F708FA000FDF05 /* LabelTest in Resources */, + 1AA51AB116F708FA000FDF05 /* LayerTest in Resources */, + 1AA51AB216F708FA000FDF05 /* MenuTest in Resources */, + 1AA51AB316F708FA000FDF05 /* OpenGLTest in Resources */, + 1AA51AB416F708FA000FDF05 /* ParallaxTest in Resources */, + 1AA51AB516F708FA000FDF05 /* ParticleTest in Resources */, + 1AA51AB616F708FA000FDF05 /* PerformanceTest in Resources */, + 1AA51AB716F708FA000FDF05 /* Presentation in Resources */, + 1AA51AB816F708FA000FDF05 /* ProgressActionsTest in Resources */, + 1AA51AB916F708FA000FDF05 /* RenderTextureTest in Resources */, + 1AA51ABB16F708FA000FDF05 /* RotateWorldTest in Resources */, + 1AA51ABC16F708FA000FDF05 /* SceneTest in Resources */, + 1AA51ABD16F708FA000FDF05 /* SchedulerTest in Resources */, + 1AA51ABE16F708FA000FDF05 /* SpriteTest in Resources */, + 1AA51ABF16F708FA000FDF05 /* SysTest in Resources */, + 1AA51AC016F708FA000FDF05 /* TextInputTest in Resources */, + 1AA51AC116F708FA000FDF05 /* TextureCacheTest in Resources */, + 1AA51AC216F708FA000FDF05 /* TileMapTest in Resources */, + 1AA51AC316F708FA000FDF05 /* TouchesTest in Resources */, + 1AA51AC416F708FA000FDF05 /* TransitionsTest in Resources */, + 1AA51AC516F708FA000FDF05 /* UnitTest in Resources */, + 1A80332A1728DECD00240CC3 /* EffectsAdvancedTest in Resources */, + 1A80332C1728F1FB00240CC3 /* res in Resources */, + A218F7DC1743D97E00F65883 /* XHRTest in Resources */, + A22656EF1743DCBB00598A2C /* ClippingNodeTest in Resources */, + A05FCAD6177C129100BE600E /* InfoPlist.strings in Resources */, + A05FCAD8177C129100BE600E /* MainMenu.xib in Resources */, + A05FCADA177C129100BE600E /* Icon.icns in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D401B68516FB637400F2529D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D401B6D716FBF49A00F2529D /* game.js in Resources */, + A05FCAD7177C129100BE600E /* InfoPlist.strings in Resources */, + A05FCAD9177C129100BE600E /* MainMenu.xib in Resources */, + A05FCADB177C129100BE600E /* Icon.icns in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + D401B6E116FC076200F2529D /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "pushd $SRCROOT/../\nrm game.js\nant -buildfile obfuscate.xml\npopd\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A92275391517C094001B78AA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */, + A05FCAE1177C12B500BE600E /* AppController.mm in Sources */, + A05FCAEE177C208D00BE600E /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D401B60D16FB637400F2529D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D401B61116FB637400F2529D /* AppDelegate.cpp in Sources */, + A05FCAE2177C12B500BE600E /* AppController.mm in Sources */, + A05FCAEF177C208D00BE600E /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + A05FCACF177C129100BE600E /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + A05FCAD0177C129100BE600E /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + A05FCAD1177C129100BE600E /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + A05FCAD2177C129100BE600E /* en */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + A92276FE1517C097001B78AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "COCOS2D_DEBUG=1", + COCOS2D_JAVASCRIPT, + USE_FILE32API, + CC_ENABLE_CHIPMUNK_INTEGRATION, + CC_TARGET_OS_MAC, + DEBUG, + CC_KEYBOARD_SUPPORT, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/../../../../cocos2dx", + "$(SRCROOT)/../../../../cocos2dx/include", + "$(SRCROOT)/../../../../cocos2dx/platform/mac", + "$(SRCROOT)/../../../../cocos2dx/kazmath/include", + "${SRCROOT}/../../../../cocos2dx/platform/third_party/mac", + "$(SRCROOT)/../../../../CocosDenshion/include", + "$(SRCROOT)/../../../../external/chipmunk/include/chipmunk", + "$(SRCROOT)/../../../../scripting/javascript/spidermonkey-mac/include", + "$(SRCROOT)/../../../../scripting/javascript/bindings", + "$(SRCROOT)/../../../../extensions", + ); + LIBRARY_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../../../scripting/javascript/spidermonkey-mac/lib\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/mac/libraries\"", + "\"$(SRCROOT)/../../../../external/libwebsockets/mac/lib\"", + ); + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + A92276FF1517C097001B78AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_PREPROCESSOR_DEFINITIONS = ( + COCOS2D_JAVASCRIPT, + USE_FILE32API, + CC_ENABLE_CHIPMUNK_INTEGRATION, + CC_TARGET_OS_MAC, + NDEBUG, + CC_KEYBOARD_SUPPORT, + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/../../../../cocos2dx", + "$(SRCROOT)/../../../../cocos2dx/include", + "$(SRCROOT)/../../../../cocos2dx/platform/mac", + "$(SRCROOT)/../../../../cocos2dx/kazmath/include", + "${SRCROOT}/../../../../cocos2dx/platform/third_party/mac", + "$(SRCROOT)/../../../../CocosDenshion/include", + "$(SRCROOT)/../../../../external/chipmunk/include/chipmunk", + "$(SRCROOT)/../../../../scripting/javascript/spidermonkey-mac/include", + "$(SRCROOT)/../../../../scripting/javascript/bindings", + "$(SRCROOT)/../../../../extensions", + ); + LIBRARY_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../../../scripting/javascript/spidermonkey-mac/lib\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/mac/libraries\"", + "\"$(SRCROOT)/../../../../external/libwebsockets/mac/lib\"", + ); + SDKROOT = macosx; + }; + name = Release; + }; + A92277011517C097001B78AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Test_Prefix.pch; + GCC_VERSION = ""; + INFOPLIST_FILE = "$(SRCROOT)/Test_Info.plist"; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ""; + PRODUCT_NAME = TestJavascript; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + A92277021517C097001B78AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Test_Prefix.pch; + GCC_VERSION = ""; + INFOPLIST_FILE = "$(SRCROOT)/Test_Info.plist"; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ""; + PRODUCT_NAME = TestJavascript; + VALIDATE_PRODUCT = YES; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + D401B6C616FB637400F2529D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 1; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Test_Prefix.pch; + GCC_THUMB_SUPPORT = NO; + GCC_VERSION = ""; + INFOPLIST_FILE = "$(SRCROOT)/Info-obfuscated.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + OTHER_LDFLAGS = ( + "-lxml2", + "-lz", + "-ljs_static", + ); + PRODUCT_NAME = TestJavascriptObfuscated; + TARGETED_DEVICE_FAMILY = "1,2"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + D401B6C716FB637400F2529D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Test_Prefix.pch; + GCC_THUMB_SUPPORT = NO; + GCC_VERSION = ""; + INFOPLIST_FILE = "$(SRCROOT)/Info-obfuscated.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + OTHER_LDFLAGS = ( + "-lxml2", + "-lz", + "-ljs_static", + ); + PRODUCT_NAME = TestJavascriptObfuscated; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A92275371517C094001B78AA /* Build configuration list for PBXProject "TestJavascript" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A92276FE1517C097001B78AA /* Debug */, + A92276FF1517C097001B78AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "TestJavascript" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A92277011517C097001B78AA /* Debug */, + A92277021517C097001B78AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D401B6C516FB637400F2529D /* Build configuration list for PBXNativeTarget "TestJavascriptObfuscated" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D401B6C616FB637400F2529D /* Debug */, + D401B6C716FB637400F2529D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = A92275341517C094001B78AA /* Project object */; +} diff --git a/samples/Javascript/TestJavascript/proj.mac/TestJavascript.xcodeproj/project.xcworkspace/xcshareddata/TestJavascript.xccheckout b/samples/Javascript/TestJavascript/proj.mac/TestJavascript.xcodeproj/project.xcworkspace/xcshareddata/TestJavascript.xccheckout new file mode 100644 index 0000000000..58f6193c12 --- /dev/null +++ b/samples/Javascript/TestJavascript/proj.mac/TestJavascript.xcodeproj/project.xcworkspace/xcshareddata/TestJavascript.xccheckout @@ -0,0 +1,63 @@ + + + + + IDESourceControlProjectIdentifier + 0B98B4D8-828E-460D-817C-495BE3652AD5 + IDESourceControlProjectName + TestJavascript + IDESourceControlProjectOriginsDictionary + + 5B0F35E6-1A4B-4F3D-A082-C30150726270 + git://github.com/folecr/cocos2dx-autogen-bindings.git + D2399FF0-C90F-4E4F-8E8D-F9BE2AA9DC5A + https://github.com/minggo/cocos2d-x.git + E0C8B176-3A21-43EF-A355-D004DE1F4825 + https://github.com/minggo/cocos2d-js-tests.git + + IDESourceControlProjectPath + samples/Javascript/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.xcworkspace + IDESourceControlProjectRelativeInstallPathDictionary + + 5B0F35E6-1A4B-4F3D-A082-C30150726270 + ../../../../../../scripting/javascript/bindings/generated + D2399FF0-C90F-4E4F-8E8D-F9BE2AA9DC5A + ../../../../../.. + E0C8B176-3A21-43EF-A355-D004DE1F4825 + ../../../../Shared + + IDESourceControlProjectURL + https://github.com/minggo/cocos2d-x.git + IDESourceControlProjectVersion + 110 + IDESourceControlProjectWCCIdentifier + D2399FF0-C90F-4E4F-8E8D-F9BE2AA9DC5A + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + D2399FF0-C90F-4E4F-8E8D-F9BE2AA9DC5A + IDESourceControlWCCName + cocos2d-x + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + E0C8B176-3A21-43EF-A355-D004DE1F4825 + IDESourceControlWCCName + Shared + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + 5B0F35E6-1A4B-4F3D-A082-C30150726270 + IDESourceControlWCCName + generated + + + + diff --git a/samples/Javascript/TestJavascript/proj.mac/Test_Prefix.pch b/samples/Javascript/TestJavascript/proj.mac/Test_Prefix.pch new file mode 100644 index 0000000000..46c36a7e99 --- /dev/null +++ b/samples/Javascript/TestJavascript/proj.mac/Test_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/samples/Javascript/TestJavascript/proj.mac/en.lproj/InfoPlist.strings b/samples/Javascript/TestJavascript/proj.mac/en.lproj/InfoPlist.strings new file mode 100644 index 0000000000..477b28ff8f --- /dev/null +++ b/samples/Javascript/TestJavascript/proj.mac/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/samples/Javascript/TestJavascript/proj.mac/en.lproj/MainMenu.xib b/samples/Javascript/TestJavascript/proj.mac/en.lproj/MainMenu.xib new file mode 100644 index 0000000000..3dacdedbd0 --- /dev/null +++ b/samples/Javascript/TestJavascript/proj.mac/en.lproj/MainMenu.xib @@ -0,0 +1,812 @@ + + + + 1060 + 10K549 + 1938 + 1038.36 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1938 + + + YES + NSMenuItem + NSCustomObject + NSMenu + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + YES + + + TestCpp + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + TestCpp + + YES + + + About TestCpp + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + YES + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide TestCpp + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit TestCpp + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + YES + + + Toggle Fullscreen + f + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + YES + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + YES + + + TestCpp Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + AppController + + + NSFontManager + + + + + YES + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 495 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + performZoom: + + + + 240 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + showHelp: + + + + 493 + + + + toggleFullScreen: + + + + 537 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + + + + + + 19 + + + YES + + + + + + 56 + + + YES + + + + + + 57 + + + YES + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + YES + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + YES + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + YES + + + + + + 296 + + + YES + + + + + + 420 + + + + + 490 + + + YES + + + + + + 491 + + + YES + + + + + + 492 + + + + + 494 + + + + + 536 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 129.IBPluginDependency + 130.IBPluginDependency + 131.IBPluginDependency + 134.IBPluginDependency + 136.IBPluginDependency + 143.IBPluginDependency + 144.IBPluginDependency + 145.IBPluginDependency + 149.IBPluginDependency + 150.IBPluginDependency + 19.IBPluginDependency + 23.IBPluginDependency + 236.IBPluginDependency + 239.IBPluginDependency + 24.IBPluginDependency + 29.IBPluginDependency + 295.IBPluginDependency + 296.IBPluginDependency + 420.IBPluginDependency + 490.IBPluginDependency + 491.IBPluginDependency + 492.IBPluginDependency + 494.IBPluginDependency + 5.IBPluginDependency + 536.IBPluginDependency + 56.IBPluginDependency + 57.IBPluginDependency + 58.IBPluginDependency + 92.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + + + + YES + + + + + 541 + + + + YES + + AppController + NSObject + + YES + + YES + exitFullScreen: + toggleFullScreen: + + + YES + id + id + + + + YES + + YES + exitFullScreen: + toggleFullScreen: + + + YES + + exitFullScreen: + id + + + toggleFullScreen: + id + + + + + YES + + YES + glView + window + + + YES + EAGLView + NSWindow + + + + YES + + YES + glView + window + + + YES + + glView + EAGLView + + + window + NSWindow + + + + + IBProjectSource + ./Classes/AppController.h + + + + EAGLView + NSOpenGLView + + IBProjectSource + ./Classes/EAGLView.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + + + diff --git a/plugin/samples/HelloAnalytics/proj.ios/RootViewController.h b/samples/Javascript/TestJavascript/proj.mac/main.m old mode 100755 new mode 100644 similarity index 88% rename from plugin/samples/HelloAnalytics/proj.ios/RootViewController.h rename to samples/Javascript/TestJavascript/proj.mac/main.m index a40c2edd28..97d9b73282 --- a/plugin/samples/HelloAnalytics/proj.ios/RootViewController.h +++ b/samples/Javascript/TestJavascript/proj.mac/main.m @@ -1,6 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org - Copyright (c) 2010 Ricardo Quesada + Copyright (c) 2010 cocos2d-x.org http://www.cocos2d-x.org @@ -23,11 +22,9 @@ THE SOFTWARE. ****************************************************************************/ -#import - - -@interface RootViewController : UIViewController { +#import +int main(int argc, char *argv[]) +{ + return NSApplicationMain(argc, (const char **)argv); } - -@end diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 1629fa860d..1aef083d39 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 1629fa860dd1c378c0c1d2d39463d796e51f0043 +Subproject commit 1aef083d3959574072f234cd31c5a53ac52b58a9 diff --git a/scripting/javascript/bindings/js_manual_conversions.cpp b/scripting/javascript/bindings/js_manual_conversions.cpp index efa23f5ef9..395c710a0f 100644 --- a/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/scripting/javascript/bindings/js_manual_conversions.cpp @@ -12,19 +12,19 @@ JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **r) { #ifdef __LP64__ + + // begin JSObject *tmp_arg; - if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) - return JS_FALSE; + JSBool ok = JS_ValueToObject( cx, vp, &tmp_arg ); + JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error converting value to object"); + JSB_PRECONDITION2( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object"); + JSB_PRECONDITION2( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(void*), cx, JS_FALSE, "Invalid Typed Array length"); - JSB_PRECONDITION( js_IsTypedArray( tmp_arg ), "jsb: Not a TypedArray object"); - - JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(void*), "jsb: Invalid Typed Array lenght"); - - int32_t* arg_array = (int32_t*)JS_GetTypedArrayData( tmp_arg ); - uint64 ret = arg_array[0]; + uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg ); + uint64_t ret = arg_array[0]; ret = ret << 32; ret |= arg_array[1]; - + #else assert( sizeof(int)==4); int32_t ret; @@ -52,19 +52,18 @@ JSBool jsval_to_long( JSContext *cx, jsval vp, long *r ) #ifdef __LP64__ // compatibility check assert( sizeof(long)==8); - JSObject *tmp_arg; - if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) - return JS_FALSE; + JSString *jsstr = JS_ValueToString(cx, vp); + JSB_PRECONDITION2(jsstr, cx, JS_FALSE, "Error converting value to string"); - JSB_PRECONDITION( js_IsTypedArray( tmp_arg ), "jsb: Not a TypedArray object"); + char *str = JS_EncodeString(cx, jsstr); + JSB_PRECONDITION2(str, cx, JS_FALSE, "Error encoding string"); + + char *endptr; + long ret = strtol(str, &endptr, 10); + + *r = ret; + return JS_TRUE; - JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long), "jsb: Invalid Typed Array lenght"); - - int32_t* arg_array = (int32_t*)JS_GetTypedArrayData( tmp_arg ); - long ret = arg_array[0]; - ret = ret << 32; - ret |= arg_array[1]; - #else // compatibility check assert( sizeof(int)==4); @@ -97,11 +96,11 @@ jsval opaque_to_jsval( JSContext *cx, void *opaque ) { #ifdef __LP64__ uint64_t number = (uint64_t)opaque; - JSObject *typedArray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT32, 2); - int32_t *buffer = (int32_t*)JS_GetTypedArrayData(typedArray); + JSObject *typedArray = JS_NewUint32Array( cx, 2 ); + uint32_t *buffer = (uint32_t*)JS_GetArrayBufferViewData(typedArray); buffer[0] = number >> 32; buffer[1] = number & 0xffffffff; - return OBJECT_TO_JSVAL(typedArray); + return OBJECT_TO_JSVAL(typedArray); #else assert(sizeof(int)==4); int32_t number = (int32_t) opaque; @@ -198,8 +197,8 @@ jsval uint_to_jsval( JSContext *cx, unsigned int number ) jsval long_to_jsval( JSContext *cx, long number ) { #ifdef __LP64__ - NSCAssert( sizeof(long)==8, @"Error!"); - + assert( sizeof(long)==8); + char chr[128]; snprintf(chr, sizeof(chr)-1, "%ld", number); JSString *ret_obj = JS_NewStringCopyZ(cx, chr); diff --git a/scripting/javascript/bindings/proj.mac/jsbindings-Prefix.pch b/scripting/javascript/bindings/proj.mac/jsbindings-Prefix.pch new file mode 100644 index 0000000000..af8c4a19d5 --- /dev/null +++ b/scripting/javascript/bindings/proj.mac/jsbindings-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'jsbindings' target in the 'jsbindings' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/scripting/javascript/bindings/proj.mac/jsbindings.xcodeproj/project.pbxproj b/scripting/javascript/bindings/proj.mac/jsbindings.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..fd51d91ed6 --- /dev/null +++ b/scripting/javascript/bindings/proj.mac/jsbindings.xcodeproj/project.pbxproj @@ -0,0 +1,651 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1A0C0E8B1778088700838530 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A0C0E8A1778088700838530 /* Foundation.framework */; }; + 1A0C0EDA1778095000838530 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0E991778095000838530 /* cocos2d_specifics.cpp */; }; + 1A0C0EDB1778095000838530 /* cocosjs_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0E9B1778095000838530 /* cocosjs_manual_conversions.cpp */; }; + 1A0C0EDC1778095000838530 /* jsb_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0E9E1778095000838530 /* jsb_cocos2dx_auto.cpp */; }; + 1A0C0EEC1778095000838530 /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EB21778095000838530 /* js_bindings_ccbreader.cpp */; }; + 1A0C0EED1778095000838530 /* js_bindings_chipmunk_auto_classes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EB51778095000838530 /* js_bindings_chipmunk_auto_classes.cpp */; }; + 1A0C0EEE1778095000838530 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EB81778095000838530 /* js_bindings_chipmunk_functions.cpp */; }; + 1A0C0EEF1778095000838530 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EBA1778095000838530 /* js_bindings_chipmunk_manual.cpp */; }; + 1A0C0EF01778095000838530 /* js_bindings_chipmunk_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EBC1778095000838530 /* js_bindings_chipmunk_registration.cpp */; }; + 1A0C0EF11778095000838530 /* js_bindings_core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EBF1778095000838530 /* js_bindings_core.cpp */; }; + 1A0C0EF21778095000838530 /* js_bindings_opengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EC11778095000838530 /* js_bindings_opengl.cpp */; }; + 1A0C0EF31778095000838530 /* js_bindings_system_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EC41778095000838530 /* js_bindings_system_functions.cpp */; }; + 1A0C0EF41778095000838530 /* js_bindings_system_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EC61778095000838530 /* js_bindings_system_registration.cpp */; }; + 1A0C0EF51778095000838530 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EC81778095000838530 /* js_manual_conversions.cpp */; }; + 1A0C0EF61778095000838530 /* jsb_cocos2dx_extension_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0ECA1778095000838530 /* jsb_cocos2dx_extension_manual.cpp */; }; + 1A0C0EF71778095000838530 /* jsb_opengl_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0ECD1778095000838530 /* jsb_opengl_functions.cpp */; }; + 1A0C0EF81778095000838530 /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0ECF1778095000838530 /* jsb_opengl_manual.cpp */; }; + 1A0C0EF91778095000838530 /* jsb_opengl_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0ED11778095000838530 /* jsb_opengl_registration.cpp */; }; + 1A0C0EFA1778095000838530 /* jsb_websocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0ED31778095000838530 /* jsb_websocket.cpp */; }; + 1A0C0EFB1778095000838530 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0ED51778095000838530 /* ScriptingCore.cpp */; }; + 1A0C0EFC1778095000838530 /* XMLHTTPRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0ED81778095000838530 /* XMLHTTPRequest.cpp */; }; + 1A6E46D51778162E0055514D /* jsb_cocos2dx_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0EA11778095000838530 /* jsb_cocos2dx_extension_auto.cpp */; }; + A00B437317795C5C00480238 /* libjs_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A00B437217795C5C00480238 /* libjs_static.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 1A0C0E851778088700838530 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1A0C0E871778088700838530 /* libjsbindings.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libjsbindings.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A0C0E8A1778088700838530 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1A0C0E991778095000838530 /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d_specifics.cpp; path = ../cocos2d_specifics.cpp; sourceTree = ""; }; + 1A0C0E9A1778095000838530 /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = cocos2d_specifics.hpp; path = ../cocos2d_specifics.hpp; sourceTree = ""; }; + 1A0C0E9B1778095000838530 /* cocosjs_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocosjs_manual_conversions.cpp; path = ../cocosjs_manual_conversions.cpp; sourceTree = ""; }; + 1A0C0E9C1778095000838530 /* cocosjs_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocosjs_manual_conversions.h; path = ../cocosjs_manual_conversions.h; sourceTree = ""; }; + 1A0C0E9E1778095000838530 /* jsb_cocos2dx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_auto.cpp; sourceTree = ""; }; + 1A0C0E9F1778095000838530 /* jsb_cocos2dx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_auto.hpp; sourceTree = ""; }; + 1A0C0EA01778095000838530 /* jsb_cocos2dx_auto_api.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2dx_auto_api.js; sourceTree = ""; }; + 1A0C0EA11778095000838530 /* jsb_cocos2dx_extension_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_extension_auto.cpp; sourceTree = ""; }; + 1A0C0EA21778095000838530 /* jsb_cocos2dx_extension_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_extension_auto.hpp; sourceTree = ""; }; + 1A0C0EA31778095000838530 /* jsb_cocos2dx_extension_auto_api.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2dx_extension_auto_api.js; sourceTree = ""; }; + 1A0C0EA41778095000838530 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; + 1A0C0EA61778095000838530 /* jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb.js; sourceTree = ""; }; + 1A0C0EA71778095000838530 /* jsb_chipmunk.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_chipmunk.js; sourceTree = ""; }; + 1A0C0EA81778095000838530 /* jsb_chipmunk_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_chipmunk_constants.js; sourceTree = ""; }; + 1A0C0EA91778095000838530 /* jsb_cocos2d.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d.js; sourceTree = ""; }; + 1A0C0EAA1778095000838530 /* jsb_cocos2d_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d_constants.js; sourceTree = ""; }; + 1A0C0EAB1778095000838530 /* jsb_cocos2d_extension.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d_extension.js; sourceTree = ""; }; + 1A0C0EAC1778095000838530 /* jsb_cocosbuilder.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocosbuilder.js; sourceTree = ""; }; + 1A0C0EAD1778095000838530 /* jsb_debugger.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_debugger.js; sourceTree = ""; }; + 1A0C0EAE1778095000838530 /* jsb_opengl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_opengl.js; sourceTree = ""; }; + 1A0C0EAF1778095000838530 /* jsb_opengl_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_opengl_constants.js; sourceTree = ""; }; + 1A0C0EB01778095000838530 /* jsb_sys.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_sys.js; sourceTree = ""; }; + 1A0C0EB11778095000838530 /* main.debug.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = main.debug.js; sourceTree = ""; }; + 1A0C0EB21778095000838530 /* js_bindings_ccbreader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_ccbreader.cpp; path = ../js_bindings_ccbreader.cpp; sourceTree = ""; }; + 1A0C0EB31778095000838530 /* js_bindings_ccbreader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_ccbreader.h; path = ../js_bindings_ccbreader.h; sourceTree = ""; }; + 1A0C0EB41778095000838530 /* js_bindings_chipmunk_auto_classes_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_chipmunk_auto_classes_registration.h; path = ../js_bindings_chipmunk_auto_classes_registration.h; sourceTree = ""; }; + 1A0C0EB51778095000838530 /* js_bindings_chipmunk_auto_classes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_chipmunk_auto_classes.cpp; path = ../js_bindings_chipmunk_auto_classes.cpp; sourceTree = ""; }; + 1A0C0EB61778095000838530 /* js_bindings_chipmunk_auto_classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_chipmunk_auto_classes.h; path = ../js_bindings_chipmunk_auto_classes.h; sourceTree = ""; }; + 1A0C0EB71778095000838530 /* js_bindings_chipmunk_functions_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_chipmunk_functions_registration.h; path = ../js_bindings_chipmunk_functions_registration.h; sourceTree = ""; }; + 1A0C0EB81778095000838530 /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_chipmunk_functions.cpp; path = ../js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; + 1A0C0EB91778095000838530 /* js_bindings_chipmunk_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_chipmunk_functions.h; path = ../js_bindings_chipmunk_functions.h; sourceTree = ""; }; + 1A0C0EBA1778095000838530 /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_chipmunk_manual.cpp; path = ../js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; + 1A0C0EBB1778095000838530 /* js_bindings_chipmunk_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_chipmunk_manual.h; path = ../js_bindings_chipmunk_manual.h; sourceTree = ""; }; + 1A0C0EBC1778095000838530 /* js_bindings_chipmunk_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_chipmunk_registration.cpp; path = ../js_bindings_chipmunk_registration.cpp; sourceTree = ""; }; + 1A0C0EBD1778095000838530 /* js_bindings_chipmunk_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_chipmunk_registration.h; path = ../js_bindings_chipmunk_registration.h; sourceTree = ""; }; + 1A0C0EBE1778095000838530 /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_config.h; path = ../js_bindings_config.h; sourceTree = ""; }; + 1A0C0EBF1778095000838530 /* js_bindings_core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_core.cpp; path = ../js_bindings_core.cpp; sourceTree = ""; }; + 1A0C0EC01778095000838530 /* js_bindings_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_core.h; path = ../js_bindings_core.h; sourceTree = ""; }; + 1A0C0EC11778095000838530 /* js_bindings_opengl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_opengl.cpp; path = ../js_bindings_opengl.cpp; sourceTree = ""; }; + 1A0C0EC21778095000838530 /* js_bindings_opengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_opengl.h; path = ../js_bindings_opengl.h; sourceTree = ""; }; + 1A0C0EC31778095000838530 /* js_bindings_system_functions_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_system_functions_registration.h; path = ../js_bindings_system_functions_registration.h; sourceTree = ""; }; + 1A0C0EC41778095000838530 /* js_bindings_system_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_system_functions.cpp; path = ../js_bindings_system_functions.cpp; sourceTree = ""; }; + 1A0C0EC51778095000838530 /* js_bindings_system_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_system_functions.h; path = ../js_bindings_system_functions.h; sourceTree = ""; }; + 1A0C0EC61778095000838530 /* js_bindings_system_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_bindings_system_registration.cpp; path = ../js_bindings_system_registration.cpp; sourceTree = ""; }; + 1A0C0EC71778095000838530 /* js_bindings_system_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_bindings_system_registration.h; path = ../js_bindings_system_registration.h; sourceTree = ""; }; + 1A0C0EC81778095000838530 /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = js_manual_conversions.cpp; path = ../js_manual_conversions.cpp; sourceTree = ""; }; + 1A0C0EC91778095000838530 /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = js_manual_conversions.h; path = ../js_manual_conversions.h; sourceTree = ""; }; + 1A0C0ECA1778095000838530 /* jsb_cocos2dx_extension_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_cocos2dx_extension_manual.cpp; path = ../jsb_cocos2dx_extension_manual.cpp; sourceTree = ""; }; + 1A0C0ECB1778095000838530 /* jsb_cocos2dx_extension_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_cocos2dx_extension_manual.h; path = ../jsb_cocos2dx_extension_manual.h; sourceTree = ""; }; + 1A0C0ECC1778095000838530 /* jsb_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_helper.h; path = ../jsb_helper.h; sourceTree = ""; }; + 1A0C0ECD1778095000838530 /* jsb_opengl_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_opengl_functions.cpp; path = ../jsb_opengl_functions.cpp; sourceTree = ""; }; + 1A0C0ECE1778095000838530 /* jsb_opengl_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_opengl_functions.h; path = ../jsb_opengl_functions.h; sourceTree = ""; }; + 1A0C0ECF1778095000838530 /* jsb_opengl_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_opengl_manual.cpp; path = ../jsb_opengl_manual.cpp; sourceTree = ""; }; + 1A0C0ED01778095000838530 /* jsb_opengl_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_opengl_manual.h; path = ../jsb_opengl_manual.h; sourceTree = ""; }; + 1A0C0ED11778095000838530 /* jsb_opengl_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_opengl_registration.cpp; path = ../jsb_opengl_registration.cpp; sourceTree = ""; }; + 1A0C0ED21778095000838530 /* jsb_opengl_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_opengl_registration.h; path = ../jsb_opengl_registration.h; sourceTree = ""; }; + 1A0C0ED31778095000838530 /* jsb_websocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_websocket.cpp; path = ../jsb_websocket.cpp; sourceTree = ""; }; + 1A0C0ED41778095000838530 /* jsb_websocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_websocket.h; path = ../jsb_websocket.h; sourceTree = ""; }; + 1A0C0ED51778095000838530 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptingCore.cpp; path = ../ScriptingCore.cpp; sourceTree = ""; }; + 1A0C0ED61778095000838530 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptingCore.h; path = ../ScriptingCore.h; sourceTree = ""; }; + 1A0C0ED71778095000838530 /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = spidermonkey_specifics.h; path = ../spidermonkey_specifics.h; sourceTree = ""; }; + 1A0C0ED81778095000838530 /* XMLHTTPRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XMLHTTPRequest.cpp; path = ../XMLHTTPRequest.cpp; sourceTree = ""; }; + 1A0C0ED91778095000838530 /* XMLHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMLHTTPRequest.h; path = ../XMLHTTPRequest.h; sourceTree = ""; }; + A00B437217795C5C00480238 /* libjs_static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjs_static.a; sourceTree = ""; }; + A05FCAF5177D12D900BE600E /* Anchor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Anchor.h; sourceTree = ""; }; + A05FCAF6177D12D900BE600E /* CallArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallArgs.h; sourceTree = ""; }; + A05FCAF7177D12D900BE600E /* CharacterEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharacterEncoding.h; sourceTree = ""; }; + A05FCAF8177D12D900BE600E /* GCAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCAPI.h; sourceTree = ""; }; + A05FCAF9177D12D900BE600E /* HashTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashTable.h; sourceTree = ""; }; + A05FCAFA177D12D900BE600E /* HeapAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapAPI.h; sourceTree = ""; }; + A05FCAFB177D12D900BE600E /* LegacyIntTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyIntTypes.h; sourceTree = ""; }; + A05FCAFC177D12D900BE600E /* MemoryMetrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryMetrics.h; sourceTree = ""; }; + A05FCAFD177D12D900BE600E /* PropertyKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyKey.h; sourceTree = ""; }; + A05FCAFE177D12D900BE600E /* RequiredDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RequiredDefines.h; sourceTree = ""; }; + A05FCAFF177D12D900BE600E /* RootingAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootingAPI.h; sourceTree = ""; }; + A05FCB00177D12D900BE600E /* TemplateLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemplateLib.h; sourceTree = ""; }; + A05FCB01177D12D900BE600E /* Utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utility.h; sourceTree = ""; }; + A05FCB02177D12D900BE600E /* Value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Value.h; sourceTree = ""; }; + A05FCB03177D12D900BE600E /* Vector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector.h; sourceTree = ""; }; + A05FCB04177D12D900BE600E /* js-config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "js-config.h"; sourceTree = ""; }; + A05FCB05177D12D900BE600E /* js.msg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = js.msg; sourceTree = ""; }; + A05FCB06177D12D900BE600E /* jsalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsalloc.h; sourceTree = ""; }; + A05FCB07177D12D900BE600E /* jsapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsapi.h; sourceTree = ""; }; + A05FCB08177D12D900BE600E /* jsclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsclass.h; sourceTree = ""; }; + A05FCB09177D12D900BE600E /* jsclist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsclist.h; sourceTree = ""; }; + A05FCB0A177D12D900BE600E /* jscpucfg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jscpucfg.h; sourceTree = ""; }; + A05FCB0B177D12D900BE600E /* jsdbgapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsdbgapi.h; sourceTree = ""; }; + A05FCB0C177D12D900BE600E /* jsdhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsdhash.h; sourceTree = ""; }; + A05FCB0D177D12D900BE600E /* jsfriendapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsfriendapi.h; sourceTree = ""; }; + A05FCB0E177D12D900BE600E /* jslock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jslock.h; sourceTree = ""; }; + A05FCB0F177D12D900BE600E /* json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json.h; sourceTree = ""; }; + A05FCB10177D12D900BE600E /* jsperf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsperf.h; sourceTree = ""; }; + A05FCB11177D12D900BE600E /* jsprf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsprf.h; sourceTree = ""; }; + A05FCB12177D12D900BE600E /* jsprototypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsprototypes.h; sourceTree = ""; }; + A05FCB13177D12D900BE600E /* jsproxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsproxy.h; sourceTree = ""; }; + A05FCB14177D12D900BE600E /* jsprvtd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsprvtd.h; sourceTree = ""; }; + A05FCB15177D12D900BE600E /* jspubtd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jspubtd.h; sourceTree = ""; }; + A05FCB16177D12D900BE600E /* jstypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jstypes.h; sourceTree = ""; }; + A05FCB17177D12D900BE600E /* jsutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsutil.h; sourceTree = ""; }; + A05FCB18177D12D900BE600E /* jsversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsversion.h; sourceTree = ""; }; + A05FCB19177D12D900BE600E /* jswrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jswrapper.h; sourceTree = ""; }; + A05FCB1B177D12D900BE600E /* Assertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Assertions.h; sourceTree = ""; }; + A05FCB1C177D12D900BE600E /* Attributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Attributes.h; sourceTree = ""; }; + A05FCB1D177D12D900BE600E /* BloomFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BloomFilter.h; sourceTree = ""; }; + A05FCB1E177D12D900BE600E /* Char16.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Char16.h; sourceTree = ""; }; + A05FCB1F177D12D900BE600E /* CheckedInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CheckedInt.h; sourceTree = ""; }; + A05FCB20177D12D900BE600E /* Compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compiler.h; sourceTree = ""; }; + A05FCB21177D12D900BE600E /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; + A05FCB22177D12D900BE600E /* DebugOnly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugOnly.h; sourceTree = ""; }; + A05FCB23177D12D900BE600E /* EnumSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnumSet.h; sourceTree = ""; }; + A05FCB24177D12D900BE600E /* FloatingPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingPoint.h; sourceTree = ""; }; + A05FCB25177D12D900BE600E /* GuardObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GuardObjects.h; sourceTree = ""; }; + A05FCB26177D12D900BE600E /* HashFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashFunctions.h; sourceTree = ""; }; + A05FCB27177D12D900BE600E /* Likely.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Likely.h; sourceTree = ""; }; + A05FCB28177D12D900BE600E /* LinkedList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkedList.h; sourceTree = ""; }; + A05FCB29177D12D900BE600E /* MathAlgorithms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathAlgorithms.h; sourceTree = ""; }; + A05FCB2A177D12D900BE600E /* MemoryChecking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryChecking.h; sourceTree = ""; }; + A05FCB2B177D12D900BE600E /* MSStdInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSStdInt.h; sourceTree = ""; }; + A05FCB2C177D12D900BE600E /* NullPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullPtr.h; sourceTree = ""; }; + A05FCB2D177D12D900BE600E /* Range.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Range.h; sourceTree = ""; }; + A05FCB2E177D12D900BE600E /* RangedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RangedPtr.h; sourceTree = ""; }; + A05FCB2F177D12D900BE600E /* RefPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefPtr.h; sourceTree = ""; }; + A05FCB30177D12D900BE600E /* Scoped.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scoped.h; sourceTree = ""; }; + A05FCB31177D12D900BE600E /* SHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SHA1.h; sourceTree = ""; }; + A05FCB32177D12D900BE600E /* SplayTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplayTree.h; sourceTree = ""; }; + A05FCB33177D12D900BE600E /* StandardInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StandardInteger.h; sourceTree = ""; }; + A05FCB34177D12D900BE600E /* ThreadLocal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadLocal.h; sourceTree = ""; }; + A05FCB35177D12D900BE600E /* TypedEnum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedEnum.h; sourceTree = ""; }; + A05FCB36177D12D900BE600E /* Types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Types.h; sourceTree = ""; }; + A05FCB37177D12D900BE600E /* TypeTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeTraits.h; sourceTree = ""; }; + A05FCB38177D12D900BE600E /* Util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Util.h; sourceTree = ""; }; + A05FCB39177D12D900BE600E /* WeakPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakPtr.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1A0C0E841778088700838530 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A0C0E8B1778088700838530 /* Foundation.framework in Frameworks */, + A00B437317795C5C00480238 /* libjs_static.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1A0C0E7E1778088700838530 = { + isa = PBXGroup; + children = ( + 1A0C0E981778093E00838530 /* bindings */, + 1A0C0E891778088700838530 /* Frameworks */, + 1A0C0E881778088700838530 /* Products */, + ); + sourceTree = ""; + }; + 1A0C0E881778088700838530 /* Products */ = { + isa = PBXGroup; + children = ( + 1A0C0E871778088700838530 /* libjsbindings.a */, + ); + name = Products; + sourceTree = ""; + }; + 1A0C0E891778088700838530 /* Frameworks */ = { + isa = PBXGroup; + children = ( + A00B432717795C5C00480238 /* spidermonkey-mac */, + 1A0C0E8A1778088700838530 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 1A0C0E981778093E00838530 /* bindings */ = { + isa = PBXGroup; + children = ( + 1A0C0E991778095000838530 /* cocos2d_specifics.cpp */, + 1A0C0E9A1778095000838530 /* cocos2d_specifics.hpp */, + 1A0C0E9B1778095000838530 /* cocosjs_manual_conversions.cpp */, + 1A0C0E9C1778095000838530 /* cocosjs_manual_conversions.h */, + 1A0C0E9D1778095000838530 /* generated */, + 1A0C0EA51778095000838530 /* js */, + 1A0C0EB21778095000838530 /* js_bindings_ccbreader.cpp */, + 1A0C0EB31778095000838530 /* js_bindings_ccbreader.h */, + 1A0C0EB41778095000838530 /* js_bindings_chipmunk_auto_classes_registration.h */, + 1A0C0EB51778095000838530 /* js_bindings_chipmunk_auto_classes.cpp */, + 1A0C0EB61778095000838530 /* js_bindings_chipmunk_auto_classes.h */, + 1A0C0EB71778095000838530 /* js_bindings_chipmunk_functions_registration.h */, + 1A0C0EB81778095000838530 /* js_bindings_chipmunk_functions.cpp */, + 1A0C0EB91778095000838530 /* js_bindings_chipmunk_functions.h */, + 1A0C0EBA1778095000838530 /* js_bindings_chipmunk_manual.cpp */, + 1A0C0EBB1778095000838530 /* js_bindings_chipmunk_manual.h */, + 1A0C0EBC1778095000838530 /* js_bindings_chipmunk_registration.cpp */, + 1A0C0EBD1778095000838530 /* js_bindings_chipmunk_registration.h */, + 1A0C0EBE1778095000838530 /* js_bindings_config.h */, + 1A0C0EBF1778095000838530 /* js_bindings_core.cpp */, + 1A0C0EC01778095000838530 /* js_bindings_core.h */, + 1A0C0EC11778095000838530 /* js_bindings_opengl.cpp */, + 1A0C0EC21778095000838530 /* js_bindings_opengl.h */, + 1A0C0EC31778095000838530 /* js_bindings_system_functions_registration.h */, + 1A0C0EC41778095000838530 /* js_bindings_system_functions.cpp */, + 1A0C0EC51778095000838530 /* js_bindings_system_functions.h */, + 1A0C0EC61778095000838530 /* js_bindings_system_registration.cpp */, + 1A0C0EC71778095000838530 /* js_bindings_system_registration.h */, + 1A0C0EC81778095000838530 /* js_manual_conversions.cpp */, + 1A0C0EC91778095000838530 /* js_manual_conversions.h */, + 1A0C0ECA1778095000838530 /* jsb_cocos2dx_extension_manual.cpp */, + 1A0C0ECB1778095000838530 /* jsb_cocos2dx_extension_manual.h */, + 1A0C0ECC1778095000838530 /* jsb_helper.h */, + 1A0C0ECD1778095000838530 /* jsb_opengl_functions.cpp */, + 1A0C0ECE1778095000838530 /* jsb_opengl_functions.h */, + 1A0C0ECF1778095000838530 /* jsb_opengl_manual.cpp */, + 1A0C0ED01778095000838530 /* jsb_opengl_manual.h */, + 1A0C0ED11778095000838530 /* jsb_opengl_registration.cpp */, + 1A0C0ED21778095000838530 /* jsb_opengl_registration.h */, + 1A0C0ED31778095000838530 /* jsb_websocket.cpp */, + 1A0C0ED41778095000838530 /* jsb_websocket.h */, + 1A0C0ED51778095000838530 /* ScriptingCore.cpp */, + 1A0C0ED61778095000838530 /* ScriptingCore.h */, + 1A0C0ED71778095000838530 /* spidermonkey_specifics.h */, + 1A0C0ED81778095000838530 /* XMLHTTPRequest.cpp */, + 1A0C0ED91778095000838530 /* XMLHTTPRequest.h */, + ); + name = bindings; + sourceTree = ""; + }; + 1A0C0E9D1778095000838530 /* generated */ = { + isa = PBXGroup; + children = ( + 1A0C0E9E1778095000838530 /* jsb_cocos2dx_auto.cpp */, + 1A0C0E9F1778095000838530 /* jsb_cocos2dx_auto.hpp */, + 1A0C0EA01778095000838530 /* jsb_cocos2dx_auto_api.js */, + 1A0C0EA11778095000838530 /* jsb_cocos2dx_extension_auto.cpp */, + 1A0C0EA21778095000838530 /* jsb_cocos2dx_extension_auto.hpp */, + 1A0C0EA31778095000838530 /* jsb_cocos2dx_extension_auto_api.js */, + 1A0C0EA41778095000838530 /* README */, + ); + name = generated; + path = ../generated; + sourceTree = ""; + }; + 1A0C0EA51778095000838530 /* js */ = { + isa = PBXGroup; + children = ( + 1A0C0EA61778095000838530 /* jsb.js */, + 1A0C0EA71778095000838530 /* jsb_chipmunk.js */, + 1A0C0EA81778095000838530 /* jsb_chipmunk_constants.js */, + 1A0C0EA91778095000838530 /* jsb_cocos2d.js */, + 1A0C0EAA1778095000838530 /* jsb_cocos2d_constants.js */, + 1A0C0EAB1778095000838530 /* jsb_cocos2d_extension.js */, + 1A0C0EAC1778095000838530 /* jsb_cocosbuilder.js */, + 1A0C0EAD1778095000838530 /* jsb_debugger.js */, + 1A0C0EAE1778095000838530 /* jsb_opengl.js */, + 1A0C0EAF1778095000838530 /* jsb_opengl_constants.js */, + 1A0C0EB01778095000838530 /* jsb_sys.js */, + 1A0C0EB11778095000838530 /* main.debug.js */, + ); + name = js; + path = ../js; + sourceTree = ""; + }; + A00B432717795C5C00480238 /* spidermonkey-mac */ = { + isa = PBXGroup; + children = ( + A00B432817795C5C00480238 /* include */, + A00B437117795C5C00480238 /* lib */, + ); + name = "spidermonkey-mac"; + path = "../../spidermonkey-mac"; + sourceTree = ""; + }; + A00B432817795C5C00480238 /* include */ = { + isa = PBXGroup; + children = ( + A05FCAF4177D12D900BE600E /* js */, + A05FCB04177D12D900BE600E /* js-config.h */, + A05FCB05177D12D900BE600E /* js.msg */, + A05FCB06177D12D900BE600E /* jsalloc.h */, + A05FCB07177D12D900BE600E /* jsapi.h */, + A05FCB08177D12D900BE600E /* jsclass.h */, + A05FCB09177D12D900BE600E /* jsclist.h */, + A05FCB0A177D12D900BE600E /* jscpucfg.h */, + A05FCB0B177D12D900BE600E /* jsdbgapi.h */, + A05FCB0C177D12D900BE600E /* jsdhash.h */, + A05FCB0D177D12D900BE600E /* jsfriendapi.h */, + A05FCB0E177D12D900BE600E /* jslock.h */, + A05FCB0F177D12D900BE600E /* json.h */, + A05FCB10177D12D900BE600E /* jsperf.h */, + A05FCB11177D12D900BE600E /* jsprf.h */, + A05FCB12177D12D900BE600E /* jsprototypes.h */, + A05FCB13177D12D900BE600E /* jsproxy.h */, + A05FCB14177D12D900BE600E /* jsprvtd.h */, + A05FCB15177D12D900BE600E /* jspubtd.h */, + A05FCB16177D12D900BE600E /* jstypes.h */, + A05FCB17177D12D900BE600E /* jsutil.h */, + A05FCB18177D12D900BE600E /* jsversion.h */, + A05FCB19177D12D900BE600E /* jswrapper.h */, + A05FCB1A177D12D900BE600E /* mozilla */, + ); + path = include; + sourceTree = ""; + }; + A00B437117795C5C00480238 /* lib */ = { + isa = PBXGroup; + children = ( + A00B437217795C5C00480238 /* libjs_static.a */, + ); + path = lib; + sourceTree = ""; + }; + A05FCAF4177D12D900BE600E /* js */ = { + isa = PBXGroup; + children = ( + A05FCAF5177D12D900BE600E /* Anchor.h */, + A05FCAF6177D12D900BE600E /* CallArgs.h */, + A05FCAF7177D12D900BE600E /* CharacterEncoding.h */, + A05FCAF8177D12D900BE600E /* GCAPI.h */, + A05FCAF9177D12D900BE600E /* HashTable.h */, + A05FCAFA177D12D900BE600E /* HeapAPI.h */, + A05FCAFB177D12D900BE600E /* LegacyIntTypes.h */, + A05FCAFC177D12D900BE600E /* MemoryMetrics.h */, + A05FCAFD177D12D900BE600E /* PropertyKey.h */, + A05FCAFE177D12D900BE600E /* RequiredDefines.h */, + A05FCAFF177D12D900BE600E /* RootingAPI.h */, + A05FCB00177D12D900BE600E /* TemplateLib.h */, + A05FCB01177D12D900BE600E /* Utility.h */, + A05FCB02177D12D900BE600E /* Value.h */, + A05FCB03177D12D900BE600E /* Vector.h */, + ); + path = js; + sourceTree = ""; + }; + A05FCB1A177D12D900BE600E /* mozilla */ = { + isa = PBXGroup; + children = ( + A05FCB1B177D12D900BE600E /* Assertions.h */, + A05FCB1C177D12D900BE600E /* Attributes.h */, + A05FCB1D177D12D900BE600E /* BloomFilter.h */, + A05FCB1E177D12D900BE600E /* Char16.h */, + A05FCB1F177D12D900BE600E /* CheckedInt.h */, + A05FCB20177D12D900BE600E /* Compiler.h */, + A05FCB21177D12D900BE600E /* Constants.h */, + A05FCB22177D12D900BE600E /* DebugOnly.h */, + A05FCB23177D12D900BE600E /* EnumSet.h */, + A05FCB24177D12D900BE600E /* FloatingPoint.h */, + A05FCB25177D12D900BE600E /* GuardObjects.h */, + A05FCB26177D12D900BE600E /* HashFunctions.h */, + A05FCB27177D12D900BE600E /* Likely.h */, + A05FCB28177D12D900BE600E /* LinkedList.h */, + A05FCB29177D12D900BE600E /* MathAlgorithms.h */, + A05FCB2A177D12D900BE600E /* MemoryChecking.h */, + A05FCB2B177D12D900BE600E /* MSStdInt.h */, + A05FCB2C177D12D900BE600E /* NullPtr.h */, + A05FCB2D177D12D900BE600E /* Range.h */, + A05FCB2E177D12D900BE600E /* RangedPtr.h */, + A05FCB2F177D12D900BE600E /* RefPtr.h */, + A05FCB30177D12D900BE600E /* Scoped.h */, + A05FCB31177D12D900BE600E /* SHA1.h */, + A05FCB32177D12D900BE600E /* SplayTree.h */, + A05FCB33177D12D900BE600E /* StandardInteger.h */, + A05FCB34177D12D900BE600E /* ThreadLocal.h */, + A05FCB35177D12D900BE600E /* TypedEnum.h */, + A05FCB36177D12D900BE600E /* Types.h */, + A05FCB37177D12D900BE600E /* TypeTraits.h */, + A05FCB38177D12D900BE600E /* Util.h */, + A05FCB39177D12D900BE600E /* WeakPtr.h */, + ); + path = mozilla; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1A0C0E861778088700838530 /* jsbindings */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1A0C0E951778088700838530 /* Build configuration list for PBXNativeTarget "jsbindings" */; + buildPhases = ( + 1A0C0E831778088700838530 /* Sources */, + 1A0C0E841778088700838530 /* Frameworks */, + 1A0C0E851778088700838530 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = jsbindings; + productName = jsbindings; + productReference = 1A0C0E871778088700838530 /* libjsbindings.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1A0C0E7F1778088700838530 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + }; + buildConfigurationList = 1A0C0E821778088700838530 /* Build configuration list for PBXProject "jsbindings" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 1A0C0E7E1778088700838530; + productRefGroup = 1A0C0E881778088700838530 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1A0C0E861778088700838530 /* jsbindings */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 1A0C0E831778088700838530 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A6E46D51778162E0055514D /* jsb_cocos2dx_extension_auto.cpp in Sources */, + 1A0C0EDA1778095000838530 /* cocos2d_specifics.cpp in Sources */, + 1A0C0EDB1778095000838530 /* cocosjs_manual_conversions.cpp in Sources */, + 1A0C0EDC1778095000838530 /* jsb_cocos2dx_auto.cpp in Sources */, + 1A0C0EEC1778095000838530 /* js_bindings_ccbreader.cpp in Sources */, + 1A0C0EED1778095000838530 /* js_bindings_chipmunk_auto_classes.cpp in Sources */, + 1A0C0EEE1778095000838530 /* js_bindings_chipmunk_functions.cpp in Sources */, + 1A0C0EEF1778095000838530 /* js_bindings_chipmunk_manual.cpp in Sources */, + 1A0C0EF01778095000838530 /* js_bindings_chipmunk_registration.cpp in Sources */, + 1A0C0EF11778095000838530 /* js_bindings_core.cpp in Sources */, + 1A0C0EF21778095000838530 /* js_bindings_opengl.cpp in Sources */, + 1A0C0EF31778095000838530 /* js_bindings_system_functions.cpp in Sources */, + 1A0C0EF41778095000838530 /* js_bindings_system_registration.cpp in Sources */, + 1A0C0EF51778095000838530 /* js_manual_conversions.cpp in Sources */, + 1A0C0EF61778095000838530 /* jsb_cocos2dx_extension_manual.cpp in Sources */, + 1A0C0EF71778095000838530 /* jsb_opengl_functions.cpp in Sources */, + 1A0C0EF81778095000838530 /* jsb_opengl_manual.cpp in Sources */, + 1A0C0EF91778095000838530 /* jsb_opengl_registration.cpp in Sources */, + 1A0C0EFA1778095000838530 /* jsb_websocket.cpp in Sources */, + 1A0C0EFB1778095000838530 /* ScriptingCore.cpp in Sources */, + 1A0C0EFC1778095000838530 /* XMLHTTPRequest.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1A0C0E931778088700838530 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 1A0C0E941778088700838530 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_PREPROCESSOR_DEFINITIONS = ( + NDEBUG, + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + SDKROOT = macosx; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 1A0C0E961778088700838530 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/jsbindings.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "jsbindings-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOS2D_DEBUG=1", + "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + ); + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/../../../../CocosDenshion/include", + "\"$(SRCROOT)/../../../../external/chipmunk/include/chipmunk\"", + "\"$(SRCROOT)/../../../../external/libwebsockets/mac/include\"", + "\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"", + "\"$(SRCROOT)/../../../../external\"", + "\"$(SRCROOT)/../../../../extensions\"", + "\"$(SRCROOT)/../../../../extensions/LocalStorage\"", + "\"$(SRCROOT)/../../../../extensions/network\"", + "\"$(SRCROOT)/../../../../cocos2dx\"", + "\"$(SRCROOT)/../../../../cocos2dx/include\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/mac\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/mac\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/mac/Simulation\"", + "\"$(SRCROOT)/../../spidermonkey-mac/include\"", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../spidermonkey-mac/lib\"", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 1A0C0E971778088700838530 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/jsbindings.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "jsbindings-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + ); + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/../../../../CocosDenshion/include", + "\"$(SRCROOT)/../../../../external/chipmunk/include/chipmunk\"", + "\"$(SRCROOT)/../../../../external/libwebsockets/mac/include\"", + "\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"", + "\"$(SRCROOT)/../../../../external\"", + "\"$(SRCROOT)/../../../../extensions\"", + "\"$(SRCROOT)/../../../../extensions/LocalStorage\"", + "\"$(SRCROOT)/../../../../extensions/network\"", + "\"$(SRCROOT)/../../../../cocos2dx\"", + "\"$(SRCROOT)/../../../../cocos2dx/include\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/mac\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/mac\"", + "\"$(SRCROOT)/../../../../cocos2dx/platform/mac/Simulation\"", + "\"$(SRCROOT)/../../spidermonkey-mac/include\"", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../spidermonkey-mac/lib\"", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1A0C0E821778088700838530 /* Build configuration list for PBXProject "jsbindings" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1A0C0E931778088700838530 /* Debug */, + 1A0C0E941778088700838530 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1A0C0E951778088700838530 /* Build configuration list for PBXNativeTarget "jsbindings" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1A0C0E961778088700838530 /* Debug */, + 1A0C0E971778088700838530 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1A0C0E7F1778088700838530 /* Project object */; +} diff --git a/scripting/javascript/spidermonkey-mac/include/js-config.h b/scripting/javascript/spidermonkey-mac/include/js-config.h new file mode 100644 index 0000000000..95f19a7012 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js-config.h @@ -0,0 +1,65 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=78: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_config_h___ +#define js_config_h___ + +/* Definitions set at build time that affect SpiderMonkey's public API. + This header file is generated by the SpiderMonkey configure script, + and installed along with jsapi.h. */ + +/* Define to 1 if SpiderMonkey should support multi-threaded clients. */ +/* #undef JS_THREADSAFE */ + +/* Define to 1 if SpiderMonkey should include ctypes support. */ +/* #undef JS_HAS_CTYPES */ + +/* Define to 1 if SpiderMonkey should support the ability to perform + entirely too much GC. */ +#define JS_GC_ZEAL 1 + +/* Define to 1 if the header is present and + useable. See jscpucfg.h. */ +/* #undef JS_HAVE_ENDIAN_H */ + +/* Define to 1 if the header is present and + useable. See jscpucfg.h. */ +#define JS_HAVE_MACHINE_ENDIAN_H 1 + +/* Define to 1 if the header is present and + useable. See jscpucfg.h. */ +/* #undef JS_HAVE_SYS_ISA_DEFS_H */ + +/* Define to 1 if the defines int8_t, etc. */ +/* #undef JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES */ + +/* Define to 1 if the N-byte __intN types are defined by the + compiler. */ +/* #undef JS_HAVE___INTN */ + +/* Define to 1 if #including provides definitions for + intptr_t and uintptr_t. */ +/* #undef JS_STDDEF_H_HAS_INTPTR_T */ + +/* Define to 1 if #including provides definitions for + intptr_t and uintptr_t. */ +/* #undef JS_CRTDEFS_H_HAS_INTPTR_T */ + +/* The configure script defines these if it doesn't #define + JS_HAVE_STDINT_H. */ +/* #undef JS_INT8_TYPE */ +/* #undef JS_INT16_TYPE */ +/* #undef JS_INT32_TYPE */ +/* #undef JS_INT64_TYPE */ +/* #undef JS_INTPTR_TYPE */ +#define JS_BYTES_PER_WORD 8 + +/* Some mozilla code uses JS-friend APIs that depend on JS_METHODJIT being + correct. */ +#define JS_METHODJIT 1 + +#endif /* js_config_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js.msg b/scripting/javascript/spidermonkey-mac/include/js.msg new file mode 100644 index 0000000000..1f727dce0b --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js.msg @@ -0,0 +1,401 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This is the JavaScript error message file. + * + * The format for each JS error message is: + * + * MSG_DEF(, , , , + * ) + * + * where ; + * is a legal C identifer that will be used in the + * JS engine source. + * + * is an unique integral value identifying this error. + * + * is an integer literal specifying the total number of + * replaceable arguments in the following format string. + * + * is an exception index from the enum in jsexn.c; + * JSEXN_NONE for none. The given exception index will be raised by the + * engine when the corresponding error occurs. + * + * is a string literal, optionally containing sequences + * {X} where X is an integer representing the argument number that will + * be replaced with a string value when the error is reported. + * + * e.g. + * + * MSG_DEF(JSMSG_NOT_A_SUBSPECIES, 73, JSEXN_NONE, 2, + * "{0} is not a member of the {1} family") + * + * can be used: + * + * JS_ReportErrorNumber(JSMSG_NOT_A_SUBSPECIES, "Rhino", "Monkey"); + * + * to report: + * + * "Rhino is not a member of the Monkey family" + * + * When removing MSG_DEFs, convert them to JSMSG_UNUSED placeholders: + * + * MSG_DEF(JSMSG_UNUSED7, 7, 0, JSEXN_NONE, "") + * + * Before adding a new MSG_DEF at the end, look for existing JSMSG_UNUSED + * free index placeholders in the middle of the list. + */ + +MSG_DEF(JSMSG_NOT_AN_ERROR, 0, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_NOT_DEFINED, 1, 1, JSEXN_REFERENCEERR, "{0} is not defined") +MSG_DEF(JSMSG_INACTIVE, 2, 0, JSEXN_INTERNALERR, "nothing active on context") +MSG_DEF(JSMSG_MORE_ARGS_NEEDED, 3, 3, JSEXN_TYPEERR, "{0} requires more than {1} argument{2}") +MSG_DEF(JSMSG_BAD_CHAR, 4, 1, JSEXN_INTERNALERR, "invalid format character {0}") +MSG_DEF(JSMSG_BAD_TYPE, 5, 1, JSEXN_TYPEERR, "unknown type {0}") +MSG_DEF(JSMSG_ALLOC_OVERFLOW, 6, 0, JSEXN_INTERNALERR, "allocation size overflow") +MSG_DEF(JSMSG_MISSING_HEXDIGITS, 7, 0, JSEXN_SYNTAXERR, "missing hexadecimal digits after '0x'") +MSG_DEF(JSMSG_INCOMPATIBLE_PROTO, 8, 3, JSEXN_TYPEERR, "{0}.prototype.{1} called on incompatible {2}") +MSG_DEF(JSMSG_NO_CONSTRUCTOR, 9, 1, JSEXN_TYPEERR, "{0} has no constructor") +MSG_DEF(JSMSG_CANT_ALIAS, 10, 3, JSEXN_TYPEERR, "can't alias {0} to {1} in class {2}") +MSG_DEF(JSMSG_NOT_SCRIPTED_FUNCTION, 11, 1, JSEXN_TYPEERR, "{0} is not a scripted function") +MSG_DEF(JSMSG_BAD_SORT_ARG, 12, 0, JSEXN_TYPEERR, "invalid Array.prototype.sort argument") +MSG_DEF(JSMSG_BAD_ATOMIC_NUMBER, 13, 1, JSEXN_INTERNALERR, "internal error: no index for atom {0}") +MSG_DEF(JSMSG_TOO_MANY_LITERALS, 14, 0, JSEXN_INTERNALERR, "too many literals") +MSG_DEF(JSMSG_CANT_WATCH, 15, 1, JSEXN_TYPEERR, "can't watch non-native objects of class {0}") +MSG_DEF(JSMSG_STACK_UNDERFLOW, 16, 2, JSEXN_INTERNALERR, "internal error compiling {0}: stack underflow at pc {1}") +MSG_DEF(JSMSG_NEED_DIET, 17, 1, JSEXN_INTERNALERR, "{0} too large") +MSG_DEF(JSMSG_TOO_MANY_LOCAL_ROOTS, 18, 0, JSEXN_ERR, "out of local root space") +MSG_DEF(JSMSG_READ_ONLY, 19, 1, JSEXN_TYPEERR, "{0} is read-only") +MSG_DEF(JSMSG_BAD_FORMAL, 20, 0, JSEXN_SYNTAXERR, "malformed formal parameter") +MSG_DEF(JSMSG_CANT_DELETE, 21, 1, JSEXN_TYPEERR, "property {0} is non-configurable and can't be deleted") +MSG_DEF(JSMSG_NOT_FUNCTION, 22, 1, JSEXN_TYPEERR, "{0} is not a function") +MSG_DEF(JSMSG_NOT_CONSTRUCTOR, 23, 1, JSEXN_TYPEERR, "{0} is not a constructor") +MSG_DEF(JSMSG_INVALID_DATE, 24, 0, JSEXN_RANGEERR, "invalid date") +MSG_DEF(JSMSG_TOO_DEEP, 25, 1, JSEXN_INTERNALERR, "{0} nested too deeply") +MSG_DEF(JSMSG_OVER_RECURSED, 26, 0, JSEXN_INTERNALERR, "too much recursion") +MSG_DEF(JSMSG_IN_NOT_OBJECT, 27, 1, JSEXN_TYPEERR, "invalid 'in' operand {0}") +MSG_DEF(JSMSG_BAD_NEW_RESULT, 28, 1, JSEXN_TYPEERR, "invalid new expression result {0}") +MSG_DEF(JSMSG_OBJECT_ACCESS_DENIED, 29, 0, JSEXN_ERR, "Permission denied to access object") +MSG_DEF(JSMSG_PROPERTY_ACCESS_DENIED, 30, 1, JSEXN_ERR, "Permission denied to access property '{0}'") +MSG_DEF(JSMSG_BAD_INSTANCEOF_RHS, 31, 1, JSEXN_TYPEERR, "invalid 'instanceof' operand {0}") +MSG_DEF(JSMSG_BAD_BYTECODE, 32, 1, JSEXN_INTERNALERR, "unimplemented JavaScript bytecode {0}") +MSG_DEF(JSMSG_BAD_RADIX, 33, 0, JSEXN_RANGEERR, "radix must be an integer at least 2 and no greater than 36") +MSG_DEF(JSMSG_PAREN_BEFORE_LET, 34, 0, JSEXN_SYNTAXERR, "missing ( before let head") +MSG_DEF(JSMSG_CANT_CONVERT, 35, 1, JSEXN_ERR, "can't convert {0} to an integer") +MSG_DEF(JSMSG_CYCLIC_VALUE, 36, 1, JSEXN_TYPEERR, "cyclic {0} value") +MSG_DEF(JSMSG_COMPILE_EXECED_SCRIPT, 37, 0, JSEXN_TYPEERR, "can't compile over a script that is currently executing") +MSG_DEF(JSMSG_CANT_CONVERT_TO, 38, 2, JSEXN_TYPEERR, "can't convert {0} to {1}") +MSG_DEF(JSMSG_NO_PROPERTIES, 39, 1, JSEXN_TYPEERR, "{0} has no properties") +MSG_DEF(JSMSG_CANT_FIND_CLASS, 40, 1, JSEXN_TYPEERR, "can't find class id {0}") +MSG_DEF(JSMSG_DEAD_OBJECT, 41, 0, JSEXN_TYPEERR, "can't access dead object") +MSG_DEF(JSMSG_BYTECODE_TOO_BIG, 42, 2, JSEXN_INTERNALERR, "bytecode {0} too large (limit {1})") +MSG_DEF(JSMSG_UNKNOWN_FORMAT, 43, 1, JSEXN_INTERNALERR, "unknown bytecode format {0}") +MSG_DEF(JSMSG_TOO_MANY_CON_ARGS, 44, 0, JSEXN_SYNTAXERR, "too many constructor arguments") +MSG_DEF(JSMSG_TOO_MANY_FUN_ARGS, 45, 0, JSEXN_SYNTAXERR, "too many function arguments") +MSG_DEF(JSMSG_BAD_QUANTIFIER, 46, 0, JSEXN_SYNTAXERR, "invalid quantifier") +MSG_DEF(JSMSG_MIN_TOO_BIG, 47, 1, JSEXN_SYNTAXERR, "overlarge minimum {0}") +MSG_DEF(JSMSG_MAX_TOO_BIG, 48, 1, JSEXN_SYNTAXERR, "overlarge maximum {0}") +MSG_DEF(JSMSG_OUT_OF_ORDER, 49, 1, JSEXN_SYNTAXERR, "maximum {0} less than minimum") +MSG_DEF(JSMSG_BAD_DESTRUCT_DECL, 50, 0, JSEXN_SYNTAXERR, "missing = in destructuring declaration") +MSG_DEF(JSMSG_BAD_DESTRUCT_ASS, 51, 0, JSEXN_REFERENCEERR, "invalid destructuring assignment operator") +MSG_DEF(JSMSG_PAREN_AFTER_LET, 52, 0, JSEXN_SYNTAXERR, "missing ) after let head") +MSG_DEF(JSMSG_CURLY_AFTER_LET, 53, 0, JSEXN_SYNTAXERR, "missing } after let block") +MSG_DEF(JSMSG_MISSING_PAREN, 54, 0, JSEXN_SYNTAXERR, "unterminated parenthetical") +MSG_DEF(JSMSG_UNTERM_CLASS, 55, 1, JSEXN_SYNTAXERR, "unterminated character class {0}") +MSG_DEF(JSMSG_TRAILING_SLASH, 56, 0, JSEXN_SYNTAXERR, "trailing \\ in regular expression") +MSG_DEF(JSMSG_BAD_CLASS_RANGE, 57, 0, JSEXN_SYNTAXERR, "invalid range in character class") +MSG_DEF(JSMSG_BAD_REGEXP_FLAG, 58, 1, JSEXN_SYNTAXERR, "invalid regular expression flag {0}") +MSG_DEF(JSMSG_NO_INPUT, 59, 5, JSEXN_SYNTAXERR, "no input for /{0}/{1}{2}{3}{4}") +MSG_DEF(JSMSG_CANT_OPEN, 60, 2, JSEXN_ERR, "can't open {0}: {1}") +MSG_DEF(JSMSG_TOO_MANY_FUN_APPLY_ARGS, 61, 0, JSEXN_RANGEERR, "arguments array passed to Function.prototype.apply is too large") +MSG_DEF(JSMSG_UNMATCHED_RIGHT_PAREN, 62, 0, JSEXN_SYNTAXERR, "unmatched ) in regular expression") +MSG_DEF(JSMSG_TOO_BIG_TO_ENCODE, 63, 0, JSEXN_INTERNALERR, "data are to big to encode") +MSG_DEF(JSMSG_ARG_INDEX_OUT_OF_RANGE, 64, 1, JSEXN_RANGEERR, "argument {0} accesses an index that is out of range") +MSG_DEF(JSMSG_SPREAD_TOO_LARGE, 65, 0, JSEXN_RANGEERR, "array too large due to spread operand(s)") +MSG_DEF(JSMSG_SOURCE_TOO_LONG, 66, 0, JSEXN_RANGEERR, "source is too long") +MSG_DEF(JSMSG_BAD_WEAKMAP_KEY, 67, 0, JSEXN_TYPEERR, "cannot use the given object as a weak map key") +MSG_DEF(JSMSG_BAD_SCRIPT_MAGIC, 68, 0, JSEXN_INTERNALERR, "bad script XDR magic number") +MSG_DEF(JSMSG_PAREN_BEFORE_FORMAL, 69, 0, JSEXN_SYNTAXERR, "missing ( before formal parameters") +MSG_DEF(JSMSG_MISSING_FORMAL, 70, 0, JSEXN_SYNTAXERR, "missing formal parameter") +MSG_DEF(JSMSG_PAREN_AFTER_FORMAL, 71, 0, JSEXN_SYNTAXERR, "missing ) after formal parameters") +MSG_DEF(JSMSG_CURLY_BEFORE_BODY, 72, 0, JSEXN_SYNTAXERR, "missing { before function body") +MSG_DEF(JSMSG_CURLY_AFTER_BODY, 73, 0, JSEXN_SYNTAXERR, "missing } after function body") +MSG_DEF(JSMSG_PAREN_BEFORE_COND, 74, 0, JSEXN_SYNTAXERR, "missing ( before condition") +MSG_DEF(JSMSG_PAREN_AFTER_COND, 75, 0, JSEXN_SYNTAXERR, "missing ) after condition") +MSG_DEF(JSMSG_BAD_DUP_ARGS, 76, 0, JSEXN_SYNTAXERR, "duplicate argument names not allowed in this context") +MSG_DEF(JSMSG_NAME_AFTER_DOT, 77, 0, JSEXN_SYNTAXERR, "missing name after . operator") +MSG_DEF(JSMSG_BRACKET_IN_INDEX, 78, 0, JSEXN_SYNTAXERR, "missing ] in index expression") +MSG_DEF(JSMSG_ACCESSOR_DEF_DENIED, 79, 1, JSEXN_ERR, "Permission denied to define accessor property '{0}'") +MSG_DEF(JSMSG_PAREN_BEFORE_SWITCH, 80, 0, JSEXN_SYNTAXERR, "missing ( before switch expression") +MSG_DEF(JSMSG_PAREN_AFTER_SWITCH, 81, 0, JSEXN_SYNTAXERR, "missing ) after switch expression") +MSG_DEF(JSMSG_CURLY_BEFORE_SWITCH, 82, 0, JSEXN_SYNTAXERR, "missing { before switch body") +MSG_DEF(JSMSG_COLON_AFTER_CASE, 83, 0, JSEXN_SYNTAXERR, "missing : after case label") +MSG_DEF(JSMSG_WHILE_AFTER_DO, 84, 0, JSEXN_SYNTAXERR, "missing while after do-loop body") +MSG_DEF(JSMSG_PAREN_AFTER_FOR, 85, 0, JSEXN_SYNTAXERR, "missing ( after for") +MSG_DEF(JSMSG_SEMI_AFTER_FOR_INIT, 86, 0, JSEXN_SYNTAXERR, "missing ; after for-loop initializer") +MSG_DEF(JSMSG_SEMI_AFTER_FOR_COND, 87, 0, JSEXN_SYNTAXERR, "missing ; after for-loop condition") +MSG_DEF(JSMSG_PAREN_AFTER_FOR_CTRL, 88, 0, JSEXN_SYNTAXERR, "missing ) after for-loop control") +MSG_DEF(JSMSG_CURLY_BEFORE_TRY, 89, 0, JSEXN_SYNTAXERR, "missing { before try block") +MSG_DEF(JSMSG_CURLY_AFTER_TRY, 90, 0, JSEXN_SYNTAXERR, "missing } after try block") +MSG_DEF(JSMSG_PAREN_BEFORE_CATCH, 91, 0, JSEXN_SYNTAXERR, "missing ( before catch") +MSG_DEF(JSMSG_CATCH_IDENTIFIER, 92, 0, JSEXN_SYNTAXERR, "missing identifier in catch") +MSG_DEF(JSMSG_PAREN_AFTER_CATCH, 93, 0, JSEXN_SYNTAXERR, "missing ) after catch") +MSG_DEF(JSMSG_CURLY_BEFORE_CATCH, 94, 0, JSEXN_SYNTAXERR, "missing { before catch block") +MSG_DEF(JSMSG_CURLY_AFTER_CATCH, 95, 0, JSEXN_SYNTAXERR, "missing } after catch block") +MSG_DEF(JSMSG_CURLY_BEFORE_FINALLY, 96, 0, JSEXN_SYNTAXERR, "missing { before finally block") +MSG_DEF(JSMSG_CURLY_AFTER_FINALLY, 97, 0, JSEXN_SYNTAXERR, "missing } after finally block") +MSG_DEF(JSMSG_CATCH_OR_FINALLY, 98, 0, JSEXN_SYNTAXERR, "missing catch or finally after try") +MSG_DEF(JSMSG_PAREN_BEFORE_WITH, 99, 0, JSEXN_SYNTAXERR, "missing ( before with-statement object") +MSG_DEF(JSMSG_PAREN_AFTER_WITH, 100, 0, JSEXN_SYNTAXERR, "missing ) after with-statement object") +MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 101, 0, JSEXN_SYNTAXERR, "missing } in compound statement") +MSG_DEF(JSMSG_NO_VARIABLE_NAME, 102, 0, JSEXN_SYNTAXERR, "missing variable name") +MSG_DEF(JSMSG_COLON_IN_COND, 103, 0, JSEXN_SYNTAXERR, "missing : in conditional expression") +MSG_DEF(JSMSG_PAREN_AFTER_ARGS, 104, 0, JSEXN_SYNTAXERR, "missing ) after argument list") +MSG_DEF(JSMSG_BRACKET_AFTER_LIST, 105, 0, JSEXN_SYNTAXERR, "missing ] after element list") +MSG_DEF(JSMSG_COLON_AFTER_ID, 106, 0, JSEXN_SYNTAXERR, "missing : after property id") +MSG_DEF(JSMSG_CURLY_AFTER_LIST, 107, 0, JSEXN_SYNTAXERR, "missing } after property list") +MSG_DEF(JSMSG_PAREN_IN_PAREN, 108, 0, JSEXN_SYNTAXERR, "missing ) in parenthetical") +MSG_DEF(JSMSG_SEMI_BEFORE_STMNT, 109, 0, JSEXN_SYNTAXERR, "missing ; before statement") +MSG_DEF(JSMSG_NO_RETURN_VALUE, 110, 1, JSEXN_TYPEERR, "function {0} does not always return a value") +MSG_DEF(JSMSG_DUPLICATE_FORMAL, 111, 1, JSEXN_SYNTAXERR, "duplicate formal argument {0}") +MSG_DEF(JSMSG_EQUAL_AS_ASSIGN, 112, 0, JSEXN_SYNTAXERR, "test for equality (==) mistyped as assignment (=)?") +MSG_DEF(JSMSG_OPTIMIZED_CLOSURE_LEAK, 113, 0, JSEXN_INTERNALERR, "can't access optimized closure") +MSG_DEF(JSMSG_TOO_MANY_DEFAULTS, 114, 0, JSEXN_SYNTAXERR, "more than one switch default") +MSG_DEF(JSMSG_TOO_MANY_CASES, 115, 0, JSEXN_INTERNALERR, "too many switch cases") +MSG_DEF(JSMSG_BAD_SWITCH, 116, 0, JSEXN_SYNTAXERR, "invalid switch statement") +MSG_DEF(JSMSG_BAD_FOR_LEFTSIDE, 117, 0, JSEXN_SYNTAXERR, "invalid for/in left-hand side") +MSG_DEF(JSMSG_CATCH_AFTER_GENERAL, 118, 0, JSEXN_SYNTAXERR, "catch after unconditional catch") +MSG_DEF(JSMSG_CATCH_WITHOUT_TRY, 119, 0, JSEXN_SYNTAXERR, "catch without try") +MSG_DEF(JSMSG_FINALLY_WITHOUT_TRY, 120, 0, JSEXN_SYNTAXERR, "finally without try") +MSG_DEF(JSMSG_LABEL_NOT_FOUND, 121, 0, JSEXN_SYNTAXERR, "label not found") +MSG_DEF(JSMSG_TOUGH_BREAK, 122, 0, JSEXN_SYNTAXERR, "unlabeled break must be inside loop or switch") +MSG_DEF(JSMSG_BAD_CONTINUE, 123, 0, JSEXN_SYNTAXERR, "continue must be inside loop") +MSG_DEF(JSMSG_BAD_RETURN_OR_YIELD, 124, 1, JSEXN_SYNTAXERR, "{0} not in function") +MSG_DEF(JSMSG_BAD_LABEL, 125, 0, JSEXN_SYNTAXERR, "invalid label") +MSG_DEF(JSMSG_DUPLICATE_LABEL, 126, 0, JSEXN_SYNTAXERR, "duplicate label") +MSG_DEF(JSMSG_VAR_HIDES_ARG, 127, 1, JSEXN_TYPEERR, "variable {0} redeclares argument") +MSG_DEF(JSMSG_BAD_VAR_INIT, 128, 0, JSEXN_SYNTAXERR, "invalid variable initialization") +MSG_DEF(JSMSG_BAD_LEFTSIDE_OF_ASS, 129, 0, JSEXN_REFERENCEERR, "invalid assignment left-hand side") +MSG_DEF(JSMSG_BAD_OPERAND, 130, 1, JSEXN_SYNTAXERR, "invalid {0} operand") +MSG_DEF(JSMSG_BAD_PROP_ID, 131, 0, JSEXN_SYNTAXERR, "invalid property id") +MSG_DEF(JSMSG_RESERVED_ID, 132, 1, JSEXN_SYNTAXERR, "{0} is a reserved identifier") +MSG_DEF(JSMSG_SYNTAX_ERROR, 133, 0, JSEXN_SYNTAXERR, "syntax error") +MSG_DEF(JSMSG_UNUSED134, 134, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_BAD_PROTOTYPE, 135, 1, JSEXN_TYPEERR, "'prototype' property of {0} is not an object") +MSG_DEF(JSMSG_MISSING_EXPONENT, 136, 0, JSEXN_SYNTAXERR, "missing exponent") +MSG_DEF(JSMSG_OUT_OF_MEMORY, 137, 0, JSEXN_ERR, "out of memory") +MSG_DEF(JSMSG_UNTERMINATED_STRING, 138, 0, JSEXN_SYNTAXERR, "unterminated string literal") +MSG_DEF(JSMSG_TOO_MANY_PARENS, 139, 0, JSEXN_INTERNALERR, "too many parentheses in regular expression") +MSG_DEF(JSMSG_UNTERMINATED_COMMENT, 140, 0, JSEXN_SYNTAXERR, "unterminated comment") +MSG_DEF(JSMSG_UNTERMINATED_REGEXP, 141, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal") +MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE, 142, 0, JSEXN_TYPEERR, "bad cloned function scope chain") +MSG_DEF(JSMSG_UNUSED143, 143, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_ILLEGAL_CHARACTER, 144, 0, JSEXN_SYNTAXERR, "illegal character") +MSG_DEF(JSMSG_BAD_OCTAL, 145, 1, JSEXN_SYNTAXERR, "{0} is not a legal ECMA-262 octal constant") +MSG_DEF(JSMSG_UNUSED146, 146, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION, 147, 1, JSEXN_INTERNALERR, "uncaught exception: {0}") +MSG_DEF(JSMSG_INVALID_BACKREF, 148, 0, JSEXN_SYNTAXERR, "non-octal digit in an escape sequence that doesn't match a back-reference") +MSG_DEF(JSMSG_BAD_BACKREF, 149, 0, JSEXN_SYNTAXERR, "back-reference exceeds number of capturing parentheses") +MSG_DEF(JSMSG_PRECISION_RANGE, 150, 1, JSEXN_RANGEERR, "precision {0} out of range") +MSG_DEF(JSMSG_BAD_GETTER_OR_SETTER, 151, 1, JSEXN_TYPEERR, "invalid {0} usage") +MSG_DEF(JSMSG_BAD_ARRAY_LENGTH, 152, 0, JSEXN_RANGEERR, "invalid array length") +MSG_DEF(JSMSG_CANT_DESCRIBE_PROPS, 153, 1, JSEXN_TYPEERR, "can't describe non-native properties of class {0}") +MSG_DEF(JSMSG_BAD_APPLY_ARGS, 154, 1, JSEXN_TYPEERR, "second argument to Function.prototype.{0} must be an array") +MSG_DEF(JSMSG_REDECLARED_VAR, 155, 2, JSEXN_TYPEERR, "redeclaration of {0} {1}") +MSG_DEF(JSMSG_UNDECLARED_VAR, 156, 1, JSEXN_REFERENCEERR, "assignment to undeclared variable {0}") +MSG_DEF(JSMSG_ANON_NO_RETURN_VALUE, 157, 0, JSEXN_TYPEERR, "anonymous function does not always return a value") +MSG_DEF(JSMSG_DEPRECATED_USAGE, 158, 1, JSEXN_REFERENCEERR, "deprecated {0} usage") +MSG_DEF(JSMSG_BAD_URI, 159, 0, JSEXN_URIERR, "malformed URI sequence") +MSG_DEF(JSMSG_GETTER_ONLY, 160, 0, JSEXN_TYPEERR, "setting a property that has only a getter") +MSG_DEF(JSMSG_IDSTART_AFTER_NUMBER, 161, 0, JSEXN_SYNTAXERR, "identifier starts immediately after numeric literal") +MSG_DEF(JSMSG_UNDEFINED_PROP, 162, 1, JSEXN_REFERENCEERR, "reference to undefined property {0}") +MSG_DEF(JSMSG_USELESS_EXPR, 163, 0, JSEXN_TYPEERR, "useless expression") +MSG_DEF(JSMSG_REDECLARED_PARAM, 164, 1, JSEXN_TYPEERR, "redeclaration of formal parameter {0}") +MSG_DEF(JSMSG_NEWREGEXP_FLAGGED, 165, 0, JSEXN_TYPEERR, "can't supply flags when constructing one RegExp from another") +MSG_DEF(JSMSG_RESERVED_SLOT_RANGE, 166, 0, JSEXN_RANGEERR, "reserved slot index out of range") +MSG_DEF(JSMSG_CANT_DECODE_PRINCIPALS, 167, 0, JSEXN_INTERNALERR, "can't decode JSPrincipals") +MSG_DEF(JSMSG_CANT_SEAL_OBJECT, 168, 1, JSEXN_ERR, "can't seal {0} objects") +MSG_DEF(JSMSG_TOO_MANY_CATCH_VARS, 169, 0, JSEXN_SYNTAXERR, "too many catch variables") +MSG_DEF(JSMSG_UNUSED170, 170, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED171, 171, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED172, 172, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED173, 173, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED174, 174, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_NESTING_GENERATOR, 175, 0, JSEXN_TYPEERR, "already executing generator") +MSG_DEF(JSMSG_UNUSED176, 176, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED177, 177, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED178, 178, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED179, 179, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED180, 180, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED181, 181, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_BAD_GENERATOR_SEND, 182, 1, JSEXN_TYPEERR, "attempt to send {0} to newborn generator") +MSG_DEF(JSMSG_UNUSED183, 183, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED184, 184, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE, 185, 0, JSEXN_TYPEERR, "proxy can't report an extensible object as non-extensible") +MSG_DEF(JSMSG_UNUSED186, 186, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED187, 187, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_INCOMPATIBLE_METHOD, 188, 3, JSEXN_TYPEERR, "{0} {1} called on incompatible {2}") +MSG_DEF(JSMSG_UNUSED189, 189, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED190, 190, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED191, 191, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED192, 192, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_BAD_FOR_EACH_LOOP, 193, 0, JSEXN_SYNTAXERR, "invalid for each loop") +MSG_DEF(JSMSG_UNUSED194, 194, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED195, 195, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNUSED196, 196, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_INTERNAL_INTL_ERROR, 197, 0, JSEXN_ERR, "internal error while computing Intl data") +MSG_DEF(JSMSG_DEFAULT_LOCALE_ERROR, 198, 0, JSEXN_ERR, "internal error getting the default locale") +MSG_DEF(JSMSG_TOO_MANY_LOCALS, 199, 0, JSEXN_SYNTAXERR, "too many local variables") +MSG_DEF(JSMSG_ARRAY_INIT_TOO_BIG, 200, 0, JSEXN_INTERNALERR, "array initialiser too large") +MSG_DEF(JSMSG_REGEXP_TOO_COMPLEX, 201, 0, JSEXN_INTERNALERR, "regular expression too complex") +MSG_DEF(JSMSG_BUFFER_TOO_SMALL, 202, 0, JSEXN_INTERNALERR, "buffer too small") +MSG_DEF(JSMSG_BAD_SURROGATE_CHAR, 203, 1, JSEXN_TYPEERR, "bad surrogate character {0}") +MSG_DEF(JSMSG_UTF8_CHAR_TOO_LARGE, 204, 1, JSEXN_TYPEERR, "UTF-8 character {0} too large") +MSG_DEF(JSMSG_MALFORMED_UTF8_CHAR, 205, 1, JSEXN_TYPEERR, "malformed UTF-8 character sequence at offset {0}") +MSG_DEF(JSMSG_USER_DEFINED_ERROR, 206, 0, JSEXN_ERR, "JS_ReportError was called") +MSG_DEF(JSMSG_WRONG_CONSTRUCTOR, 207, 1, JSEXN_TYPEERR, "wrong constructor called for {0}") +MSG_DEF(JSMSG_BAD_GENERATOR_RETURN, 208, 1, JSEXN_TYPEERR, "generator function {0} returns a value") +MSG_DEF(JSMSG_BAD_ANON_GENERATOR_RETURN, 209, 0, JSEXN_TYPEERR, "anonymous generator function returns a value") +MSG_DEF(JSMSG_NAME_AFTER_FOR_PAREN, 210, 0, JSEXN_SYNTAXERR, "missing name after for (") +MSG_DEF(JSMSG_IN_AFTER_FOR_NAME, 211, 0, JSEXN_SYNTAXERR, "missing 'in' or 'of' after for") +MSG_DEF(JSMSG_BAD_TRAP_RETURN_VALUE, 212, 2, JSEXN_TYPEERR,"trap {1} for {0} returned a primitive value") +MSG_DEF(JSMSG_UNUSED213, 213, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_BAD_GENERATOR_YIELD, 214, 1, JSEXN_TYPEERR, "yield from closing generator {0}") +MSG_DEF(JSMSG_BAD_GENERATOR_SYNTAX, 215, 1, JSEXN_SYNTAXERR, "{0} expression must be parenthesized") +MSG_DEF(JSMSG_ARRAY_COMP_LEFTSIDE, 216, 0, JSEXN_SYNTAXERR, "invalid array comprehension left-hand side") +MSG_DEF(JSMSG_UNUSED217, 217, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_EMPTY_ARRAY_REDUCE, 218, 0, JSEXN_TYPEERR, "reduce of empty array with no initial value") +MSG_DEF(JSMSG_UNUSED219, 219, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_BAD_DELETE_OPERAND, 220, 0, JSEXN_REFERENCEERR, "invalid delete operand") +MSG_DEF(JSMSG_BAD_INCOP_OPERAND, 221, 0, JSEXN_REFERENCEERR, "invalid increment/decrement operand") +MSG_DEF(JSMSG_UNEXPECTED_TYPE, 222, 2, JSEXN_TYPEERR, "{0} is {1}") +MSG_DEF(JSMSG_LET_DECL_NOT_IN_BLOCK, 223, 0, JSEXN_SYNTAXERR, "let declaration not directly within block") +MSG_DEF(JSMSG_BAD_OBJECT_INIT, 224, 0, JSEXN_SYNTAXERR, "invalid object initializer") +MSG_DEF(JSMSG_CANT_SET_ARRAY_ATTRS, 225, 0, JSEXN_INTERNALERR, "can't set attributes on indexed array properties") +MSG_DEF(JSMSG_EVAL_ARITY, 226, 0, JSEXN_TYPEERR, "eval accepts only one parameter") +MSG_DEF(JSMSG_MISSING_FUN_ARG, 227, 2, JSEXN_TYPEERR, "missing argument {0} when calling function {1}") +MSG_DEF(JSMSG_JSON_BAD_PARSE, 228, 1, JSEXN_SYNTAXERR, "JSON.parse: {0}") +MSG_DEF(JSMSG_JSON_BAD_STRINGIFY, 229, 0, JSEXN_ERR, "JSON.stringify") +MSG_DEF(JSMSG_NOT_CALLABLE_OR_UNDEFINED, 230, 0, JSEXN_TYPEERR, "value is not a function or undefined") +MSG_DEF(JSMSG_NOT_NONNULL_OBJECT, 231, 0, JSEXN_TYPEERR, "value is not a non-null object") +MSG_DEF(JSMSG_DEPRECATED_OCTAL, 232, 0, JSEXN_SYNTAXERR, "octal literals and octal escape sequences are deprecated") +MSG_DEF(JSMSG_STRICT_CODE_WITH, 233, 0, JSEXN_SYNTAXERR, "strict mode code may not contain 'with' statements") +MSG_DEF(JSMSG_DUPLICATE_PROPERTY, 234, 1, JSEXN_SYNTAXERR, "property name {0} appears more than once in object literal") +MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 235, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated") +MSG_DEF(JSMSG_DEPRECATED_ASSIGN, 236, 1, JSEXN_SYNTAXERR, "assignment to {0} is deprecated") +MSG_DEF(JSMSG_BAD_BINDING, 237, 1, JSEXN_SYNTAXERR, "redefining {0} is deprecated") +MSG_DEF(JSMSG_INVALID_DESCRIPTOR, 238, 0, JSEXN_TYPEERR, "property descriptors must not specify a value or be writable when a getter or setter has been specified") +MSG_DEF(JSMSG_OBJECT_NOT_EXTENSIBLE, 239, 1, JSEXN_TYPEERR, "{0} is not extensible") +MSG_DEF(JSMSG_CANT_REDEFINE_PROP, 240, 1, JSEXN_TYPEERR, "can't redefine non-configurable property '{0}'") +MSG_DEF(JSMSG_CANT_APPEND_TO_ARRAY, 241, 0, JSEXN_TYPEERR, "can't add elements past the end of an array if its length property is unwritable") +MSG_DEF(JSMSG_CANT_DEFINE_ARRAY_LENGTH,242, 0, JSEXN_INTERNALERR, "defining the length property on an array is not currently supported") +MSG_DEF(JSMSG_CANT_DEFINE_ARRAY_INDEX,243, 0, JSEXN_TYPEERR, "can't define array index property") +MSG_DEF(JSMSG_TYPED_ARRAY_BAD_INDEX, 244, 0, JSEXN_ERR, "invalid or out-of-range index") +MSG_DEF(JSMSG_TYPED_ARRAY_NEGATIVE_ARG, 245, 1, JSEXN_ERR, "argument {0} must be >= 0") +MSG_DEF(JSMSG_TYPED_ARRAY_BAD_ARGS, 246, 0, JSEXN_ERR, "invalid arguments") +MSG_DEF(JSMSG_CSP_BLOCKED_FUNCTION, 247, 0, JSEXN_ERR, "call to Function() blocked by CSP") +MSG_DEF(JSMSG_BAD_GET_SET_FIELD, 248, 1, JSEXN_TYPEERR, "property descriptor's {0} field is neither undefined nor a function") +MSG_DEF(JSMSG_BAD_PROXY_FIX, 249, 0, JSEXN_TYPEERR, "proxy was fixed while executing the handler") +MSG_DEF(JSMSG_INVALID_EVAL_SCOPE_ARG, 250, 0, JSEXN_EVALERR, "invalid eval scope argument") +MSG_DEF(JSMSG_ACCESSOR_WRONG_ARGS, 251, 3, JSEXN_SYNTAXERR, "{0} functions must have {1} argument{2}") +MSG_DEF(JSMSG_THROW_TYPE_ERROR, 252, 0, JSEXN_TYPEERR, "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them") +MSG_DEF(JSMSG_BAD_TOISOSTRING_PROP, 253, 0, JSEXN_TYPEERR, "toISOString property is not callable") +MSG_DEF(JSMSG_BAD_PARSE_NODE, 254, 0, JSEXN_INTERNALERR, "bad parse node") +MSG_DEF(JSMSG_NOT_EXPECTED_TYPE, 255, 3, JSEXN_TYPEERR, "{0}: expected {1}, got {2}") +MSG_DEF(JSMSG_CALLER_IS_STRICT, 256, 0, JSEXN_TYPEERR, "access to strict mode caller function is censored") +MSG_DEF(JSMSG_NEED_DEBUG_MODE, 257, 0, JSEXN_ERR, "function can be called only in debug mode") +MSG_DEF(JSMSG_STRICT_CODE_LET_EXPR_STMT, 258, 0, JSEXN_ERR, "strict mode code may not contain unparenthesized let expression statements") +MSG_DEF(JSMSG_CANT_CHANGE_EXTENSIBILITY, 259, 0, JSEXN_TYPEERR, "can't change object's extensibility") +MSG_DEF(JSMSG_SC_BAD_SERIALIZED_DATA, 260, 1, JSEXN_INTERNALERR, "bad serialized structured data ({0})") +MSG_DEF(JSMSG_SC_UNSUPPORTED_TYPE, 261, 0, JSEXN_TYPEERR, "unsupported type for structured data") +MSG_DEF(JSMSG_SC_RECURSION, 262, 0, JSEXN_INTERNALERR, "recursive object") +MSG_DEF(JSMSG_UNUSED263, 263, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_BAD_CLONE_VERSION, 264, 0, JSEXN_ERR, "unsupported structured clone version") +MSG_DEF(JSMSG_CANT_CLONE_OBJECT, 265, 0, JSEXN_TYPEERR, "can't clone object") +MSG_DEF(JSMSG_UNUSED266, 266, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_STRICT_FUNCTION_STATEMENT, 267, 0, JSEXN_SYNTAXERR, "in strict mode code, functions may be declared only at top level or immediately within another function") +MSG_DEF(JSMSG_INVALID_FOR_IN_INIT, 268, 0, JSEXN_SYNTAXERR, "for-in loop let declaration may not have an initializer") +MSG_DEF(JSMSG_CLEARED_SCOPE, 269, 0, JSEXN_TYPEERR, "attempt to run compile-and-go script on a cleared scope") +MSG_DEF(JSMSG_MALFORMED_ESCAPE, 270, 1, JSEXN_SYNTAXERR, "malformed {0} character escape sequence") +MSG_DEF(JSMSG_BAD_GENEXP_BODY, 271, 1, JSEXN_SYNTAXERR, "illegal use of {0} in generator expression") +MSG_DEF(JSMSG_UNUSED272, 272, 0, JSEXN_NONE, "") +MSG_DEF(JSMSG_UNNAMED_FUNCTION_STMT, 273, 0, JSEXN_SYNTAXERR, "function statement requires a name") +MSG_DEF(JSMSG_CCW_REQUIRED, 274, 1, JSEXN_TYPEERR, "{0}: argument must be an object from a different compartment") +MSG_DEF(JSMSG_DEBUG_BAD_RESUMPTION, 275, 0, JSEXN_TYPEERR, "debugger resumption value must be undefined, {throw: val}, {return: val}, or null") +MSG_DEF(JSMSG_ASSIGN_FUNCTION_OR_NULL, 276, 1, JSEXN_TYPEERR, "value assigned to {0} must be a function or null") +MSG_DEF(JSMSG_DEBUG_NOT_LIVE, 277, 1, JSEXN_ERR, "{0} is not live") +MSG_DEF(JSMSG_DEBUG_OBJECT_WRONG_OWNER, 278, 0, JSEXN_TYPEERR, "Debugger.Object belongs to a different Debugger") +MSG_DEF(JSMSG_DEBUG_OBJECT_PROTO, 279, 0, JSEXN_TYPEERR, "Debugger.Object.prototype is not a valid Debugger.Object") +MSG_DEF(JSMSG_DEBUG_LOOP, 280, 0, JSEXN_TYPEERR, "cannot debug an object in same compartment as debugger or a compartment that is already debugging the debugger") +MSG_DEF(JSMSG_DEBUG_NOT_IDLE, 281, 0, JSEXN_ERR, "can't start debugging: a debuggee script is on the stack") +MSG_DEF(JSMSG_DEBUG_BAD_OFFSET, 282, 0, JSEXN_TYPEERR, "invalid script offset") +MSG_DEF(JSMSG_DEBUG_BAD_LINE, 283, 0, JSEXN_TYPEERR, "invalid line number") +MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGING, 284, 0, JSEXN_ERR, "can't set breakpoint: script global is not a debuggee") +MSG_DEF(JSMSG_DEBUG_COMPARTMENT_MISMATCH, 285, 2, JSEXN_TYPEERR, "{0}: descriptor .{1} property is an object in a different compartment than the target object") +MSG_DEF(JSMSG_DEBUG_NOT_SCRIPT_FRAME, 286, 0, JSEXN_ERR, "stack frame is not running JavaScript code") +MSG_DEF(JSMSG_CANT_WATCH_PROP, 287, 0, JSEXN_TYPEERR, "properties whose names are objects can't be watched") +MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 288, 0, JSEXN_ERR, "call to eval() blocked by CSP") +MSG_DEF(JSMSG_DEBUG_NO_SCOPE_OBJECT, 289, 0, JSEXN_TYPEERR, "declarative Environments don't have binding objects") +MSG_DEF(JSMSG_EMPTY_CONSEQUENT, 290, 0, JSEXN_SYNTAXERR, "mistyped ; after conditional?") +MSG_DEF(JSMSG_NOT_ITERABLE, 291, 1, JSEXN_TYPEERR, "{0} is not iterable") +MSG_DEF(JSMSG_QUERY_LINE_WITHOUT_URL, 292, 0, JSEXN_TYPEERR, "findScripts query object has 'line' property, but no 'url' property") +MSG_DEF(JSMSG_QUERY_INNERMOST_WITHOUT_LINE_URL, 293, 0, JSEXN_TYPEERR, "findScripts query object has 'innermost' property without both 'url' and 'line' properties") +MSG_DEF(JSMSG_DEBUG_VARIABLE_NOT_FOUND, 294, 0, JSEXN_TYPEERR, "variable not found in environment") +MSG_DEF(JSMSG_PARAMETER_AFTER_REST, 295, 0, JSEXN_SYNTAXERR, "parameter after rest parameter") +MSG_DEF(JSMSG_NO_REST_NAME, 296, 0, JSEXN_SYNTAXERR, "no parameter name after ...") +MSG_DEF(JSMSG_ARGUMENTS_AND_REST, 297, 0, JSEXN_SYNTAXERR, "'arguments' object may not be used in conjunction with a rest parameter") +MSG_DEF(JSMSG_FUNCTION_ARGUMENTS_AND_REST, 298, 0, JSEXN_ERR, "the 'arguments' property of a function with a rest parameter may not be used") +MSG_DEF(JSMSG_REST_WITH_DEFAULT, 299, 0, JSEXN_SYNTAXERR, "rest parameter may not have a default") +MSG_DEF(JSMSG_NONDEFAULT_FORMAL_AFTER_DEFAULT, 300, 0, JSEXN_SYNTAXERR, "parameter(s) with default followed by parameter without default") +MSG_DEF(JSMSG_YIELD_IN_DEFAULT, 301, 0, JSEXN_SYNTAXERR, "yield in default expression") +MSG_DEF(JSMSG_INTRINSIC_NOT_DEFINED, 302, 1, JSEXN_REFERENCEERR, "no intrinsic function {0}") +MSG_DEF(JSMSG_ALREADY_HAS_SOURCEMAP, 303, 1, JSEXN_ERR, "{0} is being assigned a source map, yet already has one") +MSG_DEF(JSMSG_PAR_ARRAY_BAD_ARG, 304, 1, JSEXN_RANGEERR, "invalid ParallelArray{0} argument") +MSG_DEF(JSMSG_PAR_ARRAY_BAD_PARTITION, 305, 0, JSEXN_ERR, "argument must be divisible by outermost dimension") +MSG_DEF(JSMSG_PAR_ARRAY_REDUCE_EMPTY, 306, 0, JSEXN_ERR, "cannot reduce ParallelArray object whose outermost dimension is empty") +MSG_DEF(JSMSG_PAR_ARRAY_ALREADY_FLAT, 307, 0, JSEXN_ERR, "cannot flatten 1-dimensional ParallelArray object") +MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_CONFLICT, 308, 0, JSEXN_ERR, "no conflict resolution function provided") +MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_BOUNDS, 309, 0, JSEXN_ERR, "index in scatter vector out of bounds") +MSG_DEF(JSMSG_CANT_REPORT_NC_AS_NE, 310, 0, JSEXN_TYPEERR, "proxy can't report a non-configurable own property as non-existent") +MSG_DEF(JSMSG_CANT_REPORT_E_AS_NE, 311, 0, JSEXN_TYPEERR, "proxy can't report an existing own property as non-existent on a non-extensible object") +MSG_DEF(JSMSG_CANT_REPORT_NEW, 312, 0, JSEXN_TYPEERR, "proxy can't report a new property on a non-extensible object") +MSG_DEF(JSMSG_CANT_REPORT_INVALID, 313, 0, JSEXN_TYPEERR, "proxy can't report an incompatible property descriptor") +MSG_DEF(JSMSG_CANT_REPORT_NE_AS_NC, 314, 0, JSEXN_TYPEERR, "proxy can't report a non-existent property as non-configurable") +MSG_DEF(JSMSG_CANT_DEFINE_NEW, 315, 0, JSEXN_TYPEERR, "proxy can't define a new property on a non-extensible object") +MSG_DEF(JSMSG_CANT_DEFINE_INVALID, 316, 0, JSEXN_TYPEERR, "proxy can't define an incompatible property descriptor") +MSG_DEF(JSMSG_CANT_DEFINE_NE_AS_NC, 317, 0, JSEXN_TYPEERR, "proxy can't define a non-existent property as non-configurable") +MSG_DEF(JSMSG_INVALID_TRAP_RESULT, 318, 2, JSEXN_TYPEERR, "trap {1} for {0} returned an invalid result") +MSG_DEF(JSMSG_CANT_SKIP_NC, 319, 0, JSEXN_TYPEERR, "proxy can't skip a non-configurable property") +MSG_DEF(JSMSG_MUST_REPORT_SAME_VALUE, 320, 0, JSEXN_TYPEERR, "proxy must report the same value for a non-writable, non-configurable property") +MSG_DEF(JSMSG_MUST_REPORT_UNDEFINED, 321, 0, JSEXN_TYPEERR, "proxy must report undefined for a non-configurable accessor property without a getter") +MSG_DEF(JSMSG_CANT_SET_NW_NC, 322, 0, JSEXN_TYPEERR, "proxy can't successfully set a non-writable, non-configurable property") +MSG_DEF(JSMSG_CANT_SET_WO_SETTER, 323, 0, JSEXN_TYPEERR, "proxy can't succesfully set an accessor property without a setter") +MSG_DEF(JSMSG_DEBUG_BAD_REFERENT, 324, 2, JSEXN_TYPEERR, "{0} does not refer to {1}") +MSG_DEF(JSMSG_DEBUG_WRAPPER_IN_WAY, 325, 2, JSEXN_TYPEERR, "{0} is a wrapper around {1}, but a direct reference is required") +MSG_DEF(JSMSG_UNWRAP_DENIED, 326, 0, JSEXN_ERR, "permission denied to unwrap object") +MSG_DEF(JSMSG_INTL_OBJECT_NOT_INITED, 327, 3, JSEXN_TYPEERR, "Intl.{0}.prototype.{1} called on value that's not an object initialized as a {2}") +MSG_DEF(JSMSG_INVALID_LOCALES_ELEMENT,328, 0, JSEXN_TYPEERR, "invalid element in locales argument") +MSG_DEF(JSMSG_INVALID_LANGUAGE_TAG, 329, 1, JSEXN_RANGEERR, "invalid language tag: {0}") +MSG_DEF(JSMSG_INVALID_LOCALE_MATCHER, 330, 1, JSEXN_RANGEERR, "invalid locale matcher in supportedLocalesOf(): {0}") +MSG_DEF(JSMSG_INVALID_OPTION_VALUE, 331, 2, JSEXN_RANGEERR, "invalid value {1} for option {0}") +MSG_DEF(JSMSG_INVALID_DIGITS_VALUE, 332, 1, JSEXN_RANGEERR, "invalid digits value: {0}") +MSG_DEF(JSMSG_INTL_OBJECT_REINITED, 333, 0, JSEXN_TYPEERR, "can't initialize object twice as an object of an Intl constructor") +MSG_DEF(JSMSG_INVALID_CURRENCY_CODE, 334, 1, JSEXN_RANGEERR, "invalid currency code in NumberFormat(): {0}") +MSG_DEF(JSMSG_UNDEFINED_CURRENCY, 335, 0, JSEXN_TYPEERR, "undefined currency in NumberFormat() with currency style") +MSG_DEF(JSMSG_INVALID_TIME_ZONE, 336, 1, JSEXN_RANGEERR, "invalid time zone in DateTimeFormat(): {0}") +MSG_DEF(JSMSG_DATE_NOT_FINITE, 337, 0, JSEXN_RANGEERR, "date value is not finite in DateTimeFormat.format()") +MSG_DEF(JSMSG_MODULE_STATEMENT, 338, 0, JSEXN_SYNTAXERR, "module declarations may only appear at the top level of a program or module body") +MSG_DEF(JSMSG_CURLY_BEFORE_MODULE, 339, 0, JSEXN_SYNTAXERR, "missing { before module body") +MSG_DEF(JSMSG_CURLY_AFTER_MODULE, 340, 0, JSEXN_SYNTAXERR, "missing } after module body") +MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 341, 0, JSEXN_SYNTAXERR, "'use asm' directive only works on function code") +MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL, 342, 1, JSEXN_TYPEERR, "asm.js type error: {0}") +MSG_DEF(JSMSG_USE_ASM_LINK_FAIL, 343, 1, JSEXN_TYPEERR, "asm.js link error: {0}") +MSG_DEF(JSMSG_USE_ASM_TYPE_OK, 344, 0, JSEXN_ERR, "Successfully compiled asm.js code") +MSG_DEF(JSMSG_BAD_ARROW_ARGS, 345, 0, JSEXN_SYNTAXERR, "invalid arrow-function arguments (parentheses around the arrow-function may help)") +MSG_DEF(JSMSG_YIELD_IN_ARROW, 346, 0, JSEXN_SYNTAXERR, "arrow function may not contain yield") +MSG_DEF(JSMSG_WRONG_VALUE, 347, 2, JSEXN_ERR, "expected {0} but found {1}") +MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_BAD_TARGET, 348, 1, JSEXN_ERR, "target for index {0} is not an integer") diff --git a/scripting/javascript/spidermonkey-mac/include/js/Anchor.h b/scripting/javascript/spidermonkey-mac/include/js/Anchor.h new file mode 100644 index 0000000000..166ada5cd2 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/Anchor.h @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* JS::Anchor implementation. */ + +#ifndef js_Anchor_h___ +#define js_Anchor_h___ + +#include "mozilla/Attributes.h" + +class JSFunction; +class JSObject; +class JSScript; +class JSString; + +namespace JS { class Value; } + +namespace JS { + +/* + * Protecting non-Value, non-JSObject *, non-JSString * values from collection + * + * Most of the time, the garbage collector's conservative stack scanner works + * behind the scenes, finding all live values and protecting them from being + * collected. However, when JSAPI client code obtains a pointer to data the + * scanner does not know about, owned by an object the scanner does know about, + * Care Must Be Taken. + * + * The scanner recognizes only a select set of types: pointers to JSObjects and + * similar things (JSFunctions, and so on), pointers to JSStrings, and Values. + * So while the scanner finds all live |JSString| pointers, it does not notice + * |jschar| pointers. + * + * So suppose we have: + * + * void f(JSString *str) { + * const jschar *ch = JS_GetStringCharsZ(str); + * ... do stuff with ch, but no uses of str ...; + * } + * + * After the call to |JS_GetStringCharsZ|, there are no further uses of + * |str|, which means that the compiler is within its rights to not store + * it anywhere. But because the stack scanner will not notice |ch|, there + * is no longer any live value in this frame that would keep the string + * alive. If |str| is the last reference to that |JSString|, and the + * collector runs while we are using |ch|, the string's array of |jschar|s + * may be freed out from under us. + * + * Note that there is only an issue when 1) we extract a thing X the scanner + * doesn't recognize from 2) a thing Y the scanner does recognize, and 3) if Y + * gets garbage-collected, then X gets freed. If we have code like this: + * + * void g(JSObject *obj) { + * JS::Value x; + * JS_GetProperty(obj, "x", &x); + * ... do stuff with x ... + * } + * + * there's no problem, because the value we've extracted, x, is a Value, a + * type that the conservative scanner recognizes. + * + * Conservative GC frees us from the obligation to explicitly root the types it + * knows about, but when we work with derived values like |ch|, we must root + * their owners, as the derived value alone won't keep them alive. + * + * A JS::Anchor is a kind of GC root that allows us to keep the owners of + * derived values like |ch| alive throughout the Anchor's lifetime. We could + * fix the above code as follows: + * + * void f(JSString *str) { + * JS::Anchor a_str(str); + * const jschar *ch = JS_GetStringCharsZ(str); + * ... do stuff with ch, but no uses of str ...; + * } + * + * This simply ensures that |str| will be live until |a_str| goes out of scope. + * As long as we don't retain a pointer to the string's characters for longer + * than that, we have avoided all garbage collection hazards. + */ +template class AnchorPermitted; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; +template<> class AnchorPermitted { }; + +template +class Anchor : AnchorPermitted +{ + public: + Anchor() { } + explicit Anchor(T t) { hold = t; } + inline ~Anchor(); + T &get() { return hold; } + const T &get() const { return hold; } + void set(const T &t) { hold = t; } + void operator=(const T &t) { hold = t; } + void clear() { hold = 0; } + + private: + T hold; + Anchor(const Anchor &other) MOZ_DELETE; + void operator=(const Anchor &other) MOZ_DELETE; +}; + +template +inline Anchor::~Anchor() +{ +#ifdef __GNUC__ + /* + * No code is generated for this. But because this is marked 'volatile', G++ will + * assume it has important side-effects, and won't delete it. (G++ never looks at + * the actual text and notices it's empty.) And because we have passed |hold| to + * it, GCC will keep |hold| alive until this point. + * + * The "memory" clobber operand ensures that G++ will not move prior memory + * accesses after the asm --- it's a barrier. Unfortunately, it also means that + * G++ will assume that all memory has changed after the asm, as it would for a + * call to an unknown function. I don't know of a way to avoid that consequence. + */ + asm volatile("":: "g" (hold) : "memory"); +#else + /* + * An adequate portable substitute, for non-structure types. + * + * The compiler promises that, by the end of an expression statement, the + * last-stored value to a volatile object is the same as it would be in an + * unoptimized, direct implementation (the "abstract machine" whose behavior the + * language spec describes). However, the compiler is still free to reorder + * non-volatile accesses across this store --- which is what we must prevent. So + * assigning the held value to a volatile variable, as we do here, is not enough. + * + * In our case, however, garbage collection only occurs at function calls, so it + * is sufficient to ensure that the destructor's store isn't moved earlier across + * any function calls that could collect. It is hard to imagine the compiler + * analyzing the program so thoroughly that it could prove that such motion was + * safe. In practice, compilers treat calls to the collector as opaque operations + * --- in particular, as operations which could access volatile variables, across + * which this destructor must not be moved. + * + * ("Objection, your honor! *Alleged* killer whale!") + * + * The disadvantage of this approach is that it does generate code for the store. + * We do need to use Anchors in some cases where cycles are tight. + * + * Note that there is a Anchor::~Anchor() specialization in Value.h. + */ + volatile T sink; + sink = hold; +#endif /* defined(__GNUC__) */ +} + +} // namespace JS + +#endif /* js_Anchor_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/CallArgs.h b/scripting/javascript/spidermonkey-mac/include/js/CallArgs.h new file mode 100644 index 0000000000..b84070bbe8 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/CallArgs.h @@ -0,0 +1,348 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Helper classes encapsulating access to the callee, |this| value, arguments, + * and argument count for a function call. + * + * The intent of JS::CallArgs and JS::CallReceiver is that they be used to + * encapsulate access to the un-abstracted |unsigned argc, Value *vp| arguments + * to a function. It's possible (albeit deprecated) to manually index into + * |vp| to access the callee, |this|, and arguments of a function, and to set + * its return value. It's also possible to use the supported API of JS_CALLEE, + * JS_THIS, JS_ARGV, JS_RVAL and JS_SET_RVAL to the same ends. But neither API + * has the error-handling or moving-GC correctness of CallArgs or CallReceiver. + * New code should use CallArgs and CallReceiver instead whenever possible. + * + * The eventual plan is to change JSNative to take |const CallArgs&| directly, + * for automatic assertion of correct use and to make calling functions more + * efficient. Embedders should start internally switching away from using + * |argc| and |vp| directly, except to create a |CallArgs|. Then, when an + * eventual release making that change occurs, porting efforts will require + * changing methods' signatures but won't require invasive changes to the + * methods' implementations, potentially under time pressure. + */ + +#ifndef js_CallArgs_h___ +#define js_CallArgs_h___ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" + +#include "jstypes.h" + +#include "js/RootingAPI.h" +#include "js/Value.h" + +struct JSContext; +class JSObject; + +/* Typedef for native functions called by the JS VM. */ +typedef JSBool +(* JSNative)(JSContext *cx, unsigned argc, JS::Value *vp); + +namespace JS { + +/* + * JS::CallReceiver encapsulates access to the callee, |this|, and eventual + * return value for a function call. The principal way to create a + * CallReceiver is using JS::CallReceiverFromVp: + * + * static JSBool + * FunctionReturningThis(JSContext *cx, unsigned argc, JS::Value *vp) + * { + * JS::CallReceiver rec = JS::CallReceiverFromVp(vp); + * + * // Access to the callee must occur before accessing/setting + * // the return value. + * JSObject &callee = rec.callee(); + * rec.rval().set(JS::ObjectValue(callee)); + * + * // callee() and calleev() will now assert. + * + * // It's always fine to access thisv(). + * HandleValue thisv = rec.thisv(); + * rec.thisv().set(thisv); + * + * // As the return value was last set to |this|, returns |this|. + * return true; + * } + * + * A note on JS_ComputeThis and JS_THIS_OBJECT: these methods currently aren't + * part of the CallReceiver interface. We will likely add them at some point. + * Until then, you should probably continue using |vp| directly for these two + * cases. + * + * CallReceiver is exposed publicly and used internally. Not all parts of its + * public interface are meant to be used by embedders! See inline comments to + * for details. + */ +class CallReceiver +{ + protected: +#ifdef DEBUG + mutable bool usedRval_; + void setUsedRval() const { usedRval_ = true; } + void clearUsedRval() const { usedRval_ = false; } +#else + void setUsedRval() const {} + void clearUsedRval() const {} +#endif + + Value *argv_; + + friend CallReceiver CallReceiverFromVp(Value *vp); + friend CallReceiver CallReceiverFromArgv(Value *argv); + + public: + /* + * Returns the function being called, as an object. Must not be called + * after rval() has been used! + */ + JSObject &callee() const { + MOZ_ASSERT(!usedRval_); + return argv_[-2].toObject(); + } + + /* + * Returns the function being called, as a value. Must not be called after + * rval() has been used! + */ + HandleValue calleev() const { + MOZ_ASSERT(!usedRval_); + return HandleValue::fromMarkedLocation(&argv_[-2]); + } + + /* + * Returns the |this| value passed to the function. This method must not + * be called when the function is being called as a constructor via |new|. + * The value may or may not be an object: it is the individual function's + * responsibility to box the value if needed. + */ + HandleValue thisv() const { + // Some internal code uses thisv() in constructing cases, so don't do + // this yet. + // MOZ_ASSERT(!argv_[-1].isMagic(JS_IS_CONSTRUCTING)); + return HandleValue::fromMarkedLocation(&argv_[-1]); + } + + /* + * Returns the currently-set return value. The initial contents of this + * value are unspecified. Once this method has been called, callee() and + * calleev() can no longer be used. (If you're compiling against a debug + * build of SpiderMonkey, these methods will assert to aid debugging.) + * + * If the method you're implementing succeeds by returning true, you *must* + * set this. (SpiderMonkey doesn't currently assert this, but it will do + * so eventually.) You don't need to use or change this if your method + * fails. + */ + MutableHandleValue rval() const { + setUsedRval(); + return MutableHandleValue::fromMarkedLocation(&argv_[-2]); + } + + public: + // These methods are only intended for internal use. Embedders shouldn't + // use them! + + Value *base() const { return argv_ - 2; } + + Value *spAfterCall() const { + setUsedRval(); + return argv_ - 1; + } + + public: + // These methods are publicly exposed, but they are *not* to be used when + // implementing a JSNative method and encapsulating access to |vp| within + // it. You probably don't want to use these! + + void setCallee(Value aCalleev) const { + clearUsedRval(); + argv_[-2] = aCalleev; + } + + void setThis(Value aThisv) const { + argv_[-1] = aThisv; + } + + MutableHandleValue mutableThisv() const { + return MutableHandleValue::fromMarkedLocation(&argv_[-1]); + } +}; + +MOZ_ALWAYS_INLINE CallReceiver +CallReceiverFromArgv(Value *argv) +{ + CallReceiver receiver; + receiver.clearUsedRval(); + receiver.argv_ = argv; + return receiver; +} + +MOZ_ALWAYS_INLINE CallReceiver +CallReceiverFromVp(Value *vp) +{ + return CallReceiverFromArgv(vp + 2); +} + +/* + * JS::CallArgs encapsulates everything JS::CallReceiver does, plus access to + * the function call's arguments. The principal way to create a CallArgs is + * like so, using JS::CallArgsFromVp: + * + * static JSBool + * FunctionReturningArgcTimesArg0(JSContext *cx, unsigned argc, JS::Value *vp) + * { + * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + * + * // Guard against no arguments or a non-numeric arg0. + * if (args.length() == 0 || !args[0].isNumber()) { + * args.rval().setInt32(0); + * return true; + * } + * + * args.rval().set(JS::NumberValue(args.length() * args[0].toNumber())); + * return true; + * } + * + * CallArgs is exposed publicly and used internally. Not all parts of its + * public interface are meant to be used by embedders! See inline comments to + * for details. + */ +class CallArgs : public CallReceiver +{ + protected: + unsigned argc_; + + friend CallArgs CallArgsFromVp(unsigned argc, Value *vp); + friend CallArgs CallArgsFromSp(unsigned argc, Value *sp); + + static CallArgs create(unsigned argc, Value *argv) { + CallArgs args; + args.clearUsedRval(); + args.argv_ = argv; + args.argc_ = argc; + return args; + } + + public: + /* Returns the number of arguments. */ + unsigned length() const { return argc_; } + + /* Returns the i-th zero-indexed argument. */ + Value &operator[](unsigned i) const { + MOZ_ASSERT(i < argc_); + return argv_[i]; + } + + /* Returns a mutable handle for the i-th zero-indexed argument. */ + MutableHandleValue handleAt(unsigned i) { + MOZ_ASSERT(i < argc_); + return MutableHandleValue::fromMarkedLocation(&argv_[i]); + } + + /* Returns a Handle for the i-th zero-indexed argument. */ + HandleValue handleAt(unsigned i) const { + MOZ_ASSERT(i < argc_); + return HandleValue::fromMarkedLocation(&argv_[i]); + } + + /* + * Returns the i-th zero-indexed argument, or |undefined| if there's no + * such argument. + */ + Value get(unsigned i) const { + return i < length() ? argv_[i] : UndefinedValue(); + } + + /* + * Returns true if the i-th zero-indexed argument is present and is not + * |undefined|. + */ + bool hasDefined(unsigned i) const { + return i < argc_ && !argv_[i].isUndefined(); + } + + public: + // These methods are publicly exposed, but we're less sure of the interface + // here than we'd like (because they're hackish and drop assertions). Try + // to avoid using these if you can. + + Value *array() const { return argv_; } + Value *end() const { return argv_ + argc_; } +}; + +MOZ_ALWAYS_INLINE CallArgs +CallArgsFromVp(unsigned argc, Value *vp) +{ + return CallArgs::create(argc, vp + 2); +} + +// This method is only intended for internal use in SpiderMonkey. We may +// eventually move it to an internal header. Embedders should use +// JS::CallArgsFromVp! +MOZ_ALWAYS_INLINE CallArgs +CallArgsFromSp(unsigned argc, Value *sp) +{ + return CallArgs::create(argc, sp - argc); +} + +} // namespace JS + +/* + * Compute |this| for the |vp| inside a JSNative, either boxing primitives or + * replacing with the global object as necessary. + * + * This method will go away at some point: instead use |args.thisv()|. If the + * value is an object, no further work is required. If that value is |null| or + * |undefined|, use |JS_GetGlobalForObject| to compute the global object. If + * the value is some other primitive, use |JS_ValueToObject| to box it. + */ +extern JS_PUBLIC_API(JS::Value) +JS_ComputeThis(JSContext *cx, JS::Value *vp); + +/* + * Macros to hide interpreter stack layout details from a JSNative using its + * JS::Value *vp parameter. DO NOT USE THESE! Instead use JS::CallArgs and + * friends, above. These macros will be removed when we change JSNative to + * take a const JS::CallArgs&. + */ + +#define JS_CALLEE(cx,vp) ((vp)[0]) +#define JS_THIS_OBJECT(cx,vp) (JSVAL_TO_OBJECT(JS_THIS(cx,vp))) +#define JS_ARGV(cx,vp) ((vp) + 2) +#define JS_RVAL(cx,vp) (*(vp)) +#define JS_SET_RVAL(cx,vp,v) (*(vp) = (v)) + +/* + * Note: if this method returns null, an error has occurred and must be + * propagated or caught. + */ +MOZ_ALWAYS_INLINE JS::Value +JS_THIS(JSContext *cx, JS::Value *vp) +{ + return JSVAL_IS_PRIMITIVE(vp[1]) ? JS_ComputeThis(cx, vp) : vp[1]; +} + +/* + * |this| is passed to functions in ES5 without change. Functions themselves + * do any post-processing they desire to box |this|, compute the global object, + * &c. This macro retrieves a function's unboxed |this| value. + * + * This macro must not be used in conjunction with JS_THIS or JS_THIS_OBJECT, + * or vice versa. Either use the provided this value with this macro, or + * compute the boxed |this| value using those. JS_THIS_VALUE must not be used + * if the function is being called as a constructor. + * + * But: DO NOT USE THIS! Instead use JS::CallArgs::thisv(), above. + * + */ +#define JS_THIS_VALUE(cx,vp) ((vp)[1]) + +#endif /* js_CallArgs_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/CharacterEncoding.h b/scripting/javascript/spidermonkey-mac/include/js/CharacterEncoding.h new file mode 100644 index 0000000000..36d8670a08 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/CharacterEncoding.h @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=78: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_CharacterEncoding_h___ +#define js_CharacterEncoding_h___ + +#include "mozilla/Range.h" + +#include "js/Utility.h" + +#include "jspubtd.h" + +namespace JS { + +/* + * By default, all C/C++ 1-byte-per-character strings passed into the JSAPI + * are treated as ISO/IEC 8859-1, also known as Latin-1. That is, each + * byte is treated as a 2-byte character, and there is no way to pass in a + * string containing characters beyond U+00FF. + */ +class Latin1Chars : public mozilla::Range +{ + typedef mozilla::Range Base; + + public: + Latin1Chars() : Base() {} + Latin1Chars(char *aBytes, size_t aLength) : Base(reinterpret_cast(aBytes), aLength) {} + Latin1Chars(const char *aBytes, size_t aLength) + : Base(reinterpret_cast(const_cast(aBytes)), aLength) + {} +}; + +/* + * A Latin1Chars, but with \0 termination for C compatibility. + */ +class Latin1CharsZ : public mozilla::RangedPtr +{ + typedef mozilla::RangedPtr Base; + + public: + Latin1CharsZ() : Base(NULL, 0) {} + + Latin1CharsZ(char *aBytes, size_t aLength) + : Base(reinterpret_cast(aBytes), aLength) + { + JS_ASSERT(aBytes[aLength] == '\0'); + } + + Latin1CharsZ(unsigned char *aBytes, size_t aLength) + : Base(aBytes, aLength) + { + JS_ASSERT(aBytes[aLength] == '\0'); + } + + char *c_str() { return reinterpret_cast(get()); } +}; + +/* + * SpiderMonkey also deals directly with UTF-8 encoded text in some places. + */ +class UTF8CharsZ : public mozilla::RangedPtr +{ + typedef mozilla::RangedPtr Base; + + public: + UTF8CharsZ() : Base(NULL, 0) {} + + UTF8CharsZ(char *aBytes, size_t aLength) + : Base(reinterpret_cast(aBytes), aLength) + { + JS_ASSERT(aBytes[aLength] == '\0'); + } + + UTF8CharsZ(unsigned char *aBytes, size_t aLength) + : Base(aBytes, aLength) + { + JS_ASSERT(aBytes[aLength] == '\0'); + } + + char *c_str() { return reinterpret_cast(get()); } +}; + +/* + * SpiderMonkey uses a 2-byte character representation: it is a + * 2-byte-at-a-time view of a UTF-16 byte stream. This is similar to UCS-2, + * but unlike UCS-2, we do not strip UTF-16 extension bytes. This allows a + * sufficiently dedicated JavaScript program to be fully unicode-aware by + * manually interpreting UTF-16 extension characters embedded in the JS + * string. + */ +class TwoByteChars : public mozilla::Range +{ + typedef mozilla::Range Base; + + public: + TwoByteChars() : Base() {} + TwoByteChars(jschar *aChars, size_t aLength) : Base(aChars, aLength) {} + TwoByteChars(const jschar *aChars, size_t aLength) : Base(const_cast(aChars), aLength) {} +}; + +/* + * A non-convertible variant of TwoByteChars that does not refer to characters + * inlined inside a JSShortString or a JSInlineString. StableTwoByteChars are + * thus safe to hold across a GC. + */ +class StableTwoByteChars : public mozilla::Range +{ + typedef mozilla::Range Base; + + public: + StableTwoByteChars() : Base() {} + StableTwoByteChars(jschar *aChars, size_t aLength) : Base(aChars, aLength) {} + StableTwoByteChars(const jschar *aChars, size_t aLength) : Base(const_cast(aChars), aLength) {} +}; + +/* + * A TwoByteChars, but \0 terminated for compatibility with JSFlatString. + */ +class TwoByteCharsZ : public mozilla::RangedPtr +{ + typedef mozilla::RangedPtr Base; + + public: + TwoByteCharsZ(jschar *chars, size_t length) + : Base(chars, length) + { + JS_ASSERT(chars[length] = '\0'); + } +}; + +/* + * Convert a 2-byte character sequence to "ISO-Latin-1". This works by + * truncating each 2-byte pair in the sequence to a 1-byte pair. If the source + * contains any UTF-16 extension characters, then this may give invalid Latin1 + * output. The returned string is zero terminated. The returned string or the + * returned string's |start()| must be freed with JS_free or js_free, + * respectively. If allocation fails, an OOM error will be set and the method + * will return a NULL chars (which can be tested for with the ! operator). + * This method cannot trigger GC. + */ +extern Latin1CharsZ +LossyTwoByteCharsToNewLatin1CharsZ(JSContext *cx, TwoByteChars tbchars); + +extern UTF8CharsZ +TwoByteCharsToNewUTF8CharsZ(JSContext *cx, TwoByteChars tbchars); + +} // namespace JS + +inline void JS_free(JS::Latin1CharsZ &ptr) { js_free((void*)ptr.get()); } +inline void JS_free(JS::UTF8CharsZ &ptr) { js_free((void*)ptr.get()); } + +#endif // js_CharacterEncoding_h___ diff --git a/scripting/javascript/spidermonkey-mac/include/js/GCAPI.h b/scripting/javascript/spidermonkey-mac/include/js/GCAPI.h new file mode 100644 index 0000000000..6f4649eb30 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/GCAPI.h @@ -0,0 +1,255 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_gc_api_h___ +#define js_gc_api_h___ + +#include "HeapAPI.h" + +namespace JS { + +#define GCREASONS(D) \ + /* Reasons internal to the JS engine */ \ + D(API) \ + D(MAYBEGC) \ + D(LAST_CONTEXT) \ + D(DESTROY_CONTEXT) \ + D(LAST_DITCH) \ + D(TOO_MUCH_MALLOC) \ + D(ALLOC_TRIGGER) \ + D(DEBUG_GC) \ + D(DEBUG_MODE_GC) \ + D(TRANSPLANT) \ + D(RESET) \ + \ + /* Reasons from Firefox */ \ + D(DOM_WINDOW_UTILS) \ + D(COMPONENT_UTILS) \ + D(MEM_PRESSURE) \ + D(CC_WAITING) \ + D(CC_FORCED) \ + D(LOAD_END) \ + D(POST_COMPARTMENT) \ + D(PAGE_HIDE) \ + D(NSJSCONTEXT_DESTROY) \ + D(SET_NEW_DOCUMENT) \ + D(SET_DOC_SHELL) \ + D(DOM_UTILS) \ + D(DOM_IPC) \ + D(DOM_WORKER) \ + D(INTER_SLICE_GC) \ + D(REFRESH_FRAME) \ + D(FULL_GC_TIMER) \ + D(SHUTDOWN_CC) \ + D(FINISH_LARGE_EVALUTE) + +namespace gcreason { + +/* GCReasons will end up looking like JSGC_MAYBEGC */ +enum Reason { +#define MAKE_REASON(name) name, + GCREASONS(MAKE_REASON) +#undef MAKE_REASON + NO_REASON, + NUM_REASONS, + + /* + * For telemetry, we want to keep a fixed max bucket size over time so we + * don't have to switch histograms. 100 is conservative; as of this writing + * there are 26. But the cost of extra buckets seems to be low while the + * cost of switching histograms is high. + */ + NUM_TELEMETRY_REASONS = 100 +}; + +} /* namespace gcreason */ + +extern JS_FRIEND_API(void) +PrepareZoneForGC(Zone *zone); + +extern JS_FRIEND_API(void) +PrepareForFullGC(JSRuntime *rt); + +extern JS_FRIEND_API(void) +PrepareForIncrementalGC(JSRuntime *rt); + +extern JS_FRIEND_API(bool) +IsGCScheduled(JSRuntime *rt); + +extern JS_FRIEND_API(void) +SkipZoneForGC(Zone *zone); + +/* + * When triggering a GC using one of the functions below, it is first necessary + * to select the compartments to be collected. To do this, you can call + * PrepareZoneForGC on each compartment, or you can call PrepareForFullGC + * to select all compartments. Failing to select any compartment is an error. + */ + +extern JS_FRIEND_API(void) +GCForReason(JSRuntime *rt, gcreason::Reason reason); + +extern JS_FRIEND_API(void) +ShrinkingGC(JSRuntime *rt, gcreason::Reason reason); + +extern JS_FRIEND_API(void) +ShrinkGCBuffers(JSRuntime *rt); + +extern JS_FRIEND_API(void) +IncrementalGC(JSRuntime *rt, gcreason::Reason reason, int64_t millis = 0); + +extern JS_FRIEND_API(void) +FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason); + +enum GCProgress { + /* + * During non-incremental GC, the GC is bracketed by JSGC_CYCLE_BEGIN/END + * callbacks. During an incremental GC, the sequence of callbacks is as + * follows: + * JSGC_CYCLE_BEGIN, JSGC_SLICE_END (first slice) + * JSGC_SLICE_BEGIN, JSGC_SLICE_END (second slice) + * ... + * JSGC_SLICE_BEGIN, JSGC_CYCLE_END (last slice) + */ + + GC_CYCLE_BEGIN, + GC_SLICE_BEGIN, + GC_SLICE_END, + GC_CYCLE_END +}; + +struct JS_FRIEND_API(GCDescription) { + bool isCompartment_; + + GCDescription(bool isCompartment) + : isCompartment_(isCompartment) {} + + jschar *formatMessage(JSRuntime *rt) const; + jschar *formatJSON(JSRuntime *rt, uint64_t timestamp) const; +}; + +typedef void +(* GCSliceCallback)(JSRuntime *rt, GCProgress progress, const GCDescription &desc); + +extern JS_FRIEND_API(GCSliceCallback) +SetGCSliceCallback(JSRuntime *rt, GCSliceCallback callback); + +/* + * Signals a good place to do an incremental slice, because the browser is + * drawing a frame. + */ +extern JS_FRIEND_API(void) +NotifyDidPaint(JSRuntime *rt); + +extern JS_FRIEND_API(bool) +IsIncrementalGCEnabled(JSRuntime *rt); + +JS_FRIEND_API(bool) +IsIncrementalGCInProgress(JSRuntime *rt); + +extern JS_FRIEND_API(void) +DisableIncrementalGC(JSRuntime *rt); + +extern JS_FRIEND_API(void) +DisableGenerationalGC(JSRuntime *rt); + +extern JS_FRIEND_API(bool) +IsIncrementalBarrierNeeded(JSRuntime *rt); + +extern JS_FRIEND_API(bool) +IsIncrementalBarrierNeeded(JSContext *cx); + +extern JS_FRIEND_API(void) +IncrementalReferenceBarrier(void *ptr, JSGCTraceKind kind); + +extern JS_FRIEND_API(void) +IncrementalValueBarrier(const Value &v); + +extern JS_FRIEND_API(void) +IncrementalObjectBarrier(JSObject *obj); + +extern JS_FRIEND_API(void) +PokeGC(JSRuntime *rt); + +/* Was the most recent GC run incrementally? */ +extern JS_FRIEND_API(bool) +WasIncrementalGC(JSRuntime *rt); + +class ObjectPtr +{ + JSObject *value; + + public: + ObjectPtr() : value(NULL) {} + + ObjectPtr(JSObject *obj) : value(obj) {} + + /* Always call finalize before the destructor. */ + ~ObjectPtr() { JS_ASSERT(!value); } + + void finalize(JSRuntime *rt) { + if (IsIncrementalBarrierNeeded(rt)) + IncrementalObjectBarrier(value); + value = NULL; + } + + void init(JSObject *obj) { value = obj; } + + JSObject *get() const { return value; } + + void writeBarrierPre(JSRuntime *rt) { + IncrementalObjectBarrier(value); + } + + bool isAboutToBeFinalized() { + return JS_IsAboutToBeFinalized(&value); + } + + ObjectPtr &operator=(JSObject *obj) { + IncrementalObjectBarrier(value); + value = obj; + return *this; + } + + JSObject &operator*() const { return *value; } + JSObject *operator->() const { return value; } + operator JSObject *() const { return value; } +}; + +/* + * Unsets the gray bit for anything reachable from |thing|. |kind| should not be + * JSTRACE_SHAPE. |thing| should be non-null. + */ +extern JS_FRIEND_API(void) +UnmarkGrayGCThingRecursively(void *thing, JSGCTraceKind kind); + +/* + * This should be called when an object that is marked gray is exposed to the JS + * engine (by handing it to running JS code or writing it into live JS + * data). During incremental GC, since the gray bits haven't been computed yet, + * we conservatively mark the object black. + */ +static JS_ALWAYS_INLINE void +ExposeGCThingToActiveJS(void *thing, JSGCTraceKind kind) +{ + JS_ASSERT(kind != JSTRACE_SHAPE); + + if (GCThingIsMarkedGray(thing)) + UnmarkGrayGCThingRecursively(thing, kind); + else if (IsIncrementalBarrierNeededOnGCThing(thing, kind)) + IncrementalReferenceBarrier(thing, kind); +} + +static JS_ALWAYS_INLINE void +ExposeValueToActiveJS(const Value &v) +{ + if (v.isMarkable()) + ExposeGCThingToActiveJS(v.toGCThing(), v.gcKind()); +} + +} /* namespace JS */ + +#endif /* js_gc_api_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/HashTable.h b/scripting/javascript/spidermonkey-mac/include/js/HashTable.h new file mode 100644 index 0000000000..7a29437ed8 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/HashTable.h @@ -0,0 +1,1480 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_HashTable_h__ +#define js_HashTable_h__ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/DebugOnly.h" +#include "mozilla/TypeTraits.h" +#include "mozilla/Util.h" + +#include "js/TemplateLib.h" +#include "js/Utility.h" + +namespace js { + +class TempAllocPolicy; +template struct DefaultHasher; +template class HashMapEntry; +namespace detail { + template class HashTableEntry; + template class HashTable; +} + +/*****************************************************************************/ + +// A JS-friendly, STL-like container providing a hash-based map from keys to +// values. In particular, HashMap calls constructors and destructors of all +// objects added so non-PODs may be used safely. +// +// Key/Value requirements: +// - movable, destructible, assignable +// HashPolicy requirements: +// - see Hash Policy section below +// AllocPolicy: +// - see jsalloc.h +// +// Note: +// - HashMap is not reentrant: Key/Value/HashPolicy/AllocPolicy members +// called by HashMap must not call back into the same HashMap object. +// - Due to the lack of exception handling, the user must call |init()|. +template , + class AllocPolicy = TempAllocPolicy> +class HashMap +{ + typedef HashMapEntry TableEntry; + + struct MapHashPolicy : HashPolicy + { + typedef Key KeyType; + static const Key &getKey(TableEntry &e) { return e.key; } + static void setKey(TableEntry &e, Key &k) { const_cast(e.key) = k; } + }; + + typedef detail::HashTable Impl; + Impl impl; + + public: + typedef typename HashPolicy::Lookup Lookup; + typedef TableEntry Entry; + + // HashMap construction is fallible (due to OOM); thus the user must call + // init after constructing a HashMap and check the return value. + HashMap(AllocPolicy a = AllocPolicy()) + : impl(a) + { + MOZ_STATIC_ASSERT(tl::IsRelocatableHeapType::result, + "Key type must be relocatable"); + MOZ_STATIC_ASSERT(tl::IsRelocatableHeapType::result, + "Value type must be relocatable"); + } + + bool init(uint32_t len = 16) { return impl.init(len); } + bool initialized() const { return impl.initialized(); } + + // Return whether the given lookup value is present in the map. E.g.: + // + // typedef HashMap HM; + // HM h; + // if (HM::Ptr p = h.lookup(3)) { + // const HM::Entry &e = *p; // p acts like a pointer to Entry + // assert(p->key == 3); // Entry contains the key + // char val = p->value; // and value + // } + // + // Also see the definition of Ptr in HashTable above (with T = Entry). + typedef typename Impl::Ptr Ptr; + Ptr lookup(const Lookup &l) const { return impl.lookup(l); } + + // Like lookup, but does not assert if two threads call lookup at the same + // time. Only use this method when none of the threads will modify the map. + Ptr readonlyThreadsafeLookup(const Lookup &l) const { return impl.readonlyThreadsafeLookup(l); } + + // Assuming |p.found()|, remove |*p|. + void remove(Ptr p) { impl.remove(p); } + + // Like |lookup(l)|, but on miss, |p = lookupForAdd(l)| allows efficient + // insertion of Key |k| (where |HashPolicy::match(k,l) == true|) using + // |add(p,k,v)|. After |add(p,k,v)|, |p| points to the new Entry. E.g.: + // + // typedef HashMap HM; + // HM h; + // HM::AddPtr p = h.lookupForAdd(3); + // if (!p) { + // if (!h.add(p, 3, 'a')) + // return false; + // } + // const HM::Entry &e = *p; // p acts like a pointer to Entry + // assert(p->key == 3); // Entry contains the key + // char val = p->value; // and value + // + // Also see the definition of AddPtr in HashTable above (with T = Entry). + // + // N.B. The caller must ensure that no mutating hash table operations + // occur between a pair of |lookupForAdd| and |add| calls. To avoid + // looking up the key a second time, the caller may use the more efficient + // relookupOrAdd method. This method reuses part of the hashing computation + // to more efficiently insert the key if it has not been added. For + // example, a mutation-handling version of the previous example: + // + // HM::AddPtr p = h.lookupForAdd(3); + // if (!p) { + // call_that_may_mutate_h(); + // if (!h.relookupOrAdd(p, 3, 'a')) + // return false; + // } + // const HM::Entry &e = *p; + // assert(p->key == 3); + // char val = p->value; + typedef typename Impl::AddPtr AddPtr; + AddPtr lookupForAdd(const Lookup &l) const { + return impl.lookupForAdd(l); + } + + template + bool add(AddPtr &p, const KeyInput &k, const ValueInput &v) { + Entry e(k, v); + return impl.add(p, Move(e)); + } + + bool add(AddPtr &p, const Key &k) { + Entry e(k, Value()); + return impl.add(p, Move(e)); + } + + template + bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { + Entry e(k, v); + return impl.relookupOrAdd(p, k, Move(e)); + } + + // |all()| returns a Range containing |count()| elements. E.g.: + // + // typedef HashMap HM; + // HM h; + // for (HM::Range r = h.all(); !r.empty(); r.popFront()) + // char c = r.front().value; + // + // Also see the definition of Range in HashTable above (with T = Entry). + typedef typename Impl::Range Range; + Range all() const { return impl.all(); } + + // Typedef for the enumeration class. An Enum may be used to examine and + // remove table entries: + // + // typedef HashMap HM; + // HM s; + // for (HM::Enum e(s); !e.empty(); e.popFront()) + // if (e.front().value == 'l') + // e.removeFront(); + // + // Table resize may occur in Enum's destructor. Also see the definition of + // Enum in HashTable above (with T = Entry). + typedef typename Impl::Enum Enum; + + // Remove all entries. This does not shrink the table. For that consider + // using the finish() method. + void clear() { impl.clear(); } + + // Remove all entries without triggering destructors. This method is unsafe. + void clearWithoutCallingDestructors() { impl.clearWithoutCallingDestructors(); } + + // Remove all the entries and release all internal buffers. The map must + // be initialized again before any use. + void finish() { impl.finish(); } + + // Does the table contain any entries? + bool empty() const { return impl.empty(); } + + // Number of live elements in the map. + uint32_t count() const { return impl.count(); } + + // Total number of allocation in the dynamic table. Note: resize will + // happen well before count() == capacity(). + size_t capacity() const { return impl.capacity(); } + + // Don't just call |impl.sizeOfExcludingThis()| because there's no + // guarantee that |impl| is the first field in HashMap. + size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + return impl.sizeOfExcludingThis(mallocSizeOf); + } + size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); + } + + // If |generation()| is the same before and after a HashMap operation, + // pointers into the table remain valid. + unsigned generation() const { return impl.generation(); } + + /************************************************** Shorthand operations */ + + bool has(const Lookup &l) const { + return impl.lookup(l) != NULL; + } + + // Overwrite existing value with v. Return false on oom. + template + bool put(const KeyInput &k, const ValueInput &v) { + AddPtr p = lookupForAdd(k); + if (p) { + p->value = v; + return true; + } + return add(p, k, v); + } + + // Like put, but assert that the given key is not already present. + template + bool putNew(const KeyInput &k, const ValueInput &v) { + Entry e(k, v); + return impl.putNew(k, Move(e)); + } + + // Add (k,defaultValue) if |k| is not found. Return a false-y Ptr on oom. + Ptr lookupWithDefault(const Key &k, const Value &defaultValue) { + AddPtr p = lookupForAdd(k); + if (p) + return p; + (void)add(p, k, defaultValue); // p is left false-y on oom. + return p; + } + + // Remove if present. + void remove(const Lookup &l) { + if (Ptr p = lookup(l)) + remove(p); + } + + // HashMap is movable + HashMap(MoveRef rhs) : impl(Move(rhs->impl)) {} + void operator=(MoveRef rhs) { impl = Move(rhs->impl); } + + private: + // HashMap is not copyable or assignable + HashMap(const HashMap &hm) MOZ_DELETE; + HashMap &operator=(const HashMap &hm) MOZ_DELETE; + + friend class Impl::Enum; +}; + +/*****************************************************************************/ + +// A JS-friendly, STL-like container providing a hash-based set of values. In +// particular, HashSet calls constructors and destructors of all objects added +// so non-PODs may be used safely. +// +// T requirements: +// - movable, destructible, assignable +// HashPolicy requirements: +// - see Hash Policy section below +// AllocPolicy: +// - see jsalloc.h +// +// Note: +// - HashSet is not reentrant: T/HashPolicy/AllocPolicy members called by +// HashSet must not call back into the same HashSet object. +// - Due to the lack of exception handling, the user must call |init()|. +template , + class AllocPolicy = TempAllocPolicy> +class HashSet +{ + struct SetOps : HashPolicy + { + typedef T KeyType; + static const KeyType &getKey(const T &t) { return t; } + static void setKey(T &t, KeyType &k) { t = k; } + }; + + typedef detail::HashTable Impl; + Impl impl; + + public: + typedef typename HashPolicy::Lookup Lookup; + typedef T Entry; + + // HashSet construction is fallible (due to OOM); thus the user must call + // init after constructing a HashSet and check the return value. + HashSet(AllocPolicy a = AllocPolicy()) : impl(a) + { + MOZ_STATIC_ASSERT(tl::IsRelocatableHeapType::result, + "Set element type must be relocatable"); + } + bool init(uint32_t len = 16) { return impl.init(len); } + bool initialized() const { return impl.initialized(); } + + // Return whether the given lookup value is present in the map. E.g.: + // + // typedef HashSet HS; + // HS h; + // if (HS::Ptr p = h.lookup(3)) { + // assert(*p == 3); // p acts like a pointer to int + // } + // + // Also see the definition of Ptr in HashTable above. + typedef typename Impl::Ptr Ptr; + Ptr lookup(const Lookup &l) const { return impl.lookup(l); } + + // Assuming |p.found()|, remove |*p|. + void remove(Ptr p) { impl.remove(p); } + + // Like |lookup(l)|, but on miss, |p = lookupForAdd(l)| allows efficient + // insertion of T value |t| (where |HashPolicy::match(t,l) == true|) using + // |add(p,t)|. After |add(p,t)|, |p| points to the new element. E.g.: + // + // typedef HashSet HS; + // HS h; + // HS::AddPtr p = h.lookupForAdd(3); + // if (!p) { + // if (!h.add(p, 3)) + // return false; + // } + // assert(*p == 3); // p acts like a pointer to int + // + // Also see the definition of AddPtr in HashTable above. + // + // N.B. The caller must ensure that no mutating hash table operations + // occur between a pair of |lookupForAdd| and |add| calls. To avoid + // looking up the key a second time, the caller may use the more efficient + // relookupOrAdd method. This method reuses part of the hashing computation + // to more efficiently insert the key if it has not been added. For + // example, a mutation-handling version of the previous example: + // + // HS::AddPtr p = h.lookupForAdd(3); + // if (!p) { + // call_that_may_mutate_h(); + // if (!h.relookupOrAdd(p, 3, 3)) + // return false; + // } + // assert(*p == 3); + // + // Note that relookupOrAdd(p,l,t) performs Lookup using |l| and adds the + // entry |t|, where the caller ensures match(l,t). + typedef typename Impl::AddPtr AddPtr; + AddPtr lookupForAdd(const Lookup &l) const { return impl.lookupForAdd(l); } + + bool add(AddPtr &p, const T &t) { return impl.add(p, t); } + + bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) { + return impl.relookupOrAdd(p, l, t); + } + + // |all()| returns a Range containing |count()| elements: + // + // typedef HashSet HS; + // HS h; + // for (HS::Range r = h.all(); !r.empty(); r.popFront()) + // int i = r.front(); + // + // Also see the definition of Range in HashTable above. + typedef typename Impl::Range Range; + Range all() const { return impl.all(); } + + // Typedef for the enumeration class. An Enum may be used to examine and + // remove table entries: + // + // typedef HashSet HS; + // HS s; + // for (HS::Enum e(s); !e.empty(); e.popFront()) + // if (e.front() == 42) + // e.removeFront(); + // + // Table resize may occur in Enum's destructor. Also see the definition of + // Enum in HashTable above. + typedef typename Impl::Enum Enum; + + // Remove all entries. This does not shrink the table. For that consider + // using the finish() method. + void clear() { impl.clear(); } + + // Remove all the entries and release all internal buffers. The set must + // be initialized again before any use. + void finish() { impl.finish(); } + + // Does the table contain any entries? + bool empty() const { return impl.empty(); } + + // Number of live elements in the map. + uint32_t count() const { return impl.count(); } + + // Total number of allocation in the dynamic table. Note: resize will + // happen well before count() == capacity(). + size_t capacity() const { return impl.capacity(); } + + // Don't just call |impl.sizeOfExcludingThis()| because there's no + // guarantee that |impl| is the first field in HashSet. + size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + return impl.sizeOfExcludingThis(mallocSizeOf); + } + size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); + } + + // If |generation()| is the same before and after a HashSet operation, + // pointers into the table remain valid. + unsigned generation() const { return impl.generation(); } + + /************************************************** Shorthand operations */ + + bool has(const Lookup &l) const { + return impl.lookup(l) != NULL; + } + + // Overwrite existing value with v. Return false on oom. + bool put(const T &t) { + AddPtr p = lookupForAdd(t); + return p ? true : add(p, t); + } + + // Like put, but assert that the given key is not already present. + bool putNew(const T &t) { + return impl.putNew(t, t); + } + + bool putNew(const Lookup &l, const T &t) { + return impl.putNew(l, t); + } + + void remove(const Lookup &l) { + if (Ptr p = lookup(l)) + remove(p); + } + + // HashSet is movable + HashSet(MoveRef rhs) : impl(Move(rhs->impl)) {} + void operator=(MoveRef rhs) { impl = Move(rhs->impl); } + + private: + // HashSet is not copyable or assignable + HashSet(const HashSet &hs) MOZ_DELETE; + HashSet &operator=(const HashSet &hs) MOZ_DELETE; + + friend class Impl::Enum; +}; + +/*****************************************************************************/ + +// Hash Policy +// +// A hash policy P for a hash table with key-type Key must provide: +// - a type |P::Lookup| to use to lookup table entries; +// - a static member function |P::hash| with signature +// +// static js::HashNumber hash(Lookup) +// +// to use to hash the lookup type; and +// - a static member function |P::match| with signature +// +// static bool match(Key, Lookup) +// +// to use to test equality of key and lookup values. +// +// Normally, Lookup = Key. In general, though, different values and types of +// values can be used to lookup and store. If a Lookup value |l| is != to the +// added Key value |k|, the user must ensure that |P::match(k,l)|. E.g.: +// +// js::HashSet::AddPtr p = h.lookup(l); +// if (!p) { +// assert(P::match(k, l)); // must hold +// h.add(p, k); +// } + +// Pointer hashing policy that strips the lowest zeroBits when calculating the +// hash to improve key distribution. +template +struct PointerHasher +{ + typedef Key Lookup; + static HashNumber hash(const Lookup &l) { + JS_ASSERT(!JS::IsPoisonedPtr(l)); + size_t word = reinterpret_cast(l) >> zeroBits; + JS_STATIC_ASSERT(sizeof(HashNumber) == 4); +#if JS_BYTES_PER_WORD == 4 + return HashNumber(word); +#else + JS_STATIC_ASSERT(sizeof word == 8); + return HashNumber((word >> 32) ^ word); +#endif + } + static bool match(const Key &k, const Lookup &l) { + JS_ASSERT(!JS::IsPoisonedPtr(k)); + JS_ASSERT(!JS::IsPoisonedPtr(l)); + return k == l; + } +}; + +// Default hash policy: just use the 'lookup' value. This of course only +// works if the lookup value is integral. HashTable applies ScrambleHashCode to +// the result of the 'hash' which means that it is 'ok' if the lookup value is +// not well distributed over the HashNumber domain. +template +struct DefaultHasher +{ + typedef Key Lookup; + static HashNumber hash(const Lookup &l) { + // Hash if can implicitly cast to hash number type. + return l; + } + static bool match(const Key &k, const Lookup &l) { + // Use builtin or overloaded operator==. + return k == l; + } +}; + +// Specialize hashing policy for pointer types. It assumes that the type is +// at least word-aligned. For types with smaller size use PointerHasher. +template +struct DefaultHasher : PointerHasher::result> +{}; + +// For doubles, we can xor the two uint32s. +template <> +struct DefaultHasher +{ + typedef double Lookup; + static HashNumber hash(double d) { + JS_STATIC_ASSERT(sizeof(HashNumber) == 4); + union { + struct { + uint32_t lo; + uint32_t hi; + } s; + double d; + } u; + u.d = d; + return u.s.lo ^ u.s.hi; + } + static bool match(double lhs, double rhs) { + return lhs == rhs; + } +}; + +/*****************************************************************************/ + +// Both HashMap and HashSet are implemented by a single HashTable that is even +// more heavily parameterized than the other two. This leaves HashTable gnarly +// and extremely coupled to HashMap and HashSet; thus code should not use +// HashTable directly. + +template +class HashMapEntry +{ + template friend class detail::HashTable; + template friend class detail::HashTableEntry; + + HashMapEntry(const HashMapEntry &) MOZ_DELETE; + void operator=(const HashMapEntry &) MOZ_DELETE; + + public: + template + HashMapEntry(const KeyInput &k, const ValueInput &v) : key(k), value(v) {} + + HashMapEntry(MoveRef rhs) + : key(Move(rhs->key)), value(Move(rhs->value)) { } + + const Key key; + Value value; +}; + +} // namespace js + +namespace mozilla { + +template +struct IsPod > : IsPod {}; + +template +struct IsPod > + : IntegralConstant::value && IsPod::value> +{}; + +} // namespace mozilla + +namespace js { + +namespace detail { + +template +class HashTable; + +template +class HashTableEntry +{ + template friend class HashTable; + typedef typename tl::StripConst::result NonConstT; + + HashNumber keyHash; + mozilla::AlignedStorage2 mem; + + static const HashNumber sFreeKey = 0; + static const HashNumber sRemovedKey = 1; + static const HashNumber sCollisionBit = 1; + + // Assumed by calloc in createTable. + JS_STATIC_ASSERT(sFreeKey == 0); + + static bool isLiveHash(HashNumber hash) + { + return hash > sRemovedKey; + } + + HashTableEntry(const HashTableEntry &) MOZ_DELETE; + void operator=(const HashTableEntry &) MOZ_DELETE; + ~HashTableEntry() MOZ_DELETE; + + public: + // NB: HashTableEntry is treated as a POD: no constructor or destructor calls. + + void destroyIfLive() { + if (isLive()) + mem.addr()->~T(); + } + + void destroy() { + JS_ASSERT(isLive()); + mem.addr()->~T(); + } + + void swap(HashTableEntry *other) { + Swap(keyHash, other->keyHash); + Swap(mem, other->mem); + } + + T &get() { JS_ASSERT(isLive()); return *mem.addr(); } + + bool isFree() const { return keyHash == sFreeKey; } + void clearLive() { JS_ASSERT(isLive()); keyHash = sFreeKey; mem.addr()->~T(); } + void clear() { if (isLive()) mem.addr()->~T(); keyHash = sFreeKey; } + void clearNoDtor() { keyHash = sFreeKey; } + bool isRemoved() const { return keyHash == sRemovedKey; } + void removeLive() { JS_ASSERT(isLive()); keyHash = sRemovedKey; mem.addr()->~T(); } + bool isLive() const { return isLiveHash(keyHash); } + void setCollision() { JS_ASSERT(isLive()); keyHash |= sCollisionBit; } + void setCollision(HashNumber bit) { JS_ASSERT(isLive()); keyHash |= bit; } + void unsetCollision() { keyHash &= ~sCollisionBit; } + bool hasCollision() const { return keyHash & sCollisionBit; } + bool matchHash(HashNumber hn) { return (keyHash & ~sCollisionBit) == hn; } + HashNumber getKeyHash() const { return keyHash & ~sCollisionBit; } + + template + void setLive(HashNumber hn, const U &u) + { + JS_ASSERT(!isLive()); + keyHash = hn; + new(mem.addr()) T(u); + JS_ASSERT(isLive()); + } +}; + +template +class HashTable : private AllocPolicy +{ + typedef typename tl::StripConst::result NonConstT; + typedef typename HashPolicy::KeyType Key; + typedef typename HashPolicy::Lookup Lookup; + + public: + typedef HashTableEntry Entry; + + // A nullable pointer to a hash table element. A Ptr |p| can be tested + // either explicitly |if (p.found()) p->...| or using boolean conversion + // |if (p) p->...|. Ptr objects must not be used after any mutating hash + // table operations unless |generation()| is tested. + class Ptr + { + friend class HashTable; + typedef void (Ptr::* ConvertibleToBool)(); + void nonNull() {} + + Entry *entry_; + + protected: + Ptr(Entry &entry) : entry_(&entry) {} + + public: + // Leaves Ptr uninitialized. + Ptr() { +#ifdef DEBUG + entry_ = (Entry *)0xbad; +#endif + } + + bool found() const { return entry_->isLive(); } + operator ConvertibleToBool() const { return found() ? &Ptr::nonNull : 0; } + bool operator==(const Ptr &rhs) const { JS_ASSERT(found() && rhs.found()); return entry_ == rhs.entry_; } + bool operator!=(const Ptr &rhs) const { return !(*this == rhs); } + + T &operator*() const { return entry_->get(); } + T *operator->() const { return &entry_->get(); } + }; + + // A Ptr that can be used to add a key after a failed lookup. + class AddPtr : public Ptr + { + friend class HashTable; + HashNumber keyHash; + mozilla::DebugOnly mutationCount; + + AddPtr(Entry &entry, HashNumber hn) : Ptr(entry), keyHash(hn) {} + public: + // Leaves AddPtr uninitialized. + AddPtr() {} + }; + + // A collection of hash table entries. The collection is enumerated by + // calling |front()| followed by |popFront()| as long as |!empty()|. As + // with Ptr/AddPtr, Range objects must not be used after any mutating hash + // table operation unless the |generation()| is tested. + class Range + { + protected: + friend class HashTable; + + Range(Entry *c, Entry *e) : cur(c), end(e), validEntry(true) { + while (cur < end && !cur->isLive()) + ++cur; + } + + Entry *cur, *end; + mozilla::DebugOnly validEntry; + + public: + Range() : cur(NULL), end(NULL), validEntry(false) {} + + bool empty() const { + return cur == end; + } + + T &front() const { + JS_ASSERT(validEntry); + JS_ASSERT(!empty()); + return cur->get(); + } + + void popFront() { + JS_ASSERT(!empty()); + while (++cur < end && !cur->isLive()) + continue; + validEntry = true; + } + }; + + // A Range whose lifetime delimits a mutating enumeration of a hash table. + // Since rehashing when elements were removed during enumeration would be + // bad, it is postponed until the Enum is destructed. Since the Enum's + // destructor touches the hash table, the user must ensure that the hash + // table is still alive when the destructor runs. + class Enum : public Range + { + friend class HashTable; + + HashTable &table; + bool rekeyed; + bool removed; + + /* Not copyable. */ + Enum(const Enum &); + void operator=(const Enum &); + + public: + template explicit + Enum(Map &map) : Range(map.all()), table(map.impl), rekeyed(false), removed(false) {} + + // Removes the |front()| element from the table, leaving |front()| + // invalid until the next call to |popFront()|. For example: + // + // HashSet s; + // for (HashSet::Enum e(s); !e.empty(); e.popFront()) + // if (e.front() == 42) + // e.removeFront(); + void removeFront() { + table.remove(*this->cur); + removed = true; + this->validEntry = false; + } + + // Removes the |front()| element and re-inserts it into the table with + // a new key at the new Lookup position. |front()| is invalid after + // this operation until the next call to |popFront()|. + void rekeyFront(const Lookup &l, const Key &k) { + typename HashTableEntry::NonConstT t(Move(this->cur->get())); + HashPolicy::setKey(t, const_cast(k)); + table.remove(*this->cur); + table.putNewInfallible(l, Move(t)); + rekeyed = true; + this->validEntry = false; + } + + void rekeyFront(const Key &k) { + rekeyFront(k, k); + } + + // Potentially rehashes the table. + ~Enum() { + if (rekeyed) { + table.gen++; + table.checkOverRemoved(); + } + + if (removed) + table.compactIfUnderloaded(); + } + }; + + // HashTable is movable + HashTable(MoveRef rhs) + : AllocPolicy(*rhs) + { + PodAssign(this, &*rhs); + rhs->table = NULL; + } + void operator=(MoveRef rhs) { + if (table) + destroyTable(*this, table, capacity()); + PodAssign(this, &*rhs); + rhs->table = NULL; + } + + private: + // HashTable is not copyable or assignable + HashTable(const HashTable &) MOZ_DELETE; + void operator=(const HashTable &) MOZ_DELETE; + + private: + uint32_t hashShift; // multiplicative hash shift + uint32_t entryCount; // number of entries in table + uint32_t gen; // entry storage generation number + uint32_t removedCount; // removed entry sentinels in table + Entry *table; // entry storage + + void setTableSizeLog2(unsigned sizeLog2) + { + hashShift = sHashBits - sizeLog2; + } + +#ifdef DEBUG + mutable struct Stats + { + uint32_t searches; // total number of table searches + uint32_t steps; // hash chain links traversed + uint32_t hits; // searches that found key + uint32_t misses; // searches that didn't find key + uint32_t addOverRemoved; // adds that recycled a removed entry + uint32_t removes; // calls to remove + uint32_t removeFrees; // calls to remove that freed the entry + uint32_t grows; // table expansions + uint32_t shrinks; // table contractions + uint32_t compresses; // table compressions + uint32_t rehashes; // tombstone decontaminations + } stats; +# define METER(x) x +#else +# define METER(x) +#endif + + friend class js::ReentrancyGuard; + mutable mozilla::DebugOnly entered; + mozilla::DebugOnly mutationCount; + + // The default initial capacity is 32 (enough to hold 16 elements), but it + // can be as low as 4. + static const unsigned sMinCapacityLog2 = 2; + static const unsigned sMinCapacity = 1 << sMinCapacityLog2; + static const unsigned sMaxInit = JS_BIT(23); + static const unsigned sMaxCapacity = JS_BIT(24); + static const unsigned sHashBits = tl::BitSize::result; + static const uint8_t sMinAlphaFrac = 64; // (0x100 * .25) + static const uint8_t sMaxAlphaFrac = 192; // (0x100 * .75) + static const uint8_t sInvMaxAlpha = 171; // (ceil(0x100 / .75) >> 1) + static const HashNumber sFreeKey = Entry::sFreeKey; + static const HashNumber sRemovedKey = Entry::sRemovedKey; + static const HashNumber sCollisionBit = Entry::sCollisionBit; + + static void staticAsserts() + { + // Rely on compiler "constant overflow warnings". + JS_STATIC_ASSERT(((sMaxInit * sInvMaxAlpha) >> 7) < sMaxCapacity); + JS_STATIC_ASSERT((sMaxCapacity * sInvMaxAlpha) <= UINT32_MAX); + JS_STATIC_ASSERT((sMaxCapacity * sizeof(Entry)) <= UINT32_MAX); + } + + static bool isLiveHash(HashNumber hash) + { + return Entry::isLiveHash(hash); + } + + static HashNumber prepareHash(const Lookup& l) + { + HashNumber keyHash = ScrambleHashCode(HashPolicy::hash(l)); + + // Avoid reserved hash codes. + if (!isLiveHash(keyHash)) + keyHash -= (sRemovedKey + 1); + return keyHash & ~sCollisionBit; + } + + static Entry *createTable(AllocPolicy &alloc, uint32_t capacity) + { + // See JS_STATIC_ASSERT(sFreeKey == 0) in HashTableEntry. + return (Entry *)alloc.calloc_(capacity * sizeof(Entry)); + } + + static void destroyTable(AllocPolicy &alloc, Entry *oldTable, uint32_t capacity) + { + for (Entry *e = oldTable, *end = e + capacity; e < end; ++e) + e->destroyIfLive(); + alloc.free_(oldTable); + } + + public: + HashTable(AllocPolicy ap) + : AllocPolicy(ap), + hashShift(sHashBits), + entryCount(0), + gen(0), + removedCount(0), + table(NULL), + entered(false), + mutationCount(0) + {} + + MOZ_WARN_UNUSED_RESULT bool init(uint32_t length) + { + JS_ASSERT(!initialized()); + + // Correct for sMaxAlphaFrac such that the table will not resize + // when adding 'length' entries. + if (length > sMaxInit) { + this->reportAllocOverflow(); + return false; + } + uint32_t newCapacity = (length * sInvMaxAlpha) >> 7; + + if (newCapacity < sMinCapacity) + newCapacity = sMinCapacity; + + // FIXME: use JS_CEILING_LOG2 when PGO stops crashing (bug 543034). + uint32_t roundUp = sMinCapacity, roundUpLog2 = sMinCapacityLog2; + while (roundUp < newCapacity) { + roundUp <<= 1; + ++roundUpLog2; + } + + newCapacity = roundUp; + JS_ASSERT(newCapacity <= sMaxCapacity); + + table = createTable(*this, newCapacity); + if (!table) + return false; + + setTableSizeLog2(roundUpLog2); + METER(memset(&stats, 0, sizeof(stats))); + return true; + } + + bool initialized() const + { + return !!table; + } + + ~HashTable() + { + if (table) + destroyTable(*this, table, capacity()); + } + + private: + HashNumber hash1(HashNumber hash0) const + { + return hash0 >> hashShift; + } + + struct DoubleHash + { + HashNumber h2; + HashNumber sizeMask; + }; + + DoubleHash hash2(HashNumber curKeyHash) const + { + unsigned sizeLog2 = sHashBits - hashShift; + DoubleHash dh = { + ((curKeyHash << sizeLog2) >> hashShift) | 1, + (HashNumber(1) << sizeLog2) - 1 + }; + return dh; + } + + static HashNumber applyDoubleHash(HashNumber h1, const DoubleHash &dh) + { + return (h1 - dh.h2) & dh.sizeMask; + } + + bool overloaded() + { + return entryCount + removedCount >= ((sMaxAlphaFrac * capacity()) >> 8); + } + + // Would the table be underloaded if it had the given capacity and entryCount? + static bool wouldBeUnderloaded(uint32_t capacity, uint32_t entryCount) + { + return capacity > sMinCapacity && entryCount <= ((sMinAlphaFrac * capacity) >> 8); + } + + bool underloaded() + { + return wouldBeUnderloaded(capacity(), entryCount); + } + + static bool match(Entry &e, const Lookup &l) + { + return HashPolicy::match(HashPolicy::getKey(e.get()), l); + } + + Entry &lookup(const Lookup &l, HashNumber keyHash, unsigned collisionBit) const + { + JS_ASSERT(isLiveHash(keyHash)); + JS_ASSERT(!(keyHash & sCollisionBit)); + JS_ASSERT(collisionBit == 0 || collisionBit == sCollisionBit); + JS_ASSERT(table); + METER(stats.searches++); + + // Compute the primary hash address. + HashNumber h1 = hash1(keyHash); + Entry *entry = &table[h1]; + + // Miss: return space for a new entry. + if (entry->isFree()) { + METER(stats.misses++); + return *entry; + } + + // Hit: return entry. + if (entry->matchHash(keyHash) && match(*entry, l)) { + METER(stats.hits++); + return *entry; + } + + // Collision: double hash. + DoubleHash dh = hash2(keyHash); + + // Save the first removed entry pointer so we can recycle later. + Entry *firstRemoved = NULL; + + while(true) { + if (JS_UNLIKELY(entry->isRemoved())) { + if (!firstRemoved) + firstRemoved = entry; + } else { + entry->setCollision(collisionBit); + } + + METER(stats.steps++); + h1 = applyDoubleHash(h1, dh); + + entry = &table[h1]; + if (entry->isFree()) { + METER(stats.misses++); + return firstRemoved ? *firstRemoved : *entry; + } + + if (entry->matchHash(keyHash) && match(*entry, l)) { + METER(stats.hits++); + return *entry; + } + } + } + + // This is a copy of lookup hardcoded to the assumptions: + // 1. the lookup is a lookupForAdd + // 2. the key, whose |keyHash| has been passed is not in the table, + // 3. no entries have been removed from the table. + // This specialized search avoids the need for recovering lookup values + // from entries, which allows more flexible Lookup/Key types. + Entry &findFreeEntry(HashNumber keyHash) + { + JS_ASSERT(!(keyHash & sCollisionBit)); + JS_ASSERT(table); + METER(stats.searches++); + + // We assume 'keyHash' has already been distributed. + + // Compute the primary hash address. + HashNumber h1 = hash1(keyHash); + Entry *entry = &table[h1]; + + // Miss: return space for a new entry. + if (!entry->isLive()) { + METER(stats.misses++); + return *entry; + } + + // Collision: double hash. + DoubleHash dh = hash2(keyHash); + + while(true) { + JS_ASSERT(!entry->isRemoved()); + entry->setCollision(); + + METER(stats.steps++); + h1 = applyDoubleHash(h1, dh); + + entry = &table[h1]; + if (!entry->isLive()) { + METER(stats.misses++); + return *entry; + } + } + } + + enum RebuildStatus { NotOverloaded, Rehashed, RehashFailed }; + + RebuildStatus changeTableSize(int deltaLog2) + { + // Look, but don't touch, until we succeed in getting new entry store. + Entry *oldTable = table; + uint32_t oldCap = capacity(); + uint32_t newLog2 = sHashBits - hashShift + deltaLog2; + uint32_t newCapacity = JS_BIT(newLog2); + if (newCapacity > sMaxCapacity) { + this->reportAllocOverflow(); + return RehashFailed; + } + + Entry *newTable = createTable(*this, newCapacity); + if (!newTable) + return RehashFailed; + + // We can't fail from here on, so update table parameters. + setTableSizeLog2(newLog2); + removedCount = 0; + gen++; + table = newTable; + + // Copy only live entries, leaving removed ones behind. + for (Entry *src = oldTable, *end = src + oldCap; src < end; ++src) { + if (src->isLive()) { + HashNumber hn = src->getKeyHash(); + findFreeEntry(hn).setLive(hn, Move(src->get())); + src->destroy(); + } + } + + // All entries have been destroyed, no need to destroyTable. + this->free_(oldTable); + return Rehashed; + } + + RebuildStatus checkOverloaded() + { + if (!overloaded()) + return NotOverloaded; + + // Compress if a quarter or more of all entries are removed. + int deltaLog2; + if (removedCount >= (capacity() >> 2)) { + METER(stats.compresses++); + deltaLog2 = 0; + } else { + METER(stats.grows++); + deltaLog2 = 1; + } + + return changeTableSize(deltaLog2); + } + + // Infallibly rehash the table if we are overloaded with removals. + void checkOverRemoved() + { + if (overloaded()) { + if (checkOverloaded() == RehashFailed) + rehashTableInPlace(); + } + } + + void remove(Entry &e) + { + JS_ASSERT(table); + METER(stats.removes++); + + if (e.hasCollision()) { + e.removeLive(); + removedCount++; + } else { + METER(stats.removeFrees++); + e.clearLive(); + } + entryCount--; + mutationCount++; + } + + void checkUnderloaded() + { + if (underloaded()) { + METER(stats.shrinks++); + (void) changeTableSize(-1); + } + } + + // Resize the table down to the largest capacity which doesn't underload the + // table. Since we call checkUnderloaded() on every remove, you only need + // to call this after a bulk removal of items done without calling remove(). + void compactIfUnderloaded() + { + int32_t resizeLog2 = 0; + uint32_t newCapacity = capacity(); + while (wouldBeUnderloaded(newCapacity, entryCount)) { + newCapacity = newCapacity >> 1; + resizeLog2--; + } + + if (resizeLog2 != 0) { + changeTableSize(resizeLog2); + } + } + + // This is identical to changeTableSize(currentSize), but without requiring + // a second table. We do this by recycling the collision bits to tell us if + // the element is already inserted or still waiting to be inserted. Since + // already-inserted elements win any conflicts, we get the same table as we + // would have gotten through random insertion order. + void rehashTableInPlace() + { + METER(stats.rehashes++); + removedCount = 0; + for (size_t i = 0; i < capacity(); ++i) + table[i].unsetCollision(); + + for (size_t i = 0; i < capacity();) { + Entry *src = &table[i]; + + if (!src->isLive() || src->hasCollision()) { + ++i; + continue; + } + + HashNumber keyHash = src->getKeyHash(); + HashNumber h1 = hash1(keyHash); + DoubleHash dh = hash2(keyHash); + Entry *tgt = &table[h1]; + while (true) { + if (!tgt->hasCollision()) { + src->swap(tgt); + tgt->setCollision(); + break; + } + + h1 = applyDoubleHash(h1, dh); + tgt = &table[h1]; + } + } + + // TODO: this algorithm leaves collision bits on *all* elements, even if + // they are on no collision path. We have the option of setting the + // collision bits correctly on a subsequent pass or skipping the rehash + // unless we are totally filled with tombstones: benchmark to find out + // which approach is best. + } + + public: + void clear() + { + if (mozilla::IsPod::value) { + memset(table, 0, sizeof(*table) * capacity()); + } else { + uint32_t tableCapacity = capacity(); + for (Entry *e = table, *end = table + tableCapacity; e < end; ++e) + e->clear(); + } + removedCount = 0; + entryCount = 0; + mutationCount++; + } + + void clearWithoutCallingDestructors() + { + if (mozilla::IsPod::value) { + memset(table, 0, sizeof(*table) * capacity()); + } else { + uint32_t tableCapacity = capacity(); + for (Entry *e = table, *end = table + tableCapacity; e < end; ++e) + e->clearNoDtor(); + } + removedCount = 0; + entryCount = 0; + mutationCount++; + } + + void finish() + { + JS_ASSERT(!entered); + + if (!table) + return; + + destroyTable(*this, table, capacity()); + table = NULL; + gen++; + entryCount = 0; + removedCount = 0; + mutationCount++; + } + + Range all() const + { + JS_ASSERT(table); + return Range(table, table + capacity()); + } + + bool empty() const + { + JS_ASSERT(table); + return !entryCount; + } + + uint32_t count() const + { + JS_ASSERT(table); + return entryCount; + } + + uint32_t capacity() const + { + JS_ASSERT(table); + return JS_BIT(sHashBits - hashShift); + } + + uint32_t generation() const + { + JS_ASSERT(table); + return gen; + } + + size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const + { + return mallocSizeOf(table); + } + + size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const + { + return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); + } + + Ptr lookup(const Lookup &l) const + { + ReentrancyGuard g(*this); + HashNumber keyHash = prepareHash(l); + return Ptr(lookup(l, keyHash, 0)); + } + + Ptr readonlyThreadsafeLookup(const Lookup &l) const + { + HashNumber keyHash = prepareHash(l); + return Ptr(lookup(l, keyHash, 0)); + } + + AddPtr lookupForAdd(const Lookup &l) const + { + ReentrancyGuard g(*this); + HashNumber keyHash = prepareHash(l); + Entry &entry = lookup(l, keyHash, sCollisionBit); + AddPtr p(entry, keyHash); + p.mutationCount = mutationCount; + return p; + } + + template + bool add(AddPtr &p, const U &rhs) + { + ReentrancyGuard g(*this); + JS_ASSERT(mutationCount == p.mutationCount); + JS_ASSERT(table); + JS_ASSERT(!p.found()); + JS_ASSERT(!(p.keyHash & sCollisionBit)); + + // Changing an entry from removed to live does not affect whether we + // are overloaded and can be handled separately. + if (p.entry_->isRemoved()) { + METER(stats.addOverRemoved++); + removedCount--; + p.keyHash |= sCollisionBit; + } else { + // Preserve the validity of |p.entry_|. + RebuildStatus status = checkOverloaded(); + if (status == RehashFailed) + return false; + if (status == Rehashed) + p.entry_ = &findFreeEntry(p.keyHash); + } + + p.entry_->setLive(p.keyHash, rhs); + entryCount++; + mutationCount++; + return true; + } + + template + void putNewInfallible(const Lookup &l, const U &u) + { + JS_ASSERT(table); + + HashNumber keyHash = prepareHash(l); + Entry *entry = &findFreeEntry(keyHash); + + if (entry->isRemoved()) { + METER(stats.addOverRemoved++); + removedCount--; + keyHash |= sCollisionBit; + } + + entry->setLive(keyHash, u); + entryCount++; + mutationCount++; + } + + template + bool putNew(const Lookup &l, const U &u) + { + if (checkOverloaded() == RehashFailed) + return false; + + putNewInfallible(l, u); + return true; + } + + template + bool relookupOrAdd(AddPtr& p, const Lookup &l, const U &u) + { + p.mutationCount = mutationCount; + { + ReentrancyGuard g(*this); + p.entry_ = &lookup(l, p.keyHash, sCollisionBit); + } + return p.found() || add(p, u); + } + + void remove(Ptr p) + { + JS_ASSERT(table); + ReentrancyGuard g(*this); + JS_ASSERT(p.found()); + remove(*p.entry_); + checkUnderloaded(); + } + +#undef METER +}; + +} // namespace detail +} // namespace js + +#endif // js_HashTable_h__ + diff --git a/scripting/javascript/spidermonkey-mac/include/js/HeapAPI.h b/scripting/javascript/spidermonkey-mac/include/js/HeapAPI.h new file mode 100644 index 0000000000..2f61e9d2ee --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/HeapAPI.h @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_heap_api_h___ +#define js_heap_api_h___ + +/* These values are private to the JS engine. */ +namespace js { +namespace gc { + +/* + * Page size must be static to support our arena pointer optimizations, so we + * are forced to support each platform with non-4096 pages as a special case. + * Note: The freelist supports a maximum arena shift of 15. + * Note: Do not use JS_CPU_SPARC here, this header is used outside JS. + */ +#if (defined(SOLARIS) || defined(__FreeBSD__)) && \ + (defined(__sparc) || defined(__sparcv9) || defined(__ia64)) +const size_t PageShift = 13; +const size_t ArenaShift = PageShift; +#elif defined(__powerpc64__) +const size_t PageShift = 16; +const size_t ArenaShift = 12; +#else +const size_t PageShift = 12; +const size_t ArenaShift = PageShift; +#endif +const size_t PageSize = size_t(1) << PageShift; +const size_t ArenaSize = size_t(1) << ArenaShift; +const size_t ArenaMask = ArenaSize - 1; + +const size_t ChunkShift = 20; +const size_t ChunkSize = size_t(1) << ChunkShift; +const size_t ChunkMask = ChunkSize - 1; + +const size_t CellShift = 3; +const size_t CellSize = size_t(1) << CellShift; +const size_t CellMask = CellSize - 1; + +/* These are magic constants derived from actual offsets in gc/Heap.h. */ +const size_t ChunkMarkBitmapOffset = 1032368; +const size_t ChunkMarkBitmapBits = 129024; + +/* + * Live objects are marked black. How many other additional colors are available + * depends on the size of the GCThing. Objects marked gray are eligible for + * cycle collection. + */ +static const uint32_t BLACK = 0; +static const uint32_t GRAY = 1; + +} /* namespace gc */ +} /* namespace js */ + +namespace JS { +struct Zone; +} /* namespace JS */ + +namespace JS { +namespace shadow { + +struct ArenaHeader +{ + js::Zone *zone; +}; + +struct Zone +{ + bool needsBarrier_; + + Zone() : needsBarrier_(false) {} +}; + +} /* namespace shadow */ +} /* namespace JS */ + +namespace js { +namespace gc { + +static JS_ALWAYS_INLINE uintptr_t * +GetGCThingMarkBitmap(const void *thing) +{ + uintptr_t addr = uintptr_t(thing); + addr &= ~js::gc::ChunkMask; + addr |= js::gc::ChunkMarkBitmapOffset; + return reinterpret_cast(addr); +} + +static JS_ALWAYS_INLINE void +GetGCThingMarkWordAndMask(const void *thing, uint32_t color, + uintptr_t **wordp, uintptr_t *maskp) +{ + uintptr_t addr = uintptr_t(thing); + size_t bit = (addr & js::gc::ChunkMask) / js::gc::CellSize + color; + JS_ASSERT(bit < js::gc::ChunkMarkBitmapBits); + uintptr_t *bitmap = GetGCThingMarkBitmap(thing); + *maskp = uintptr_t(1) << (bit % JS_BITS_PER_WORD); + *wordp = &bitmap[bit / JS_BITS_PER_WORD]; +} + +static JS_ALWAYS_INLINE JS::shadow::ArenaHeader * +GetGCThingArena(void *thing) +{ + uintptr_t addr = uintptr_t(thing); + addr &= ~js::gc::ArenaMask; + return reinterpret_cast(addr); +} + +} /* namespace gc */ + +} /* namespace js */ + +namespace JS { + +static JS_ALWAYS_INLINE Zone * +GetGCThingZone(void *thing) +{ + JS_ASSERT(thing); + return js::gc::GetGCThingArena(thing)->zone; +} + +static JS_ALWAYS_INLINE Zone * +GetObjectZone(JSObject *obj) +{ + return GetGCThingZone(obj); +} + +static JS_ALWAYS_INLINE bool +GCThingIsMarkedGray(void *thing) +{ + uintptr_t *word, mask; + js::gc::GetGCThingMarkWordAndMask(thing, js::gc::GRAY, &word, &mask); + return *word & mask; +} + +static JS_ALWAYS_INLINE bool +IsIncrementalBarrierNeededOnGCThing(void *thing, JSGCTraceKind kind) +{ + js::Zone *zone = GetGCThingZone(thing); + return reinterpret_cast(zone)->needsBarrier_; +} + +} /* namespace JS */ + +#endif /* js_heap_api_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/LegacyIntTypes.h b/scripting/javascript/spidermonkey-mac/include/js/LegacyIntTypes.h new file mode 100644 index 0000000000..30944efda6 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/LegacyIntTypes.h @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This section typedefs the old 'native' types to the new types. + * These redefinitions are provided solely to allow JSAPI users to more easily + * transition to types. They are not to be used in the JSAPI, and + * new JSAPI user code should not use them. This mapping file may eventually + * be removed from SpiderMonkey, so don't depend on it in the long run. + */ + +/* + * BEWARE: Comity with other implementers of these types is not guaranteed. + * Indeed, if you use this header and third-party code defining these + * types, *expect* to encounter either compile errors or link errors, + * depending how these types are used and on the order of inclusion. + * It is safest to use only the JSAPI -style types, + * customizing those types using MOZ_CUSTOM_STDINT_H if necessary. + */ +#ifndef PROTYPES_H +#define PROTYPES_H + +#include "mozilla/StandardInteger.h" + +#include "js-config.h" + +typedef uint8_t uint8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef uint64_t uint64; + +/* + * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very + * common header file) defines the types int8, int16, int32, and int64. + * So we don't define these four types here to avoid conflicts in case + * the code also includes sys/types.h. + */ +#if defined(AIX) && defined(HAVE_SYS_INTTYPES_H) +#include +#else +typedef int8_t int8; +typedef int16_t int16; +typedef int32_t int32; +typedef int64_t int64; +#endif /* AIX && HAVE_SYS_INTTYPES_H */ + +typedef uint8_t JSUint8; +typedef uint16_t JSUint16; +typedef uint32_t JSUint32; +typedef uint64_t JSUint64; + +typedef int8_t JSInt8; +typedef int16_t JSInt16; +typedef int32_t JSInt32; +typedef int64_t JSInt64; + +#endif /* !defined(PROTYPES_H) */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/MemoryMetrics.h b/scripting/javascript/spidermonkey-mac/include/js/MemoryMetrics.h new file mode 100644 index 0000000000..71b8cd37ba --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/MemoryMetrics.h @@ -0,0 +1,452 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_MemoryMetrics_h +#define js_MemoryMetrics_h + +// These declarations are not within jsapi.h because they are highly likely to +// change in the future. Depend on them at your own risk. + +#include + +#include "jsalloc.h" +#include "jspubtd.h" + +#include "js/Utility.h" +#include "js/Vector.h" + +class nsISupports; // This is needed for ObjectPrivateVisitor. + +namespace js { + +// In memory reporting, we have concept of "sundries", line items which are too +// small to be worth reporting individually. Under some circumstances, a memory +// reporter gets tossed into the sundries bucket if it's smaller than +// MemoryReportingSundriesThreshold() bytes. +// +// We need to define this value here, rather than in the code which actually +// generates the memory reports, because HugeStringInfo uses this value. +JS_FRIEND_API(size_t) MemoryReportingSundriesThreshold(); + +} // namespace js + +namespace JS { + +// Data for tracking memory usage of things hanging off objects. +struct ObjectsExtraSizes +{ + size_t slots; + size_t elementsNonAsmJS; + size_t elementsAsmJSHeap; + size_t elementsAsmJSNonHeap; + size_t argumentsData; + size_t regExpStatics; + size_t propertyIteratorData; + size_t ctypesData; + size_t private_; // The '_' suffix is required because |private| is a keyword. + // Note that this field is measured separately from the others. + + ObjectsExtraSizes() { memset(this, 0, sizeof(ObjectsExtraSizes)); } + + void add(ObjectsExtraSizes &sizes) { + this->slots += sizes.slots; + this->elementsNonAsmJS += sizes.elementsNonAsmJS; + this->elementsAsmJSHeap += sizes.elementsAsmJSHeap; + this->elementsAsmJSNonHeap += sizes.elementsAsmJSNonHeap; + this->argumentsData += sizes.argumentsData; + this->regExpStatics += sizes.regExpStatics; + this->propertyIteratorData += sizes.propertyIteratorData; + this->ctypesData += sizes.ctypesData; + this->private_ += sizes.private_; + } +}; + +// Data for tracking analysis/inference memory usage. +struct TypeInferenceSizes +{ + size_t typeScripts; + size_t typeResults; + size_t analysisPool; + size_t pendingArrays; + size_t allocationSiteTables; + size_t arrayTypeTables; + size_t objectTypeTables; + + TypeInferenceSizes() { memset(this, 0, sizeof(TypeInferenceSizes)); } + + void add(TypeInferenceSizes &sizes) { + this->typeScripts += sizes.typeScripts; + this->typeResults += sizes.typeResults; + this->analysisPool += sizes.analysisPool; + this->pendingArrays += sizes.pendingArrays; + this->allocationSiteTables += sizes.allocationSiteTables; + this->arrayTypeTables += sizes.arrayTypeTables; + this->objectTypeTables += sizes.objectTypeTables; + } +}; + +// Data for tracking JIT-code memory usage. +struct CodeSizes +{ + size_t jaeger; + size_t ion; + size_t asmJS; + size_t baseline; + size_t regexp; + size_t other; + size_t unused; + + CodeSizes() { memset(this, 0, sizeof(CodeSizes)); } +}; + +// Holds data about a huge string (one which uses more HugeStringInfo::MinSize +// bytes of memory), so we can report it individually. +struct HugeStringInfo +{ + HugeStringInfo() : length(0), size(0) { memset(&buffer, 0, sizeof(buffer)); } + + // A string needs to take up this many bytes of storage before we consider + // it to be "huge". + static size_t MinSize() { + return js::MemoryReportingSundriesThreshold(); + } + + // A string's size in memory is not necessarily equal to twice its length + // because the allocator and the JS engine both may round up. + size_t length; + size_t size; + + // We record the first 32 chars of the escaped string here. (We escape the + // string so we can use a char[] instead of a jschar[] here. + char buffer[32]; +}; + +// These measurements relate directly to the JSRuntime, and not to +// compartments within it. +struct RuntimeSizes +{ + RuntimeSizes() { memset(this, 0, sizeof(RuntimeSizes)); } + + size_t object; + size_t atomsTable; + size_t contexts; + size_t dtoa; + size_t temporary; + size_t regexpData; + size_t stack; + size_t gcMarker; + size_t mathCache; + size_t scriptData; + size_t scriptSources; + + CodeSizes code; +}; + +struct ZoneStats +{ + ZoneStats() + : extra1(0), + gcHeapArenaAdmin(0), + gcHeapUnusedGcThings(0), + gcHeapStringsNormal(0), + gcHeapStringsShort(0), + gcHeapTypeObjects(0), + gcHeapIonCodes(0), + stringCharsNonHuge(0), + typeObjects(0), + typePool(0), + hugeStrings() + {} + + ZoneStats(const ZoneStats &other) + : extra1(other.extra1), + gcHeapArenaAdmin(other.gcHeapArenaAdmin), + gcHeapUnusedGcThings(other.gcHeapUnusedGcThings), + gcHeapStringsNormal(other.gcHeapStringsNormal), + gcHeapStringsShort(other.gcHeapStringsShort), + gcHeapTypeObjects(other.gcHeapTypeObjects), + gcHeapIonCodes(other.gcHeapIonCodes), + stringCharsNonHuge(other.stringCharsNonHuge), + typeObjects(other.typeObjects), + typePool(other.typePool), + hugeStrings() + { + hugeStrings.append(other.hugeStrings); + } + + // Add other's numbers to this object's numbers. + void add(ZoneStats &other) { + #define ADD(x) this->x += other.x + + ADD(gcHeapArenaAdmin); + ADD(gcHeapUnusedGcThings); + + ADD(gcHeapStringsNormal); + ADD(gcHeapStringsShort); + ADD(gcHeapTypeObjects); + ADD(gcHeapIonCodes); + + ADD(stringCharsNonHuge); + ADD(typeObjects); + ADD(typePool); + + #undef ADD + + hugeStrings.append(other.hugeStrings); + } + + // This field can be used by embedders. + void *extra1; + + size_t gcHeapArenaAdmin; + size_t gcHeapUnusedGcThings; + + size_t gcHeapStringsNormal; + size_t gcHeapStringsShort; + + size_t gcHeapTypeObjects; + size_t gcHeapIonCodes; + + size_t stringCharsNonHuge; + size_t typeObjects; + size_t typePool; + + js::Vector hugeStrings; + + // The size of all the live things in the GC heap that don't belong to any + // compartment. + size_t GCHeapThingsSize(); +}; + +struct CompartmentStats +{ + CompartmentStats() + : extra1(0), + extra2(0), + gcHeapObjectsOrdinary(0), + gcHeapObjectsFunction(0), + gcHeapObjectsDenseArray(0), + gcHeapObjectsSlowArray(0), + gcHeapObjectsCrossCompartmentWrapper(0), + gcHeapShapesTreeGlobalParented(0), + gcHeapShapesTreeNonGlobalParented(0), + gcHeapShapesDict(0), + gcHeapShapesBase(0), + gcHeapScripts(0), + objectsExtra(), + shapesExtraTreeTables(0), + shapesExtraDictTables(0), + shapesExtraTreeShapeKids(0), + shapesCompartmentTables(0), + scriptData(0), + jaegerData(0), + ionData(0), + compartmentObject(0), + crossCompartmentWrappersTable(0), + regexpCompartment(0), + debuggeesSet(0), + typeInference() + {} + + CompartmentStats(const CompartmentStats &other) + : extra1(other.extra1), + extra2(other.extra2), + gcHeapObjectsOrdinary(other.gcHeapObjectsOrdinary), + gcHeapObjectsFunction(other.gcHeapObjectsFunction), + gcHeapObjectsDenseArray(other.gcHeapObjectsDenseArray), + gcHeapObjectsSlowArray(other.gcHeapObjectsSlowArray), + gcHeapObjectsCrossCompartmentWrapper(other.gcHeapObjectsCrossCompartmentWrapper), + gcHeapShapesTreeGlobalParented(other.gcHeapShapesTreeGlobalParented), + gcHeapShapesTreeNonGlobalParented(other.gcHeapShapesTreeNonGlobalParented), + gcHeapShapesDict(other.gcHeapShapesDict), + gcHeapShapesBase(other.gcHeapShapesBase), + gcHeapScripts(other.gcHeapScripts), + objectsExtra(other.objectsExtra), + shapesExtraTreeTables(other.shapesExtraTreeTables), + shapesExtraDictTables(other.shapesExtraDictTables), + shapesExtraTreeShapeKids(other.shapesExtraTreeShapeKids), + shapesCompartmentTables(other.shapesCompartmentTables), + scriptData(other.scriptData), + jaegerData(other.jaegerData), + ionData(other.ionData), + compartmentObject(other.compartmentObject), + crossCompartmentWrappersTable(other.crossCompartmentWrappersTable), + regexpCompartment(other.regexpCompartment), + debuggeesSet(other.debuggeesSet), + typeInference(other.typeInference) + { + } + + // These fields can be used by embedders. + void *extra1; + void *extra2; + + // If you add a new number, remember to update the constructors, add(), and + // maybe gcHeapThingsSize()! + size_t gcHeapObjectsOrdinary; + size_t gcHeapObjectsFunction; + size_t gcHeapObjectsDenseArray; + size_t gcHeapObjectsSlowArray; + size_t gcHeapObjectsCrossCompartmentWrapper; + size_t gcHeapShapesTreeGlobalParented; + size_t gcHeapShapesTreeNonGlobalParented; + size_t gcHeapShapesDict; + size_t gcHeapShapesBase; + size_t gcHeapScripts; + ObjectsExtraSizes objectsExtra; + + size_t shapesExtraTreeTables; + size_t shapesExtraDictTables; + size_t shapesExtraTreeShapeKids; + size_t shapesCompartmentTables; + size_t scriptData; + size_t jaegerData; + size_t ionData; + size_t compartmentObject; + size_t crossCompartmentWrappersTable; + size_t regexpCompartment; + size_t debuggeesSet; + + TypeInferenceSizes typeInference; + + // Add cStats's numbers to this object's numbers. + void add(CompartmentStats &cStats) { + #define ADD(x) this->x += cStats.x + + ADD(gcHeapObjectsOrdinary); + ADD(gcHeapObjectsFunction); + ADD(gcHeapObjectsDenseArray); + ADD(gcHeapObjectsSlowArray); + ADD(gcHeapObjectsCrossCompartmentWrapper); + ADD(gcHeapShapesTreeGlobalParented); + ADD(gcHeapShapesTreeNonGlobalParented); + ADD(gcHeapShapesDict); + ADD(gcHeapShapesBase); + ADD(gcHeapScripts); + objectsExtra.add(cStats.objectsExtra); + + ADD(shapesExtraTreeTables); + ADD(shapesExtraDictTables); + ADD(shapesExtraTreeShapeKids); + ADD(shapesCompartmentTables); + ADD(scriptData); + ADD(jaegerData); + ADD(ionData); + ADD(compartmentObject); + ADD(crossCompartmentWrappersTable); + ADD(regexpCompartment); + ADD(debuggeesSet); + + #undef ADD + + typeInference.add(cStats.typeInference); + } + + // The size of all the live things in the GC heap. + size_t GCHeapThingsSize(); +}; + +struct RuntimeStats +{ + RuntimeStats(JSMallocSizeOfFun mallocSizeOf) + : runtime(), + gcHeapChunkTotal(0), + gcHeapDecommittedArenas(0), + gcHeapUnusedChunks(0), + gcHeapUnusedArenas(0), + gcHeapUnusedGcThings(0), + gcHeapChunkAdmin(0), + gcHeapGcThings(0), + cTotals(), + zTotals(), + compartmentStatsVector(), + zoneStatsVector(), + currZoneStats(NULL), + mallocSizeOf_(mallocSizeOf) + {} + + RuntimeSizes runtime; + + // If you add a new number, remember to update the constructor! + + // Here's a useful breakdown of the GC heap. + // + // - rtStats.gcHeapChunkTotal + // - decommitted bytes + // - rtStats.gcHeapDecommittedArenas (decommitted arenas in non-empty chunks) + // - unused bytes + // - rtStats.gcHeapUnusedChunks (empty chunks) + // - rtStats.gcHeapUnusedArenas (empty arenas within non-empty chunks) + // - rtStats.total.gcHeapUnusedGcThings (empty GC thing slots within non-empty arenas) + // - used bytes + // - rtStats.gcHeapChunkAdmin + // - rtStats.total.gcHeapArenaAdmin + // - rtStats.gcHeapGcThings (in-use GC things) + // + // It's possible that some arenas in empty chunks may be decommitted, but + // we don't count those under rtStats.gcHeapDecommittedArenas because (a) + // it's rare, and (b) this means that rtStats.gcHeapUnusedChunks is a + // multiple of the chunk size, which is good. + + size_t gcHeapChunkTotal; + size_t gcHeapDecommittedArenas; + size_t gcHeapUnusedChunks; + size_t gcHeapUnusedArenas; + size_t gcHeapUnusedGcThings; + size_t gcHeapChunkAdmin; + size_t gcHeapGcThings; + + // The sum of all compartment's measurements. + CompartmentStats cTotals; + ZoneStats zTotals; + + js::Vector compartmentStatsVector; + js::Vector zoneStatsVector; + + ZoneStats *currZoneStats; + + JSMallocSizeOfFun mallocSizeOf_; + + virtual void initExtraCompartmentStats(JSCompartment *c, CompartmentStats *cstats) = 0; + virtual void initExtraZoneStats(JS::Zone *zone, ZoneStats *zstats) = 0; +}; + +class ObjectPrivateVisitor +{ + public: + // Within CollectRuntimeStats, this method is called for each JS object + // that has an nsISupports pointer. + virtual size_t sizeOfIncludingThis(nsISupports *aSupports) = 0; + + // A callback that gets a JSObject's nsISupports pointer, if it has one. + // Note: this function does *not* addref |iface|. + typedef JSBool(*GetISupportsFun)(JSObject *obj, nsISupports **iface); + GetISupportsFun getISupports_; + + ObjectPrivateVisitor(GetISupportsFun getISupports) + : getISupports_(getISupports) + {} +}; + +extern JS_PUBLIC_API(bool) +CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv); + +extern JS_PUBLIC_API(int64_t) +GetExplicitNonHeapForRuntime(JSRuntime *rt, JSMallocSizeOfFun mallocSizeOf); + +extern JS_PUBLIC_API(size_t) +SystemCompartmentCount(JSRuntime *rt); + +extern JS_PUBLIC_API(size_t) +UserCompartmentCount(JSRuntime *rt); + +extern JS_PUBLIC_API(size_t) +PeakSizeOfTemporary(const JSRuntime *rt); + +} // namespace JS + +#endif // js_MemoryMetrics_h diff --git a/scripting/javascript/spidermonkey-mac/include/js/PropertyKey.h b/scripting/javascript/spidermonkey-mac/include/js/PropertyKey.h new file mode 100644 index 0000000000..5d048195f5 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/PropertyKey.h @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* JS::PropertyKey implementation. */ + +#ifndef js_PropertyKey_h___ +#define js_PropertyKey_h___ + +#include "mozilla/Attributes.h" + +#include "js/Value.h" + +struct JSContext; + +namespace JS { + +class PropertyKey; + +namespace detail { + +extern JS_PUBLIC_API(bool) +ToPropertyKeySlow(JSContext *cx, HandleValue v, PropertyKey *key); + +} // namespace detail + +/* + * A PropertyKey is a key used to access some property on an object. It is a + * natural way to represent a property accessed using a JavaScript value. + * + * PropertyKey can represent indexes, named properties, and ES6 symbols. The + * latter aren't implemented in SpiderMonkey yet, but PropertyKey carves out + * space for them. + */ +class PropertyKey +{ + Value v; + friend JS_PUBLIC_API(bool) detail::ToPropertyKeySlow(JSContext *cx, HandleValue v, PropertyKey *key); + + public: + explicit PropertyKey(uint32_t index) : v(PrivateUint32Value(index)) {} + + /* + * An index is a string property name whose characters exactly spell out an + * unsigned 32-bit integer in decimal: "0", "1", "2", ...., "4294967294", + * "4294967295". + */ + bool isIndex(uint32_t *index) { + // The implementation here assumes that private uint32_t are stored + // using the int32_t representation. This is purely an implementation + // detail: embedders must not rely upon this! + if (!v.isInt32()) + return false; + *index = v.toPrivateUint32(); + return true; + } + + /* + * A name is a string property name which is *not* an index. Note that by + * the ECMAScript language grammar, any dotted property access |obj.prop| + * will access a named property. + */ + bool isName(JSString **str) { + uint32_t dummy; + if (isIndex(&dummy)) + return false; + *str = v.toString(); + return true; + } + + /* + * A symbol is a property name that's a Symbol, a particular kind of object + * in ES6. It is the only kind of property name that's not a string. + * + * SpiderMonkey doesn't yet implement symbols, but we're carving out API + * space for them in advance. + */ + bool isSymbol() { + return false; + } +}; + +inline bool +ToPropertyKey(JSContext *cx, HandleValue v, PropertyKey *key) +{ + if (v.isInt32() && v.toInt32() >= 0) { + *key = PropertyKey(uint32_t(v.toInt32())); + return true; + } + + return detail::ToPropertyKeySlow(cx, v, key); +} + +} // namespace JS + +#endif /* js_PropertyKey_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/RequiredDefines.h b/scripting/javascript/spidermonkey-mac/include/js/RequiredDefines.h new file mode 100644 index 0000000000..8dc47e251c --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/RequiredDefines.h @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=79: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Various #defines required to build SpiderMonkey. Embedders should add this + * file to the start of the command line via -include or a similar mechanism, + * or SpiderMonkey public headers may not work correctly. + */ + +#ifndef js_RequiredDefines_h___ +#define js_RequiredDefines_h___ + +/* + * The c99 defining the limit macros (UINT32_MAX for example), says: + * C++ implementations should define these macros only when __STDC_LIMIT_MACROS + * is defined before is included. + */ +#define __STDC_LIMIT_MACROS + +#endif /* js_RequiredDefines_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/RootingAPI.h b/scripting/javascript/spidermonkey-mac/include/js/RootingAPI.h new file mode 100644 index 0000000000..0f1e6b459c --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/RootingAPI.h @@ -0,0 +1,837 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=78: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsgc_root_h__ +#define jsgc_root_h__ + +#include "mozilla/GuardObjects.h" +#include "mozilla/TypeTraits.h" + +#include "js/Utility.h" +#include "js/TemplateLib.h" + +#include "jspubtd.h" + +/* + * Moving GC Stack Rooting + * + * A moving GC may change the physical location of GC allocated things, even + * when they are rooted, updating all pointers to the thing to refer to its new + * location. The GC must therefore know about all live pointers to a thing, + * not just one of them, in order to behave correctly. + * + * The |Root| and |Handle| classes below are used to root stack locations + * whose value may be held live across a call that can trigger GC. For a + * code fragment such as: + * + * JSObject *obj = NewObject(cx); + * DoSomething(cx); + * ... = obj->lastProperty(); + * + * If |DoSomething()| can trigger a GC, the stack location of |obj| must be + * rooted to ensure that the GC does not move the JSObject referred to by + * |obj| without updating |obj|'s location itself. This rooting must happen + * regardless of whether there are other roots which ensure that the object + * itself will not be collected. + * + * If |DoSomething()| cannot trigger a GC, and the same holds for all other + * calls made between |obj|'s definitions and its last uses, then no rooting + * is required. + * + * SpiderMonkey can trigger a GC at almost any time and in ways that are not + * always clear. For example, the following innocuous-looking actions can + * cause a GC: allocation of any new GC thing; JSObject::hasProperty; + * JS_ReportError and friends; and ToNumber, among many others. The following + * dangerous-looking actions cannot trigger a GC: js_malloc, cx->malloc_, + * rt->malloc_, and friends and JS_ReportOutOfMemory. + * + * The following family of four classes will exactly root a stack location. + * Incorrect usage of these classes will result in a compile error in almost + * all cases. Therefore, it is very hard to be incorrectly rooted if you use + * these classes exclusively. These classes are all templated on the type T of + * the value being rooted. + * + * - Rooted declares a variable of type T, whose value is always rooted. + * Rooted may be automatically coerced to a Handle, below. Rooted + * should be used whenever a local variable's value may be held live across a + * call which can trigger a GC. This is generally true of + * + * - Handle is a const reference to a Rooted. Functions which take GC + * things or values as arguments and need to root those arguments should + * generally use handles for those arguments and avoid any explicit rooting. + * This has two benefits. First, when several such functions call each other + * then redundant rooting of multiple copies of the GC thing can be avoided. + * Second, if the caller does not pass a rooted value a compile error will be + * generated, which is quicker and easier to fix than when relying on a + * separate rooting analysis. + * + * - MutableHandle is a non-const reference to Rooted. It is used in the + * same way as Handle and includes a |set(const T &v)| method to allow + * updating the value of the referenced Rooted. A MutableHandle can be + * created from a Rooted by using |Rooted::operator&()|. + * + * In some cases the small performance overhead of exact rooting is too much. + * In these cases, try the following: + * + * - Move all Rooted above inner loops: this allows you to re-use the root + * on each iteration of the loop. + * + * - Pass Handle through your hot call stack to avoid re-rooting costs at + * every invocation. + * + * There also exists a set of RawT typedefs for modules without rooting + * concerns, such as the GC. Do not use these as they provide no rooting + * protection whatsoever. + * + * The following diagram explains the list of supported, implicit type + * conversions between classes of this family: + * + * RawT -----> Rooted ----> Handle + * | ^ + * | | + * | | + * +---> MutableHandle + * (via &) + * + * Currently all of these types implicit conversion to RawT. These are present + * only for the purpose of bootstrapping exact rooting and will be removed in + * the future (Bug 817164). + */ + +namespace js { + +class Module; + +template +struct RootMethods {}; + +template +class RootedBase {}; + +template +class HandleBase {}; + +template +class MutableHandleBase {}; + +/* + * js::NullPtr acts like a NULL pointer in contexts that require a Handle. + * + * Handle provides an implicit constructor for js::NullPtr so that, given: + * foo(Handle h); + * callers can simply write: + * foo(js::NullPtr()); + * which avoids creating a Rooted just to pass NULL. + * + * This is the SpiderMonkey internal variant. js::NullPtr should be used in + * preference to JS::NullPtr to avoid the GOT access required for JS_PUBLIC_API + * symbols. + */ +struct NullPtr +{ + static void * const constNullValue; +}; + +} /* namespace js */ + +namespace JS { + +template class Rooted; + +template class Handle; +template class MutableHandle; + +/* This is exposing internal state of the GC for inlining purposes. */ +JS_FRIEND_API(bool) isGCEnabled(); + +#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) +extern void +CheckStackRoots(JSContext *cx); +#endif + +/* + * JS::NullPtr acts like a NULL pointer in contexts that require a Handle. + * + * Handle provides an implicit constructor for JS::NullPtr so that, given: + * foo(Handle h); + * callers can simply write: + * foo(JS::NullPtr()); + * which avoids creating a Rooted just to pass NULL. + */ +struct JS_PUBLIC_API(NullPtr) +{ + static void * const constNullValue; +}; + +/* + * Reference to a T that has been rooted elsewhere. This is most useful + * as a parameter type, which guarantees that the T lvalue is properly + * rooted. See "Move GC Stack Rooting" above. + * + * If you want to add additional methods to Handle for a specific + * specialization, define a HandleBase specialization containing them. + */ +template +class Handle : public js::HandleBase +{ + friend class MutableHandle; + + public: + /* Creates a handle from a handle of a type convertible to T. */ + template + Handle(Handle handle, + typename mozilla::EnableIf::value, int>::Type dummy = 0) + { + ptr = reinterpret_cast(handle.address()); + } + + /* Create a handle for a NULL pointer. */ + Handle(js::NullPtr) { + MOZ_STATIC_ASSERT(mozilla::IsPointer::value, + "js::NullPtr overload not valid for non-pointer types"); + ptr = reinterpret_cast(&js::NullPtr::constNullValue); + } + + /* Create a handle for a NULL pointer. */ + Handle(JS::NullPtr) { + MOZ_STATIC_ASSERT(mozilla::IsPointer::value, + "JS::NullPtr overload not valid for non-pointer types"); + ptr = reinterpret_cast(&JS::NullPtr::constNullValue); + } + + Handle(MutableHandle handle) { + ptr = handle.address(); + } + + /* + * This may be called only if the location of the T is guaranteed + * to be marked (for some reason other than being a Rooted), + * e.g., if it is guaranteed to be reachable from an implicit root. + * + * Create a Handle from a raw location of a T. + */ + static Handle fromMarkedLocation(const T *p) { + Handle h; + h.ptr = p; + return h; + } + + /* + * Construct a handle from an explicitly rooted location. This is the + * normal way to create a handle, and normally happens implicitly. + */ + template + inline + Handle(Rooted &root, + typename mozilla::EnableIf::value, int>::Type dummy = 0); + + /* Construct a read only handle from a mutable handle. */ + template + inline + Handle(MutableHandle &root, + typename mozilla::EnableIf::value, int>::Type dummy = 0); + + const T *address() const { return ptr; } + T get() const { return *ptr; } + + operator T() const { return get(); } + T operator->() const { return get(); } + + bool operator!=(const T &other) { return *ptr != other; } + bool operator==(const T &other) { return *ptr == other; } + + private: + Handle() {} + + const T *ptr; + + template + void operator=(S v) MOZ_DELETE; +}; + +typedef Handle HandleObject; +typedef Handle HandleModule; +typedef Handle HandleFunction; +typedef Handle HandleScript; +typedef Handle HandleString; +typedef Handle HandleId; +typedef Handle HandleValue; + +/* + * Similar to a handle, but the underlying storage can be changed. This is + * useful for outparams. + * + * If you want to add additional methods to MutableHandle for a specific + * specialization, define a MutableHandleBase specialization containing + * them. + */ +template +class MutableHandle : public js::MutableHandleBase +{ + public: + inline MutableHandle(Rooted *root); + + void set(T v) { + JS_ASSERT(!js::RootMethods::poisoned(v)); + *ptr = v; + } + + /* + * This may be called only if the location of the T is guaranteed + * to be marked (for some reason other than being a Rooted), + * e.g., if it is guaranteed to be reachable from an implicit root. + * + * Create a MutableHandle from a raw location of a T. + */ + static MutableHandle fromMarkedLocation(T *p) { + MutableHandle h; + h.ptr = p; + return h; + } + + T *address() const { return ptr; } + T get() const { return *ptr; } + + operator T() const { return get(); } + T operator->() const { return get(); } + + private: + MutableHandle() {} + + T *ptr; + + template + void operator=(S v) MOZ_DELETE; +}; + +typedef MutableHandle MutableHandleObject; +typedef MutableHandle MutableHandleFunction; +typedef MutableHandle MutableHandleScript; +typedef MutableHandle MutableHandleString; +typedef MutableHandle MutableHandleId; +typedef MutableHandle MutableHandleValue; + +} /* namespace JS */ + +namespace js { + +/* + * Raw pointer used as documentation that a parameter does not need to be + * rooted. + */ +typedef JSObject * RawObject; +typedef JSString * RawString; +typedef jsid RawId; +typedef JS::Value RawValue; + +/* + * InternalHandle is a handle to an internal pointer into a gcthing. Use + * InternalHandle when you have a pointer to a direct field of a gcthing, or + * when you need a parameter type for something that *may* be a pointer to a + * direct field of a gcthing. + */ +template +class InternalHandle {}; + +template +class InternalHandle +{ + void * const *holder; + size_t offset; + + public: + /* + * Create an InternalHandle using a Handle to the gcthing containing the + * field in question, and a pointer to the field. + */ + template + InternalHandle(const JS::Handle &handle, T *field) + : holder((void**)handle.address()), offset(uintptr_t(field) - uintptr_t(handle.get())) + {} + + /* + * Create an InternalHandle to a field within a Rooted<>. + */ + template + InternalHandle(const JS::Rooted &root, T *field) + : holder((void**)root.address()), offset(uintptr_t(field) - uintptr_t(root.get())) + {} + + T *get() const { return reinterpret_cast(uintptr_t(*holder) + offset); } + + const T &operator*() const { return *get(); } + T *operator->() const { return get(); } + + static InternalHandle fromMarkedLocation(T *fieldPtr) { + return InternalHandle(fieldPtr); + } + + private: + /* + * Create an InternalHandle to something that is not a pointer to a + * gcthing, and so does not need to be rooted in the first place. Use these + * InternalHandles to pass pointers into functions that also need to accept + * regular InternalHandles to gcthing fields. + * + * Make this private to prevent accidental misuse; this is only for + * fromMarkedLocation(). + */ + InternalHandle(T *field) + : holder(reinterpret_cast(&js::NullPtr::constNullValue)), + offset(uintptr_t(field)) + {} +}; + +/* + * This macro simplifies forward declaration of a class and its matching raw-pointer. + */ +# define ForwardDeclare(type) \ + class type; \ + typedef type * Raw##type + +# define ForwardDeclareJS(type) \ + class JS##type; \ + namespace js { \ + typedef JS##type * Raw##type; \ + } \ + class JS##type + +/* + * By default, pointers should use the inheritance hierarchy to find their + * ThingRootKind. Some pointer types are explicitly set in jspubtd.h so that + * Rooted may be used without the class definition being available. + */ +template +struct RootKind +{ + static ThingRootKind rootKind() { return T::rootKind(); } +}; + +template +struct RootMethods +{ + static T *initial() { return NULL; } + static ThingRootKind kind() { return RootKind::rootKind(); } + static bool poisoned(T *v) { return JS::IsPoisonedPtr(v); } +}; + +} /* namespace js */ + +namespace JS { + +/* + * Local variable of type T whose value is always rooted. This is typically + * used for local variables, or for non-rooted values being passed to a + * function that requires a handle, e.g. Foo(Root(cx, x)). + * + * If you want to add additional methods to Rooted for a specific + * specialization, define a RootedBase specialization containing them. + */ +template +class Rooted : public js::RootedBase +{ + void init(JSContext *cxArg) { +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + js::ContextFriendFields *cx = js::ContextFriendFields::get(cxArg); + commonInit(cx->thingGCRooters); +#endif + } + + void init(js::PerThreadData *ptArg) { +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + js::PerThreadDataFriendFields *pt = js::PerThreadDataFriendFields::get(ptArg); + commonInit(pt->thingGCRooters); +#endif + } + + public: + Rooted(JSContext *cx + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : ptr(js::RootMethods::initial()) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + init(cx); + } + + Rooted(JSContext *cx, T initial + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : ptr(initial) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + init(cx); + } + + Rooted(js::PerThreadData *pt + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : ptr(js::RootMethods::initial()) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + init(pt); + } + + Rooted(js::PerThreadData *pt, T initial + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : ptr(initial) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + init(pt); + } + + ~Rooted() { +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + JS_ASSERT(*stack == reinterpret_cast*>(this)); + *stack = prev; +#endif + } + +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + Rooted *previous() { return prev; } +#endif + + operator T() const { return ptr; } + T operator->() const { return ptr; } + T *address() { return &ptr; } + const T *address() const { return &ptr; } + T &get() { return ptr; } + const T &get() const { return ptr; } + + T &operator=(T value) { + JS_ASSERT(!js::RootMethods::poisoned(value)); + ptr = value; + return ptr; + } + + T &operator=(const Rooted &value) { + ptr = value; + return ptr; + } + + bool operator!=(const T &other) { return ptr != other; } + bool operator==(const T &other) { return ptr == other; } + + private: + void commonInit(Rooted **thingGCRooters) { +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + js::ThingRootKind kind = js::RootMethods::kind(); + this->stack = &thingGCRooters[kind]; + this->prev = *stack; + *stack = reinterpret_cast*>(this); + + JS_ASSERT(!js::RootMethods::poisoned(ptr)); +#endif + } + +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + Rooted **stack, *prev; +#endif + +#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) + /* Has the rooting analysis ever scanned this Rooted's stack location? */ + friend void JS::CheckStackRoots(JSContext*); + bool scanned; +#endif + + /* + * |ptr| must be the last field in Rooted because the analysis treats all + * Rooted as Rooted during the analysis. See bug 829372. + */ + T ptr; + + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER + + Rooted(const Rooted &) MOZ_DELETE; +}; + +#if !(defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)) +// Defined in vm/String.h. +template <> +class Rooted; +#endif + +typedef Rooted RootedObject; +typedef Rooted RootedModule; +typedef Rooted RootedFunction; +typedef Rooted RootedScript; +typedef Rooted RootedString; +typedef Rooted RootedId; +typedef Rooted RootedValue; + +} /* namespace JS */ + +namespace js { + +/* + * Mark a stack location as a root for the rooting analysis, without actually + * rooting it in release builds. This should only be used for stack locations + * of GC things that cannot be relocated by a garbage collection, and that + * are definitely reachable via another path. + */ +class SkipRoot +{ +#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) + + SkipRoot **stack, *prev; + const uint8_t *start; + const uint8_t *end; + + template + void init(SkipRoot **head, const T *ptr, size_t count) { + this->stack = head; + this->prev = *stack; + *stack = this; + this->start = (const uint8_t *) ptr; + this->end = this->start + (sizeof(T) * count); + } + + public: + template + SkipRoot(JSContext *cx, const T *ptr, size_t count = 1 + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + { + init(&ContextFriendFields::get(cx)->skipGCRooters, ptr, count); + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + + template + SkipRoot(js::PerThreadData *ptd, const T *ptr, size_t count = 1 + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + { + PerThreadDataFriendFields *ptff = PerThreadDataFriendFields::get(ptd); + init(&ptff->skipGCRooters, ptr, count); + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + + ~SkipRoot() { + JS_ASSERT(*stack == this); + *stack = prev; + } + + SkipRoot *previous() { return prev; } + + bool contains(const uint8_t *v, size_t len) { + return v >= start && v + len <= end; + } + +#else /* DEBUG && JSGC_ROOT_ANALYSIS */ + + public: + template + SkipRoot(JSContext *cx, const T *ptr, size_t count = 1 + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + + template + SkipRoot(PerThreadData *ptd, const T *ptr, size_t count = 1 + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + +#endif /* DEBUG && JSGC_ROOT_ANALYSIS */ + + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER +}; + +/* Interface substitute for Rooted which does not root the variable's memory. */ +template +class FakeRooted : public RootedBase +{ + public: + FakeRooted(JSContext *cx + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : ptr(RootMethods::initial()) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + + FakeRooted(JSContext *cx, T initial + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : ptr(initial) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + + operator T() const { return ptr; } + T operator->() const { return ptr; } + T *address() { return &ptr; } + const T *address() const { return &ptr; } + T &get() { return ptr; } + const T &get() const { return ptr; } + + T &operator=(T value) { + JS_ASSERT(!RootMethods::poisoned(value)); + ptr = value; + return ptr; + } + + bool operator!=(const T &other) { return ptr != other; } + bool operator==(const T &other) { return ptr == other; } + + private: + T ptr; + + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER + + FakeRooted(const FakeRooted &) MOZ_DELETE; +}; + +/* Interface substitute for MutableHandle which is not required to point to rooted memory. */ +template +class FakeMutableHandle : public js::MutableHandleBase +{ + public: + FakeMutableHandle(T *t) { + ptr = t; + } + + FakeMutableHandle(FakeRooted *root) { + ptr = root->address(); + } + + void set(T v) { + JS_ASSERT(!js::RootMethods::poisoned(v)); + *ptr = v; + } + + T *address() const { return ptr; } + T get() const { return *ptr; } + + operator T() const { return get(); } + T operator->() const { return get(); } + + private: + FakeMutableHandle() {} + + T *ptr; + + template + void operator=(S v) MOZ_DELETE; +}; + +/* + * Types for a variable that either should or shouldn't be rooted, depending on + * the template parameter Rooted. Used for implementing functions that can + * operate on either rooted or unrooted data. + * + * The toHandle() and toMutableHandle() functions are for calling functions + * which require handle types and are only called in the CanGC case. These + * allow the calling code to type check. + */ +enum AllowGC { + NoGC = 0, + CanGC = 1 +}; +template +class MaybeRooted +{ +}; + +template class MaybeRooted +{ + public: + typedef JS::Handle HandleType; + typedef JS::Rooted RootType; + typedef JS::MutableHandle MutableHandleType; + + static inline JS::Handle toHandle(HandleType v) { + return v; + } + + static inline JS::MutableHandle toMutableHandle(MutableHandleType v) { + return v; + } +}; + +template class MaybeRooted +{ + public: + typedef T HandleType; + typedef FakeRooted RootType; + typedef FakeMutableHandle MutableHandleType; + + static inline JS::Handle toHandle(HandleType v) { + JS_NOT_REACHED("Bad conversion"); + return JS::Handle::fromMarkedLocation(NULL); + } + + static inline JS::MutableHandle toMutableHandle(MutableHandleType v) { + JS_NOT_REACHED("Bad conversion"); + return JS::MutableHandle::fromMarkedLocation(NULL); + } +}; + +} /* namespace js */ + +namespace JS { + +template template +inline +Handle::Handle(Rooted &root, + typename mozilla::EnableIf::value, int>::Type dummy) +{ + ptr = reinterpret_cast(root.address()); +} + +template template +inline +Handle::Handle(MutableHandle &root, + typename mozilla::EnableIf::value, int>::Type dummy) +{ + ptr = reinterpret_cast(root.address()); +} + +template +inline +MutableHandle::MutableHandle(Rooted *root) +{ + ptr = root->address(); +} + +} /* namespace JS */ + +namespace js { + +/* + * Hook for dynamic root analysis. Checks the native stack and poisons + * references to GC things which have not been rooted. + */ +inline void MaybeCheckStackRoots(JSContext *cx) +{ +#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) + JS::CheckStackRoots(cx); +#endif +} + +namespace gc { +struct Cell; +} /* namespace gc */ + +/* Base class for automatic read-only object rooting during compilation. */ +class CompilerRootNode +{ + protected: + CompilerRootNode(js::gc::Cell *ptr) : next(NULL), ptr_(ptr) {} + + public: + void **address() { return (void **)&ptr_; } + + public: + CompilerRootNode *next; + + protected: + js::gc::Cell *ptr_; +}; + +} /* namespace js */ + +ForwardDeclareJS(Script); +ForwardDeclareJS(Function); +ForwardDeclareJS(Object); + +#endif /* jsgc_root_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/TemplateLib.h b/scripting/javascript/spidermonkey-mac/include/js/TemplateLib.h new file mode 100644 index 0000000000..254c7fe752 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/TemplateLib.h @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_template_lib_h__ +#define js_template_lib_h__ + +#include "jstypes.h" + +/* + * Library of reusable template meta-functions (that is, functions on types and + * compile-time values). Meta-functions are placed inside the 'tl' namespace to + * avoid conflict with non-meta functions that logically have the same name + * (e.g., js::tl::Min vs. js::Min). + */ + +namespace js { +namespace tl { + +/* Compute min/max/clamp. */ +template struct Min { + static const size_t result = i < j ? i : j; +}; +template struct Max { + static const size_t result = i > j ? i : j; +}; +template struct Clamp { + static const size_t result = i < min ? min : (i > max ? max : i); +}; + +/* Compute x^y. */ +template struct Pow { + static const size_t result = x * Pow::result; +}; +template struct Pow { + static const size_t result = 1; +}; + +/* Compute floor(log2(i)). */ +template struct FloorLog2 { + static const size_t result = 1 + FloorLog2::result; +}; +template <> struct FloorLog2<0> { /* Error */ }; +template <> struct FloorLog2<1> { static const size_t result = 0; }; + +/* Compute ceiling(log2(i)). */ +template struct CeilingLog2 { + static const size_t result = FloorLog2<2 * i - 1>::result; +}; + +/* Round up to the nearest power of 2. */ +template struct RoundUpPow2 { + static const size_t result = size_t(1) << CeilingLog2::result; +}; +template <> struct RoundUpPow2<0> { + static const size_t result = 1; +}; + +/* Compute the number of bits in the given unsigned type. */ +template struct BitSize { + static const size_t result = sizeof(T) * JS_BITS_PER_BYTE; +}; + +/* + * Produce an N-bit mask, where N <= BitSize::result. Handle the + * language-undefined edge case when N = BitSize::result. + */ +template struct NBitMask { + // Assert the precondition. On success this evaluates to 0. Otherwise it + // triggers divide-by-zero at compile time: a guaranteed compile error in + // C++11, and usually one in C++98. Add this value to |result| to assure + // its computation. + static const size_t checkPrecondition = 0 / size_t(N < BitSize::result); + static const size_t result = (size_t(1) << N) - 1 + checkPrecondition; +}; +template <> struct NBitMask::result> { + static const size_t result = size_t(-1); +}; + +/* + * For the unsigned integral type size_t, compute a mask M for N such that + * for all X, !(X & M) implies X * N will not overflow (w.r.t size_t) + */ +template struct MulOverflowMask { + static const size_t result = + ~NBitMask::result - CeilingLog2::result>::result; +}; +template <> struct MulOverflowMask<0> { /* Error */ }; +template <> struct MulOverflowMask<1> { static const size_t result = 0; }; + +/* + * Generate a mask for T such that if (X & sUnsafeRangeSizeMask), an X-sized + * array of T's is big enough to cause a ptrdiff_t overflow when subtracting + * a pointer to the end of the array from the beginning. + */ +template struct UnsafeRangeSizeMask { + /* + * The '2' factor means the top bit is clear, sizeof(T) converts from + * units of elements to bytes. + */ + static const size_t result = MulOverflowMask<2 * sizeof(T)>::result; +}; + +/* Return T stripped of any const-ness. */ +template struct StripConst { typedef T result; }; +template struct StripConst { typedef T result; }; + +template struct If { static const T result = v1; }; +template struct If { static const T result = v2; }; + +/* + * Traits class for identifying types that are implicitly barriered. + */ +template struct IsRelocatableHeapType { static const bool result = true; }; + +} /* namespace tl */ +} /* namespace js */ + +#endif /* js_template_lib_h__ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/Utility.h b/scripting/javascript/spidermonkey-mac/include/js/Utility.h new file mode 100644 index 0000000000..deceff2488 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/Utility.h @@ -0,0 +1,868 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_utility_h__ +#define js_utility_h__ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/Scoped.h" + +#include +#include + +#ifdef JS_OOM_DO_BACKTRACES +#include +#include +#endif + +#include "jstypes.h" + +#include "js/TemplateLib.h" + +/* The public JS engine namespace. */ +namespace JS {} + +/* The mozilla-shared reusable template/utility namespace. */ +namespace mozilla {} + +/* The private JS engine namespace. */ +namespace js {} + +/* + * Pattern used to overwrite freed memory. If you are accessing an object with + * this pattern, you probably have a dangling pointer. + */ +#define JS_FREE_PATTERN 0xDA + +#define JS_ASSERT(expr) MOZ_ASSERT(expr) +#define JS_ASSERT_IF(cond, expr) MOZ_ASSERT_IF(cond, expr) +#define JS_NOT_REACHED(reason) MOZ_NOT_REACHED(reason) +#define JS_ALWAYS_TRUE(expr) MOZ_ALWAYS_TRUE(expr) +#define JS_ALWAYS_FALSE(expr) MOZ_ALWAYS_FALSE(expr) + +#ifdef DEBUG +# ifdef JS_THREADSAFE +# define JS_THREADSAFE_ASSERT(expr) JS_ASSERT(expr) +# else +# define JS_THREADSAFE_ASSERT(expr) ((void) 0) +# endif +#else +# define JS_THREADSAFE_ASSERT(expr) ((void) 0) +#endif + +#if defined(DEBUG) +# define JS_DIAGNOSTICS_ASSERT(expr) MOZ_ASSERT(expr) +#elif defined(JS_CRASH_DIAGNOSTICS) +# define JS_DIAGNOSTICS_ASSERT(expr) do { if (!(expr)) MOZ_CRASH(); } while(0) +#else +# define JS_DIAGNOSTICS_ASSERT(expr) ((void) 0) +#endif + +#define JS_STATIC_ASSERT(cond) MOZ_STATIC_ASSERT(cond, "JS_STATIC_ASSERT") +#define JS_STATIC_ASSERT_IF(cond, expr) MOZ_STATIC_ASSERT_IF(cond, expr, "JS_STATIC_ASSERT_IF") + +extern MOZ_NORETURN JS_PUBLIC_API(void) +JS_Assert(const char *s, const char *file, int ln); + +/* + * Abort the process in a non-graceful manner. This will cause a core file, + * call to the debugger or other moral equivalent as well as causing the + * entire process to stop. + */ +extern JS_PUBLIC_API(void) JS_Abort(void); + +/* + * Custom allocator support for SpiderMonkey + */ +#if defined JS_USE_CUSTOM_ALLOCATOR +# include "jscustomallocator.h" +#else +# ifdef DEBUG +/* + * In order to test OOM conditions, when the shell command-line option + * |-A NUM| is passed, we fail continuously after the NUM'th allocation. + */ +extern JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations; /* set from shell/js.cpp */ +extern JS_PUBLIC_DATA(uint32_t) OOM_counter; /* data race, who cares. */ + +#ifdef JS_OOM_DO_BACKTRACES +#define JS_OOM_BACKTRACE_SIZE 32 +static JS_ALWAYS_INLINE void +PrintBacktrace() +{ + void* OOM_trace[JS_OOM_BACKTRACE_SIZE]; + char** OOM_traceSymbols = NULL; + int32_t OOM_traceSize = 0; + int32_t OOM_traceIdx = 0; + OOM_traceSize = backtrace(OOM_trace, JS_OOM_BACKTRACE_SIZE); + OOM_traceSymbols = backtrace_symbols(OOM_trace, OOM_traceSize); + + if (!OOM_traceSymbols) + return; + + for (OOM_traceIdx = 0; OOM_traceIdx < OOM_traceSize; ++OOM_traceIdx) { + fprintf(stderr, "#%d %s\n", OOM_traceIdx, OOM_traceSymbols[OOM_traceIdx]); + } + + free(OOM_traceSymbols); +} + +#define JS_OOM_EMIT_BACKTRACE() \ + do {\ + fprintf(stderr, "Forcing artificial memory allocation function failure:\n");\ + PrintBacktrace();\ + } while (0) +# else +# define JS_OOM_EMIT_BACKTRACE() do {} while(0) +#endif /* JS_OOM_DO_BACKTRACES */ + +# define JS_OOM_POSSIBLY_FAIL() \ + do \ + { \ + if (++OOM_counter > OOM_maxAllocations) { \ + JS_OOM_EMIT_BACKTRACE();\ + return NULL; \ + } \ + } while (0) + +# define JS_OOM_POSSIBLY_FAIL_REPORT(cx) \ + do \ + { \ + if (++OOM_counter > OOM_maxAllocations) { \ + JS_OOM_EMIT_BACKTRACE();\ + js_ReportOutOfMemory(cx);\ + return NULL; \ + } \ + } while (0) + +# else +# define JS_OOM_POSSIBLY_FAIL() do {} while(0) +# define JS_OOM_POSSIBLY_FAIL_REPORT(cx) do {} while(0) +# endif /* DEBUG */ + +static JS_INLINE void* js_malloc(size_t bytes) +{ + JS_OOM_POSSIBLY_FAIL(); + return malloc(bytes); +} + +static JS_INLINE void* js_calloc(size_t bytes) +{ + JS_OOM_POSSIBLY_FAIL(); + return calloc(bytes, 1); +} + +static JS_INLINE void* js_realloc(void* p, size_t bytes) +{ + JS_OOM_POSSIBLY_FAIL(); + return realloc(p, bytes); +} + +static JS_INLINE void js_free(void* p) +{ + free(p); +} +#endif/* JS_USE_CUSTOM_ALLOCATOR */ + +JS_BEGIN_EXTERN_C + +/* + * Replace bit-scanning code sequences with CPU-specific instructions to + * speedup calculations of ceiling/floor log2. + * + * With GCC 3.4 or later we can use __builtin_clz for that, see bug 327129. + * + * SWS: Added MSVC intrinsic bitscan support. See bugs 349364 and 356856. + */ +#if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) + +unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask); +unsigned char _BitScanReverse(unsigned long * Index, unsigned long Mask); +# pragma intrinsic(_BitScanForward,_BitScanReverse) + +__forceinline static int +__BitScanForward32(unsigned int val) +{ + unsigned long idx; + + _BitScanForward(&idx, (unsigned long)val); + return (int)idx; +} +__forceinline static int +__BitScanReverse32(unsigned int val) +{ + unsigned long idx; + + _BitScanReverse(&idx, (unsigned long)val); + return (int)(31-idx); +} +# define js_bitscan_ctz32(val) __BitScanForward32(val) +# define js_bitscan_clz32(val) __BitScanReverse32(val) +# define JS_HAS_BUILTIN_BITSCAN32 + +#if defined(_M_AMD64) || defined(_M_X64) +unsigned char _BitScanForward64(unsigned long * Index, unsigned __int64 Mask); +unsigned char _BitScanReverse64(unsigned long * Index, unsigned __int64 Mask); +# pragma intrinsic(_BitScanForward64,_BitScanReverse64) + +__forceinline static int +__BitScanForward64(unsigned __int64 val) +{ + unsigned long idx; + + _BitScanForward64(&idx, val); + return (int)idx; +} +__forceinline static int +__BitScanReverse64(unsigned __int64 val) +{ + unsigned long idx; + + _BitScanReverse64(&idx, val); + return (int)(63-idx); +} +# define js_bitscan_ctz64(val) __BitScanForward64(val) +# define js_bitscan_clz64(val) __BitScanReverse64(val) +# define JS_HAS_BUILTIN_BITSCAN64 +#endif +#elif (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + +# define js_bitscan_ctz32(val) __builtin_ctz(val) +# define js_bitscan_clz32(val) __builtin_clz(val) +# define JS_HAS_BUILTIN_BITSCAN32 +# if (JS_BYTES_PER_WORD == 8) +# define js_bitscan_ctz64(val) __builtin_ctzll(val) +# define js_bitscan_clz64(val) __builtin_clzll(val) +# define JS_HAS_BUILTIN_BITSCAN64 +# endif + +#endif + +/* +** Macro version of JS_CeilingLog2: Compute the log of the least power of +** 2 greater than or equal to _n. The result is returned in _log2. +*/ +#ifdef JS_HAS_BUILTIN_BITSCAN32 +/* + * Use intrinsic function or count-leading-zeros to calculate ceil(log2(_n)). + * The macro checks for "n <= 1" and not "n != 0" as js_bitscan_clz32(0) is + * undefined. + */ +# define JS_CEILING_LOG2(_log2,_n) \ + JS_BEGIN_MACRO \ + unsigned int j_ = (unsigned int)(_n); \ + (_log2) = (j_ <= 1 ? 0 : 32 - js_bitscan_clz32(j_ - 1)); \ + JS_END_MACRO +#else +# define JS_CEILING_LOG2(_log2,_n) \ + JS_BEGIN_MACRO \ + uint32_t j_ = (uint32_t)(_n); \ + (_log2) = 0; \ + if ((j_) & ((j_)-1)) \ + (_log2) += 1; \ + if ((j_) >> 16) \ + (_log2) += 16, (j_) >>= 16; \ + if ((j_) >> 8) \ + (_log2) += 8, (j_) >>= 8; \ + if ((j_) >> 4) \ + (_log2) += 4, (j_) >>= 4; \ + if ((j_) >> 2) \ + (_log2) += 2, (j_) >>= 2; \ + if ((j_) >> 1) \ + (_log2) += 1; \ + JS_END_MACRO +#endif + +/* +** Macro version of JS_FloorLog2: Compute the log of the greatest power of +** 2 less than or equal to _n. The result is returned in _log2. +** +** This is equivalent to finding the highest set bit in the word. +*/ +#ifdef JS_HAS_BUILTIN_BITSCAN32 +/* + * Use js_bitscan_clz32 or count-leading-zeros to calculate floor(log2(_n)). + * Since js_bitscan_clz32(0) is undefined, the macro set the loweset bit to 1 + * to ensure 0 result when _n == 0. + */ +# define JS_FLOOR_LOG2(_log2,_n) \ + JS_BEGIN_MACRO \ + (_log2) = 31 - js_bitscan_clz32(((unsigned int)(_n)) | 1); \ + JS_END_MACRO +#else +# define JS_FLOOR_LOG2(_log2,_n) \ + JS_BEGIN_MACRO \ + uint32_t j_ = (uint32_t)(_n); \ + (_log2) = 0; \ + if ((j_) >> 16) \ + (_log2) += 16, (j_) >>= 16; \ + if ((j_) >> 8) \ + (_log2) += 8, (j_) >>= 8; \ + if ((j_) >> 4) \ + (_log2) += 4, (j_) >>= 4; \ + if ((j_) >> 2) \ + (_log2) += 2, (j_) >>= 2; \ + if ((j_) >> 1) \ + (_log2) += 1; \ + JS_END_MACRO +#endif + +#if JS_BYTES_PER_WORD == 4 +# ifdef JS_HAS_BUILTIN_BITSCAN32 +# define js_FloorLog2wImpl(n) \ + ((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz32(n))) +# else +JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n); +# endif +#elif JS_BYTES_PER_WORD == 8 +# ifdef JS_HAS_BUILTIN_BITSCAN64 +# define js_FloorLog2wImpl(n) \ + ((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz64(n))) +# else +JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n); +# endif +#else +# error "NOT SUPPORTED" +#endif + +JS_END_EXTERN_C + +/* + * Internal function. + * Compute the log of the least power of 2 greater than or equal to n. This is + * a version of JS_CeilingLog2 that operates on unsigned integers with + * CPU-dependant size. + */ +#define JS_CEILING_LOG2W(n) ((n) <= 1 ? 0 : 1 + JS_FLOOR_LOG2W((n) - 1)) + +/* + * Internal function. + * Compute the log of the greatest power of 2 less than or equal to n. + * This is a version of JS_FloorLog2 that operates on unsigned integers with + * CPU-dependant size and requires that n != 0. + */ +static MOZ_ALWAYS_INLINE size_t +JS_FLOOR_LOG2W(size_t n) +{ + JS_ASSERT(n != 0); + return js_FloorLog2wImpl(n); +} + +/* + * JS_ROTATE_LEFT32 + * + * There is no rotate operation in the C Language so the construct (a << 4) | + * (a >> 28) is used instead. Most compilers convert this to a rotate + * instruction but some versions of MSVC don't without a little help. To get + * MSVC to generate a rotate instruction, we have to use the _rotl intrinsic + * and use a pragma to make _rotl inline. + * + * MSVC in VS2005 will do an inline rotate instruction on the above construct. + */ +#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \ + defined(_M_X64)) +#include +#pragma intrinsic(_rotl) +#define JS_ROTATE_LEFT32(a, bits) _rotl(a, bits) +#else +#define JS_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits)))) +#endif + +#include + +/* + * Low-level memory management in SpiderMonkey: + * + * ** Do not use the standard malloc/free/realloc: SpiderMonkey allows these + * to be redefined (via JS_USE_CUSTOM_ALLOCATOR) and Gecko even #define's + * these symbols. + * + * ** Do not use the builtin C++ operator new and delete: these throw on + * error and we cannot override them not to. + * + * Allocation: + * + * - If the lifetime of the allocation is tied to the lifetime of a GC-thing + * (that is, finalizing the GC-thing will free the allocation), call one of + * the following functions: + * + * JSContext::{malloc_,realloc_,calloc_,new_} + * JSRuntime::{malloc_,realloc_,calloc_,new_} + * + * These functions accumulate the number of bytes allocated which is used as + * part of the GC-triggering heuristic. + * + * The difference between the JSContext and JSRuntime versions is that the + * cx version reports an out-of-memory error on OOM. (This follows from the + * general SpiderMonkey idiom that a JSContext-taking function reports its + * own errors.) + * + * - Otherwise, use js_malloc/js_realloc/js_calloc/js_free/js_new + * + * Deallocation: + * + * - Ordinarily, use js_free/js_delete. + * + * - For deallocations during GC finalization, use one of the following + * operations on the FreeOp provided to the finalizer: + * + * FreeOp::{free_,delete_} + * + * The advantage of these operations is that the memory is batched and freed + * on another thread. + */ + +#define JS_NEW_BODY(allocator, t, parms) \ + void *memory = allocator(sizeof(t)); \ + return memory ? new(memory) t parms : NULL; + +/* + * Given a class which should provide 'new' methods, add + * JS_DECLARE_NEW_METHODS (see JSContext for a usage example). This + * adds news with up to 12 parameters. Add more versions of new below if + * you need more than 12 parameters. + * + * Note: Do not add a ; at the end of a use of JS_DECLARE_NEW_METHODS, + * or the build will break. + */ +#define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS)\ + template \ + QUALIFIERS T *NEWNAME() {\ + JS_NEW_BODY(ALLOCATOR, T, ())\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11))\ + }\ +\ + template \ + QUALIFIERS T *NEWNAME(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12) {\ + JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12))\ + }\ + +JS_DECLARE_NEW_METHODS(js_new, js_malloc, static JS_ALWAYS_INLINE) + +template +static JS_ALWAYS_INLINE void +js_delete(T *p) +{ + if (p) { + p->~T(); + js_free(p); + } +} + +template +static JS_ALWAYS_INLINE T * +js_pod_malloc() +{ + return (T *)js_malloc(sizeof(T)); +} + +template +static JS_ALWAYS_INLINE T * +js_pod_calloc() +{ + return (T *)js_calloc(sizeof(T)); +} + +template +static JS_ALWAYS_INLINE T * +js_pod_malloc(size_t numElems) +{ + if (numElems & js::tl::MulOverflowMask::result) + return NULL; + return (T *)js_malloc(numElems * sizeof(T)); +} + +template +static JS_ALWAYS_INLINE T * +js_pod_calloc(size_t numElems) +{ + if (numElems & js::tl::MulOverflowMask::result) + return NULL; + return (T *)js_calloc(numElems * sizeof(T)); +} + +namespace js { + +template +struct ScopedFreePtrTraits +{ + typedef T* type; + static T* empty() { return NULL; } + static void release(T* ptr) { js_free(ptr); } +}; +SCOPED_TEMPLATE(ScopedJSFreePtr, ScopedFreePtrTraits) + +template +struct ScopedDeletePtrTraits : public ScopedFreePtrTraits +{ + static void release(T *ptr) { js_delete(ptr); } +}; +SCOPED_TEMPLATE(ScopedJSDeletePtr, ScopedDeletePtrTraits) + +template +struct ScopedReleasePtrTraits : public ScopedFreePtrTraits +{ + static void release(T *ptr) { if (ptr) ptr->release(); } +}; +SCOPED_TEMPLATE(ScopedReleasePtr, ScopedReleasePtrTraits) + +} /* namespace js */ + +namespace js { + +/* + * "Move" References + * + * Some types can be copied much more efficiently if we know the original's + * value need not be preserved --- that is, if we are doing a "move", not a + * "copy". For example, if we have: + * + * Vector u; + * Vector v(u); + * + * the constructor for v must apply a copy constructor to each element of u --- + * taking time linear in the length of u. However, if we know we will not need u + * any more once v has been initialized, then we could initialize v very + * efficiently simply by stealing u's dynamically allocated buffer and giving it + * to v --- a constant-time operation, regardless of the size of u. + * + * Moves often appear in container implementations. For example, when we append + * to a vector, we may need to resize its buffer. This entails moving each of + * its extant elements from the old, smaller buffer to the new, larger buffer. + * But once the elements have been migrated, we're just going to throw away the + * old buffer; we don't care if they still have their values. So if the vector's + * element type can implement "move" more efficiently than "copy", the vector + * resizing should by all means use a "move" operation. Hash tables also need to + * be resized. + * + * The details of the optimization, and whether it's worth applying, vary from + * one type to the next. And while some constructor calls are moves, many really + * are copies, and can't be optimized this way. So we need: + * + * 1) a way for a particular invocation of a copy constructor to say that it's + * really a move, and that the value of the original isn't important + * afterwards (althought it must still be safe to destroy); and + * + * 2) a way for a type (like Vector) to announce that it can be moved more + * efficiently than it can be copied, and provide an implementation of that + * move operation. + * + * The Move(T &) function takes a reference to a T, and returns an MoveRef + * referring to the same value; that's 1). An MoveRef is simply a reference + * to a T, annotated to say that a copy constructor applied to it may move that + * T, instead of copying it. Finally, a constructor that accepts an MoveRef + * should perform a more efficient move, instead of a copy, providing 2). + * + * So, where we might define a copy constructor for a class C like this: + * + * C(const C &rhs) { ... copy rhs to this ... } + * + * we would declare a move constructor like this: + * + * C(MoveRef rhs) { ... move rhs to this ... } + * + * And where we might perform a copy like this: + * + * C c2(c1); + * + * we would perform a move like this: + * + * C c2(Move(c1)) + * + * Note that MoveRef implicitly converts to T &, so you can pass an + * MoveRef to an ordinary copy constructor for a type that doesn't support a + * special move constructor, and you'll just get a copy. This means that + * templates can use Move whenever they know they won't use the original value + * any more, even if they're not sure whether the type at hand has a specialized + * move constructor. If it doesn't, the MoveRef will just convert to a T &, + * and the ordinary copy constructor will apply. + * + * A class with a move constructor can also provide a move assignment operator, + * which runs this's destructor, and then applies the move constructor to + * *this's memory. A typical definition: + * + * C &operator=(MoveRef rhs) { + * this->~C(); + * new(this) C(rhs); + * return *this; + * } + * + * With that in place, one can write move assignments like this: + * + * c2 = Move(c1); + * + * This destroys c1, moves c1's value to c2, and leaves c1 in an undefined but + * destructible state. + * + * This header file defines MoveRef and Move in the js namespace. It's up to + * individual containers to annotate moves as such, by calling Move; and it's up + * to individual types to define move constructors. + * + * One hint: if you're writing a move constructor where the type has members + * that should be moved themselves, it's much nicer to write this: + * + * C(MoveRef c) : x(c->x), y(c->y) { } + * + * than the equivalent: + * + * C(MoveRef c) { new(&x) X(c->x); new(&y) Y(c->y); } + * + * especially since GNU C++ fails to notice that this does indeed initialize x + * and y, which may matter if they're const. + */ +template +class MoveRef { + public: + typedef T Referent; + explicit MoveRef(T &t) : pointer(&t) { } + T &operator*() const { return *pointer; } + T *operator->() const { return pointer; } + operator T& () const { return *pointer; } + private: + T *pointer; +}; + +template +MoveRef Move(T &t) { return MoveRef(t); } + +template +MoveRef Move(const T &t) { return MoveRef(const_cast(t)); } + +/* Useful for implementing containers that assert non-reentrancy */ +class ReentrancyGuard +{ + /* ReentrancyGuard is not copyable. */ + ReentrancyGuard(const ReentrancyGuard &); + void operator=(const ReentrancyGuard &); + +#ifdef DEBUG + bool &entered; +#endif + public: + template +#ifdef DEBUG + ReentrancyGuard(T &obj) + : entered(obj.entered) +#else + ReentrancyGuard(T &/*obj*/) +#endif + { +#ifdef DEBUG + JS_ASSERT(!entered); + entered = true; +#endif + } + ~ReentrancyGuard() + { +#ifdef DEBUG + entered = false; +#endif + } +}; + +template +JS_ALWAYS_INLINE static void +Swap(T &t, T &u) +{ + T tmp(Move(t)); + t = Move(u); + u = Move(tmp); +} + +/* + * Round x up to the nearest power of 2. This function assumes that the most + * significant bit of x is not set, which would lead to overflow. + */ +JS_ALWAYS_INLINE size_t +RoundUpPow2(size_t x) +{ + return size_t(1) << JS_CEILING_LOG2W(x); +} + +/* Integral types for all hash functions. */ +typedef uint32_t HashNumber; +const unsigned HashNumberSizeBits = 32; + +namespace detail { + +/* + * Given a raw hash code, h, return a number that can be used to select a hash + * bucket. + * + * This function aims to produce as uniform an output distribution as possible, + * especially in the most significant (leftmost) bits, even though the input + * distribution may be highly nonrandom, given the constraints that this must + * be deterministic and quick to compute. + * + * Since the leftmost bits of the result are best, the hash bucket index is + * computed by doing ScrambleHashCode(h) / (2^32/N) or the equivalent + * right-shift, not ScrambleHashCode(h) % N or the equivalent bit-mask. + * + * FIXME: OrderedHashTable uses a bit-mask; see bug 775896. + */ +inline HashNumber +ScrambleHashCode(HashNumber h) +{ + /* + * Simply returning h would not cause any hash tables to produce wrong + * answers. But it can produce pathologically bad performance: The caller + * right-shifts the result, keeping only the highest bits. The high bits of + * hash codes are very often completely entropy-free. (So are the lowest + * bits.) + * + * So we use Fibonacci hashing, as described in Knuth, The Art of Computer + * Programming, 6.4. This mixes all the bits of the input hash code h. + * + * The value of goldenRatio is taken from the hex + * expansion of the golden ratio, which starts 1.9E3779B9.... + * This value is especially good if values with consecutive hash codes + * are stored in a hash table; see Knuth for details. + */ + static const HashNumber goldenRatio = 0x9E3779B9U; + return h * goldenRatio; +} + +} /* namespace detail */ + +} /* namespace js */ + +namespace JS { + +/* + * Methods for poisoning GC heap pointer words and checking for poisoned words. + * These are in this file for use in Value methods and so forth. + * + * If the moving GC hazard analysis is in use and detects a non-rooted stack + * pointer to a GC thing, one byte of that pointer is poisoned to refer to an + * invalid location. For both 32 bit and 64 bit systems, the fourth byte of the + * pointer is overwritten, to reduce the likelihood of accidentally changing + * a live integer value. + */ + +inline void PoisonPtr(void *v) +{ +#if defined(JSGC_ROOT_ANALYSIS) && defined(DEBUG) + uint8_t *ptr = (uint8_t *) v + 3; + *ptr = JS_FREE_PATTERN; +#endif +} + +template +inline bool IsPoisonedPtr(T *v) +{ +#if defined(JSGC_ROOT_ANALYSIS) && defined(DEBUG) + uint32_t mask = uintptr_t(v) & 0xff000000; + return mask == uint32_t(JS_FREE_PATTERN << 24); +#else + return false; +#endif +} + +} + +/* + * This is SpiderMonkey's equivalent to |nsMallocSizeOfFun|. + */ +typedef size_t(*JSMallocSizeOfFun)(const void *p); + +/* sixgill annotation defines */ +#ifndef HAVE_STATIC_ANNOTATIONS +# define HAVE_STATIC_ANNOTATIONS +# ifdef XGILL_PLUGIN +# define STATIC_PRECONDITION(COND) __attribute__((precondition(#COND))) +# define STATIC_PRECONDITION_ASSUME(COND) __attribute__((precondition_assume(#COND))) +# define STATIC_POSTCONDITION(COND) __attribute__((postcondition(#COND))) +# define STATIC_POSTCONDITION_ASSUME(COND) __attribute__((postcondition_assume(#COND))) +# define STATIC_INVARIANT(COND) __attribute__((invariant(#COND))) +# define STATIC_INVARIANT_ASSUME(COND) __attribute__((invariant_assume(#COND))) +# define STATIC_PASTE2(X,Y) X ## Y +# define STATIC_PASTE1(X,Y) STATIC_PASTE2(X,Y) +# define STATIC_ASSERT(COND) \ + JS_BEGIN_MACRO \ + __attribute__((assert_static(#COND), unused)) \ + int STATIC_PASTE1(assert_static_, __COUNTER__); \ + JS_END_MACRO +# define STATIC_ASSUME(COND) \ + JS_BEGIN_MACRO \ + __attribute__((assume_static(#COND), unused)) \ + int STATIC_PASTE1(assume_static_, __COUNTER__); \ + JS_END_MACRO +# define STATIC_ASSERT_RUNTIME(COND) \ + JS_BEGIN_MACRO \ + __attribute__((assert_static_runtime(#COND), unused)) \ + int STATIC_PASTE1(assert_static_runtime_, __COUNTER__); \ + JS_END_MACRO +# else /* XGILL_PLUGIN */ +# define STATIC_PRECONDITION(COND) /* nothing */ +# define STATIC_PRECONDITION_ASSUME(COND) /* nothing */ +# define STATIC_POSTCONDITION(COND) /* nothing */ +# define STATIC_POSTCONDITION_ASSUME(COND) /* nothing */ +# define STATIC_INVARIANT(COND) /* nothing */ +# define STATIC_INVARIANT_ASSUME(COND) /* nothing */ +# define STATIC_ASSERT(COND) JS_BEGIN_MACRO /* nothing */ JS_END_MACRO +# define STATIC_ASSUME(COND) JS_BEGIN_MACRO /* nothing */ JS_END_MACRO +# define STATIC_ASSERT_RUNTIME(COND) JS_BEGIN_MACRO /* nothing */ JS_END_MACRO +# endif /* XGILL_PLUGIN */ +# define STATIC_SKIP_INFERENCE STATIC_INVARIANT(skip_inference()) +#endif /* HAVE_STATIC_ANNOTATIONS */ + +#endif /* js_utility_h__ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/Value.h b/scripting/javascript/spidermonkey-mac/include/js/Value.h new file mode 100644 index 0000000000..a9a7bfd400 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/Value.h @@ -0,0 +1,1765 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* JS::Value implementation. */ + +#ifndef js_Value_h___ +#define js_Value_h___ + +#include "mozilla/Attributes.h" +#include "mozilla/FloatingPoint.h" +#include "mozilla/Likely.h" + +#include /* for std::numeric_limits */ + +#include "js/Anchor.h" +#include "js/RootingAPI.h" +#include "js/Utility.h" + +namespace JS { class Value; } + +/* JS::Value can store a full int32_t. */ +#define JSVAL_INT_BITS 32 +#define JSVAL_INT_MIN ((int32_t)0x80000000) +#define JSVAL_INT_MAX ((int32_t)0x7fffffff) + +/* + * Try to get jsvals 64-bit aligned. We could almost assert that all values are + * aligned, but MSVC and GCC occasionally break alignment. + */ +#if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__) +# define JSVAL_ALIGNMENT __attribute__((aligned (8))) +#elif defined(_MSC_VER) + /* + * Structs can be aligned with MSVC, but not if they are used as parameters, + * so we just don't try to align. + */ +# define JSVAL_ALIGNMENT +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# define JSVAL_ALIGNMENT +#elif defined(__HP_cc) || defined(__HP_aCC) +# define JSVAL_ALIGNMENT +#endif + +#if JS_BITS_PER_WORD == 64 +# define JSVAL_TAG_SHIFT 47 +#endif + +/* + * We try to use enums so that printing a jsval_layout in the debugger shows + * nice symbolic type tags, however we can only do this when we can force the + * underlying type of the enum to be the desired size. + */ +#if defined(__cplusplus) && !defined(__SUNPRO_CC) && !defined(__xlC__) + +#if defined(_MSC_VER) +# define JS_ENUM_HEADER(id, type) enum id : type +# define JS_ENUM_FOOTER(id) +#else +# define JS_ENUM_HEADER(id, type) enum id +# define JS_ENUM_FOOTER(id) __attribute__((packed)) +#endif + +/* Remember to propagate changes to the C defines below. */ +JS_ENUM_HEADER(JSValueType, uint8_t) +{ + JSVAL_TYPE_DOUBLE = 0x00, + JSVAL_TYPE_INT32 = 0x01, + JSVAL_TYPE_UNDEFINED = 0x02, + JSVAL_TYPE_BOOLEAN = 0x03, + JSVAL_TYPE_MAGIC = 0x04, + JSVAL_TYPE_STRING = 0x05, + JSVAL_TYPE_NULL = 0x06, + JSVAL_TYPE_OBJECT = 0x07, + + /* These never appear in a jsval; they are only provided as an out-of-band value. */ + JSVAL_TYPE_UNKNOWN = 0x20, + JSVAL_TYPE_MISSING = 0x21 +} JS_ENUM_FOOTER(JSValueType); + +JS_STATIC_ASSERT(sizeof(JSValueType) == 1); + +#if JS_BITS_PER_WORD == 32 + +/* Remember to propagate changes to the C defines below. */ +JS_ENUM_HEADER(JSValueTag, uint32_t) +{ + JSVAL_TAG_CLEAR = 0xFFFFFF80, + JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32, + JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED, + JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING, + JSVAL_TAG_BOOLEAN = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN, + JSVAL_TAG_MAGIC = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC, + JSVAL_TAG_NULL = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL, + JSVAL_TAG_OBJECT = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT +} JS_ENUM_FOOTER(JSValueTag); + +JS_STATIC_ASSERT(sizeof(JSValueTag) == 4); + +#elif JS_BITS_PER_WORD == 64 + +/* Remember to propagate changes to the C defines below. */ +JS_ENUM_HEADER(JSValueTag, uint32_t) +{ + JSVAL_TAG_MAX_DOUBLE = 0x1FFF0, + JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32, + JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED, + JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING, + JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN, + JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC, + JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL, + JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT +} JS_ENUM_FOOTER(JSValueTag); + +JS_STATIC_ASSERT(sizeof(JSValueTag) == sizeof(uint32_t)); + +JS_ENUM_HEADER(JSValueShiftedTag, uint64_t) +{ + JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF), + JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) +} JS_ENUM_FOOTER(JSValueShiftedTag); + +JS_STATIC_ASSERT(sizeof(JSValueShiftedTag) == sizeof(uint64_t)); + +#endif + +#else /* defined(__cplusplus) */ + +typedef uint8_t JSValueType; +#define JSVAL_TYPE_DOUBLE ((uint8_t)0x00) +#define JSVAL_TYPE_INT32 ((uint8_t)0x01) +#define JSVAL_TYPE_UNDEFINED ((uint8_t)0x02) +#define JSVAL_TYPE_BOOLEAN ((uint8_t)0x03) +#define JSVAL_TYPE_MAGIC ((uint8_t)0x04) +#define JSVAL_TYPE_STRING ((uint8_t)0x05) +#define JSVAL_TYPE_NULL ((uint8_t)0x06) +#define JSVAL_TYPE_OBJECT ((uint8_t)0x07) +#define JSVAL_TYPE_UNKNOWN ((uint8_t)0x20) + +#if JS_BITS_PER_WORD == 32 + +typedef uint32_t JSValueTag; +#define JSVAL_TAG_CLEAR ((uint32_t)(0xFFFFFF80)) +#define JSVAL_TAG_INT32 ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32)) +#define JSVAL_TAG_UNDEFINED ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED)) +#define JSVAL_TAG_STRING ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING)) +#define JSVAL_TAG_BOOLEAN ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN)) +#define JSVAL_TAG_MAGIC ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC)) +#define JSVAL_TAG_NULL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL)) +#define JSVAL_TAG_OBJECT ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT)) + +#elif JS_BITS_PER_WORD == 64 + +typedef uint32_t JSValueTag; +#define JSVAL_TAG_MAX_DOUBLE ((uint32_t)(0x1FFF0)) +#define JSVAL_TAG_INT32 (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) +#define JSVAL_TAG_UNDEFINED (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED) +#define JSVAL_TAG_STRING (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING) +#define JSVAL_TAG_BOOLEAN (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) +#define JSVAL_TAG_MAGIC (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC) +#define JSVAL_TAG_NULL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) +#define JSVAL_TAG_OBJECT (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT) + +typedef uint64_t JSValueShiftedTag; +#define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF) +#define JSVAL_SHIFTED_TAG_INT32 (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_STRING (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_MAGIC (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_NULL (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_OBJECT (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) + +#endif /* JS_BITS_PER_WORD */ +#endif /* defined(__cplusplus) && !defined(__SUNPRO_CC) */ + +#define JSVAL_LOWER_INCL_TYPE_OF_OBJ_OR_NULL_SET JSVAL_TYPE_NULL +#define JSVAL_UPPER_EXCL_TYPE_OF_PRIMITIVE_SET JSVAL_TYPE_OBJECT +#define JSVAL_UPPER_INCL_TYPE_OF_NUMBER_SET JSVAL_TYPE_INT32 +#define JSVAL_LOWER_INCL_TYPE_OF_PTR_PAYLOAD_SET JSVAL_TYPE_MAGIC + +#if JS_BITS_PER_WORD == 32 + +#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type))) + +#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL +#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT +#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 +#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING + +#elif JS_BITS_PER_WORD == 64 + +#define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL +#define JSVAL_TAG_MASK 0xFFFF800000000000LL +#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type))) +#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT) + +#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL +#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT +#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 +#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING + +#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL +#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT +#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED +#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING + +#endif /* JS_BITS_PER_WORD */ + +typedef enum JSWhyMagic +{ + JS_ELEMENTS_HOLE, /* a hole in a native object's elements */ + JS_NATIVE_ENUMERATE, /* indicates that a custom enumerate hook forwarded + * to JS_EnumerateState, which really means the object can be + * enumerated like a native object. */ + JS_NO_ITER_VALUE, /* there is not a pending iterator value */ + JS_GENERATOR_CLOSING, /* exception value thrown when closing a generator */ + JS_NO_CONSTANT, /* compiler sentinel value */ + JS_THIS_POISON, /* used in debug builds to catch tracing errors */ + JS_ARG_POISON, /* used in debug builds to catch tracing errors */ + JS_SERIALIZE_NO_NODE, /* an empty subnode in the AST serializer */ + JS_LAZY_ARGUMENTS, /* lazy arguments value on the stack */ + JS_OPTIMIZED_ARGUMENTS, /* optimized-away 'arguments' value */ + JS_IS_CONSTRUCTING, /* magic value passed to natives to indicate construction */ + JS_OVERWRITTEN_CALLEE, /* arguments.callee has been overwritten */ + JS_FORWARD_TO_CALL_OBJECT, /* args object element stored in call object */ + JS_BLOCK_NEEDS_CLONE, /* value of static block object slot */ + JS_HASH_KEY_EMPTY, /* see class js::HashableValue */ + JS_ION_ERROR, /* error while running Ion code */ + JS_ION_BAILOUT, /* status code to signal EnterIon will OSR into Interpret */ + JS_GENERIC_MAGIC /* for local use */ +} JSWhyMagic; + +#if defined(IS_LITTLE_ENDIAN) +# if JS_BITS_PER_WORD == 32 +typedef union jsval_layout +{ + uint64_t asBits; + struct { + union { + int32_t i32; + uint32_t u32; + JSBool boo; + JSString *str; + JSObject *obj; + void *ptr; + JSWhyMagic why; + size_t word; + uintptr_t uintptr; + } payload; + JSValueTag tag; + } s; + double asDouble; + void *asPtr; +} JSVAL_ALIGNMENT jsval_layout; +# elif JS_BITS_PER_WORD == 64 +typedef union jsval_layout +{ + uint64_t asBits; +#if (!defined(_WIN64) && defined(__cplusplus)) + /* MSVC does not pack these correctly :-( */ + struct { + uint64_t payload47 : 47; + JSValueTag tag : 17; + } debugView; +#endif + struct { + union { + int32_t i32; + uint32_t u32; + JSWhyMagic why; + } payload; + } s; + double asDouble; + void *asPtr; + size_t asWord; + uintptr_t asUIntPtr; +} JSVAL_ALIGNMENT jsval_layout; +# endif /* JS_BITS_PER_WORD */ +#else /* defined(IS_LITTLE_ENDIAN) */ +# if JS_BITS_PER_WORD == 32 +typedef union jsval_layout +{ + uint64_t asBits; + struct { + JSValueTag tag; + union { + int32_t i32; + uint32_t u32; + JSBool boo; + JSString *str; + JSObject *obj; + void *ptr; + JSWhyMagic why; + size_t word; + uintptr_t uintptr; + } payload; + } s; + double asDouble; + void *asPtr; +} JSVAL_ALIGNMENT jsval_layout; +# elif JS_BITS_PER_WORD == 64 +typedef union jsval_layout +{ + uint64_t asBits; + struct { + JSValueTag tag : 17; + uint64_t payload47 : 47; + } debugView; + struct { + uint32_t padding; + union { + int32_t i32; + uint32_t u32; + JSWhyMagic why; + } payload; + } s; + double asDouble; + void *asPtr; + size_t asWord; + uintptr_t asUIntPtr; +} JSVAL_ALIGNMENT jsval_layout; +# endif /* JS_BITS_PER_WORD */ +#endif /* defined(IS_LITTLE_ENDIAN) */ + +JS_STATIC_ASSERT(sizeof(jsval_layout) == 8); + +#if JS_BITS_PER_WORD == 32 + +/* + * N.B. GCC, in some but not all cases, chooses to emit signed comparison of + * JSValueTag even though its underlying type has been forced to be uint32_t. + * Thus, all comparisons should explicitly cast operands to uint32_t. + */ + +static inline jsval_layout +BUILD_JSVAL(JSValueTag tag, uint32_t payload) +{ + jsval_layout l; + l.asBits = (((uint64_t)(uint32_t)tag) << 32) | payload; + return l; +} + +static inline JSBool +JSVAL_IS_DOUBLE_IMPL(jsval_layout l) +{ + return (uint32_t)l.s.tag <= (uint32_t)JSVAL_TAG_CLEAR; +} + +static inline jsval_layout +DOUBLE_TO_JSVAL_IMPL(double d) +{ + jsval_layout l; + l.asDouble = d; + MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); + return l; +} + +static inline JSBool +JSVAL_IS_INT32_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_INT32; +} + +static inline int32_t +JSVAL_TO_INT32_IMPL(jsval_layout l) +{ + return l.s.payload.i32; +} + +static inline jsval_layout +INT32_TO_JSVAL_IMPL(int32_t i) +{ + jsval_layout l; + l.s.tag = JSVAL_TAG_INT32; + l.s.payload.i32 = i; + return l; +} + +static inline JSBool +JSVAL_IS_NUMBER_IMPL(jsval_layout l) +{ + JSValueTag tag = l.s.tag; + MOZ_ASSERT(tag != JSVAL_TAG_CLEAR); + return (uint32_t)tag <= (uint32_t)JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET; +} + +static inline JSBool +JSVAL_IS_UNDEFINED_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_UNDEFINED; +} + +static inline JSBool +JSVAL_IS_STRING_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_STRING; +} + +static inline jsval_layout +STRING_TO_JSVAL_IMPL(JSString *str) +{ + jsval_layout l; + MOZ_ASSERT(str); + l.s.tag = JSVAL_TAG_STRING; + l.s.payload.str = str; + return l; +} + +static inline JSString * +JSVAL_TO_STRING_IMPL(jsval_layout l) +{ + return l.s.payload.str; +} + +static inline JSBool +JSVAL_IS_BOOLEAN_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_BOOLEAN; +} + +static inline JSBool +JSVAL_TO_BOOLEAN_IMPL(jsval_layout l) +{ + return l.s.payload.boo; +} + +static inline jsval_layout +BOOLEAN_TO_JSVAL_IMPL(JSBool b) +{ + jsval_layout l; + MOZ_ASSERT(b == JS_TRUE || b == JS_FALSE); + l.s.tag = JSVAL_TAG_BOOLEAN; + l.s.payload.boo = b; + return l; +} + +static inline JSBool +JSVAL_IS_MAGIC_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_MAGIC; +} + +static inline JSBool +JSVAL_IS_OBJECT_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_OBJECT; +} + +static inline JSBool +JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l) +{ + return (uint32_t)l.s.tag < (uint32_t)JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET; +} + +static inline JSBool +JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l) +{ + MOZ_ASSERT((uint32_t)l.s.tag <= (uint32_t)JSVAL_TAG_OBJECT); + return (uint32_t)l.s.tag >= (uint32_t)JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET; +} + +static inline JSObject * +JSVAL_TO_OBJECT_IMPL(jsval_layout l) +{ + return l.s.payload.obj; +} + +static inline jsval_layout +OBJECT_TO_JSVAL_IMPL(JSObject *obj) +{ + jsval_layout l; + MOZ_ASSERT(obj); + l.s.tag = JSVAL_TAG_OBJECT; + l.s.payload.obj = obj; + return l; +} + +static inline JSBool +JSVAL_IS_NULL_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_NULL; +} + +static inline jsval_layout +PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) +{ + jsval_layout l; + MOZ_ASSERT(((uint32_t)ptr & 1) == 0); + l.s.tag = (JSValueTag)0; + l.s.payload.ptr = ptr; + MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); + return l; +} + +static inline void * +JSVAL_TO_PRIVATE_PTR_IMPL(jsval_layout l) +{ + return l.s.payload.ptr; +} + +static inline JSBool +JSVAL_IS_GCTHING_IMPL(jsval_layout l) +{ + /* gcc sometimes generates signed < without explicit casts. */ + return (uint32_t)l.s.tag >= (uint32_t)JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET; +} + +static inline void * +JSVAL_TO_GCTHING_IMPL(jsval_layout l) +{ + return l.s.payload.ptr; +} + +static inline JSBool +JSVAL_IS_TRACEABLE_IMPL(jsval_layout l) +{ + return l.s.tag == JSVAL_TAG_STRING || l.s.tag == JSVAL_TAG_OBJECT; +} + +static inline uint32_t +JSVAL_TRACE_KIND_IMPL(jsval_layout l) +{ + return (uint32_t)(JSBool)JSVAL_IS_STRING_IMPL(l); +} + +static inline JSBool +JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32) +{ + return l.s.tag == JSVAL_TAG_INT32 && l.s.payload.i32 == i32; +} + +static inline JSBool +JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b) +{ + return (l.s.tag == JSVAL_TAG_BOOLEAN) && (l.s.payload.boo == b); +} + +static inline jsval_layout +MAGIC_TO_JSVAL_IMPL(JSWhyMagic why) +{ + jsval_layout l; + l.s.tag = JSVAL_TAG_MAGIC; + l.s.payload.why = why; + return l; +} + +static inline JSBool +JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs) +{ + JSValueTag ltag = lhs.s.tag, rtag = rhs.s.tag; + return ltag == rtag || (ltag < JSVAL_TAG_CLEAR && rtag < JSVAL_TAG_CLEAR); +} + +static inline JSValueType +JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l) +{ + uint32_t type = l.s.tag & 0xF; + MOZ_ASSERT(type > JSVAL_TYPE_DOUBLE); + return (JSValueType)type; +} + +#elif JS_BITS_PER_WORD == 64 + +static inline jsval_layout +BUILD_JSVAL(JSValueTag tag, uint64_t payload) +{ + jsval_layout l; + l.asBits = (((uint64_t)(uint32_t)tag) << JSVAL_TAG_SHIFT) | payload; + return l; +} + +static inline JSBool +JSVAL_IS_DOUBLE_IMPL(jsval_layout l) +{ + return l.asBits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE; +} + +static inline jsval_layout +DOUBLE_TO_JSVAL_IMPL(double d) +{ + jsval_layout l; + l.asDouble = d; + MOZ_ASSERT(l.asBits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE); + return l; +} + +static inline JSBool +JSVAL_IS_INT32_IMPL(jsval_layout l) +{ + return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_INT32; +} + +static inline int32_t +JSVAL_TO_INT32_IMPL(jsval_layout l) +{ + return (int32_t)l.asBits; +} + +static inline jsval_layout +INT32_TO_JSVAL_IMPL(int32_t i32) +{ + jsval_layout l; + l.asBits = ((uint64_t)(uint32_t)i32) | JSVAL_SHIFTED_TAG_INT32; + return l; +} + +static inline JSBool +JSVAL_IS_NUMBER_IMPL(jsval_layout l) +{ + return l.asBits < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET; +} + +static inline JSBool +JSVAL_IS_UNDEFINED_IMPL(jsval_layout l) +{ + return l.asBits == JSVAL_SHIFTED_TAG_UNDEFINED; +} + +static inline JSBool +JSVAL_IS_STRING_IMPL(jsval_layout l) +{ + return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_STRING; +} + +static inline jsval_layout +STRING_TO_JSVAL_IMPL(JSString *str) +{ + jsval_layout l; + uint64_t strBits = (uint64_t)str; + MOZ_ASSERT(str); + MOZ_ASSERT((strBits >> JSVAL_TAG_SHIFT) == 0); + l.asBits = strBits | JSVAL_SHIFTED_TAG_STRING; + return l; +} + +static inline JSString * +JSVAL_TO_STRING_IMPL(jsval_layout l) +{ + return (JSString *)(l.asBits & JSVAL_PAYLOAD_MASK); +} + +static inline JSBool +JSVAL_IS_BOOLEAN_IMPL(jsval_layout l) +{ + return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_BOOLEAN; +} + +static inline JSBool +JSVAL_TO_BOOLEAN_IMPL(jsval_layout l) +{ + return (JSBool)l.asBits; +} + +static inline jsval_layout +BOOLEAN_TO_JSVAL_IMPL(JSBool b) +{ + jsval_layout l; + MOZ_ASSERT(b == JS_TRUE || b == JS_FALSE); + l.asBits = ((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN; + return l; +} + +static inline JSBool +JSVAL_IS_MAGIC_IMPL(jsval_layout l) +{ + return (l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_MAGIC; +} + +static inline JSBool +JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l) +{ + return l.asBits < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET; +} + +static inline JSBool +JSVAL_IS_OBJECT_IMPL(jsval_layout l) +{ + MOZ_ASSERT((l.asBits >> JSVAL_TAG_SHIFT) <= JSVAL_SHIFTED_TAG_OBJECT); + return l.asBits >= JSVAL_SHIFTED_TAG_OBJECT; +} + +static inline JSBool +JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l) +{ + MOZ_ASSERT((l.asBits >> JSVAL_TAG_SHIFT) <= JSVAL_TAG_OBJECT); + return l.asBits >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET; +} + +static inline JSObject * +JSVAL_TO_OBJECT_IMPL(jsval_layout l) +{ + uint64_t ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; + MOZ_ASSERT((ptrBits & 0x7) == 0); + return (JSObject *)ptrBits; +} + +static inline jsval_layout +OBJECT_TO_JSVAL_IMPL(JSObject *obj) +{ + jsval_layout l; + uint64_t objBits = (uint64_t)obj; + MOZ_ASSERT(obj); + MOZ_ASSERT((objBits >> JSVAL_TAG_SHIFT) == 0); + l.asBits = objBits | JSVAL_SHIFTED_TAG_OBJECT; + return l; +} + +static inline JSBool +JSVAL_IS_NULL_IMPL(jsval_layout l) +{ + return l.asBits == JSVAL_SHIFTED_TAG_NULL; +} + +static inline JSBool +JSVAL_IS_GCTHING_IMPL(jsval_layout l) +{ + return l.asBits >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET; +} + +static inline void * +JSVAL_TO_GCTHING_IMPL(jsval_layout l) +{ + uint64_t ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; + MOZ_ASSERT((ptrBits & 0x7) == 0); + return (void *)ptrBits; +} + +static inline JSBool +JSVAL_IS_TRACEABLE_IMPL(jsval_layout l) +{ + return JSVAL_IS_GCTHING_IMPL(l) && !JSVAL_IS_NULL_IMPL(l); +} + +static inline uint32_t +JSVAL_TRACE_KIND_IMPL(jsval_layout l) +{ + return (uint32_t)(JSBool)!(JSVAL_IS_OBJECT_IMPL(l)); +} + +static inline jsval_layout +PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) +{ + jsval_layout l; + uint64_t ptrBits = (uint64_t)ptr; + MOZ_ASSERT((ptrBits & 1) == 0); + l.asBits = ptrBits >> 1; + MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); + return l; +} + +static inline void * +JSVAL_TO_PRIVATE_PTR_IMPL(jsval_layout l) +{ + MOZ_ASSERT((l.asBits & 0x8000000000000000LL) == 0); + return (void *)(l.asBits << 1); +} + +static inline JSBool +JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32) +{ + return l.asBits == (((uint64_t)(uint32_t)i32) | JSVAL_SHIFTED_TAG_INT32); +} + +static inline JSBool +JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b) +{ + return l.asBits == (((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN); +} + +static inline jsval_layout +MAGIC_TO_JSVAL_IMPL(JSWhyMagic why) +{ + jsval_layout l; + l.asBits = ((uint64_t)(uint32_t)why) | JSVAL_SHIFTED_TAG_MAGIC; + return l; +} + +static inline JSBool +JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs) +{ + uint64_t lbits = lhs.asBits, rbits = rhs.asBits; + return (lbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE && rbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE) || + (((lbits ^ rbits) & 0xFFFF800000000000LL) == 0); +} + +static inline JSValueType +JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l) +{ + uint64_t type = (l.asBits >> JSVAL_TAG_SHIFT) & 0xF; + MOZ_ASSERT(type > JSVAL_TYPE_DOUBLE); + return (JSValueType)type; +} + +#endif /* JS_BITS_PER_WORD */ + +static inline double +JS_CANONICALIZE_NAN(double d) +{ + if (MOZ_UNLIKELY(d != d)) { + jsval_layout l; + l.asBits = 0x7FF8000000000000LL; + return l.asDouble; + } + return d; +} + +static inline jsval_layout JSVAL_TO_IMPL(JS::Value v); +static inline JS::Value IMPL_TO_JSVAL(jsval_layout l); + +namespace JS { + +/* + * JS::Value is the interface for a single JavaScript Engine value. A few + * general notes on JS::Value: + * + * - JS::Value has setX() and isX() members for X in + * + * { Int32, Double, String, Boolean, Undefined, Null, Object, Magic } + * + * JS::Value also contains toX() for each of the non-singleton types. + * + * - Magic is a singleton type whose payload contains a JSWhyMagic "reason" for + * the magic value. By providing JSWhyMagic values when creating and checking + * for magic values, it is possible to assert, at runtime, that only magic + * values with the expected reason flow through a particular value. For + * example, if cx->exception has a magic value, the reason must be + * JS_GENERATOR_CLOSING. + * + * - The JS::Value operations are preferred. The JSVAL_* operations remain for + * compatibility; they may be removed at some point. These operations mostly + * provide similar functionality. But there are a few key differences. One + * is that JS::Value gives null a separate type. Thus + * + * JSVAL_IS_OBJECT(v) === v.isObjectOrNull() + * !JSVAL_IS_PRIMITIVE(v) === v.isObject() + * + * Also, to help prevent mistakenly boxing a nullable JSObject* as an object, + * Value::setObject takes a JSObject&. (Conversely, Value::asObject returns a + * JSObject&.) A convenience member Value::setObjectOrNull is provided. + * + * - JSVAL_VOID is the same as the singleton value of the Undefined type. + * + * - Note that JS::Value is 8 bytes on 32 and 64-bit architectures. Thus, on + * 32-bit user code should avoid copying jsval/JS::Value as much as possible, + * preferring to pass by const Value &. + */ +class Value +{ + public: + /* + * N.B. the default constructor leaves Value unitialized. Adding a default + * constructor prevents Value from being stored in a union. + */ + + /*** Mutators ***/ + + void setNull() { + data.asBits = BUILD_JSVAL(JSVAL_TAG_NULL, 0).asBits; + } + + void setUndefined() { + data.asBits = BUILD_JSVAL(JSVAL_TAG_UNDEFINED, 0).asBits; + } + + void setInt32(int32_t i) { + data = INT32_TO_JSVAL_IMPL(i); + } + + int32_t &getInt32Ref() { + MOZ_ASSERT(isInt32()); + return data.s.payload.i32; + } + + void setDouble(double d) { + data = DOUBLE_TO_JSVAL_IMPL(d); + } + + double &getDoubleRef() { + MOZ_ASSERT(isDouble()); + return data.asDouble; + } + + void setString(JSString *str) { + MOZ_ASSERT(!IsPoisonedPtr(str)); + data = STRING_TO_JSVAL_IMPL(str); + } + + void setString(const JS::Anchor &str) { + setString(str.get()); + } + + void setObject(JSObject &obj) { + MOZ_ASSERT(!IsPoisonedPtr(&obj)); + data = OBJECT_TO_JSVAL_IMPL(&obj); + } + + void setBoolean(bool b) { + data = BOOLEAN_TO_JSVAL_IMPL(b); + } + + void setMagic(JSWhyMagic why) { + data = MAGIC_TO_JSVAL_IMPL(why); + } + + bool setNumber(uint32_t ui) { + if (ui > JSVAL_INT_MAX) { + setDouble((double)ui); + return false; + } else { + setInt32((int32_t)ui); + return true; + } + } + + bool setNumber(double d) { + int32_t i; + if (MOZ_DOUBLE_IS_INT32(d, &i)) { + setInt32(i); + return true; + } else { + setDouble(d); + return false; + } + } + + void setObjectOrNull(JSObject *arg) { + if (arg) + setObject(*arg); + else + setNull(); + } + + void swap(Value &rhs) { + uint64_t tmp = rhs.data.asBits; + rhs.data.asBits = data.asBits; + data.asBits = tmp; + } + + /*** Value type queries ***/ + + bool isUndefined() const { + return JSVAL_IS_UNDEFINED_IMPL(data); + } + + bool isNull() const { + return JSVAL_IS_NULL_IMPL(data); + } + + bool isNullOrUndefined() const { + return isNull() || isUndefined(); + } + + bool isInt32() const { + return JSVAL_IS_INT32_IMPL(data); + } + + bool isInt32(int32_t i32) const { + return JSVAL_IS_SPECIFIC_INT32_IMPL(data, i32); + } + + bool isDouble() const { + return JSVAL_IS_DOUBLE_IMPL(data); + } + + bool isNumber() const { + return JSVAL_IS_NUMBER_IMPL(data); + } + + bool isString() const { + return JSVAL_IS_STRING_IMPL(data); + } + + bool isObject() const { + return JSVAL_IS_OBJECT_IMPL(data); + } + + bool isPrimitive() const { + return JSVAL_IS_PRIMITIVE_IMPL(data); + } + + bool isObjectOrNull() const { + return JSVAL_IS_OBJECT_OR_NULL_IMPL(data); + } + + bool isGCThing() const { + return JSVAL_IS_GCTHING_IMPL(data); + } + + bool isBoolean() const { + return JSVAL_IS_BOOLEAN_IMPL(data); + } + + bool isTrue() const { + return JSVAL_IS_SPECIFIC_BOOLEAN(data, true); + } + + bool isFalse() const { + return JSVAL_IS_SPECIFIC_BOOLEAN(data, false); + } + + bool isMagic() const { + return JSVAL_IS_MAGIC_IMPL(data); + } + + bool isMagic(JSWhyMagic why) const { + MOZ_ASSERT_IF(isMagic(), data.s.payload.why == why); + return JSVAL_IS_MAGIC_IMPL(data); + } + + bool isMarkable() const { + return JSVAL_IS_TRACEABLE_IMPL(data); + } + + JSGCTraceKind gcKind() const { + MOZ_ASSERT(isMarkable()); + return JSGCTraceKind(JSVAL_TRACE_KIND_IMPL(data)); + } + + JSWhyMagic whyMagic() const { + MOZ_ASSERT(isMagic()); + return data.s.payload.why; + } + + /*** Comparison ***/ + + bool operator==(const Value &rhs) const { + return data.asBits == rhs.data.asBits; + } + + bool operator!=(const Value &rhs) const { + return data.asBits != rhs.data.asBits; + } + + friend inline bool SameType(const Value &lhs, const Value &rhs); + + /*** Extract the value's typed payload ***/ + + int32_t toInt32() const { + MOZ_ASSERT(isInt32()); + return JSVAL_TO_INT32_IMPL(data); + } + + double toDouble() const { + MOZ_ASSERT(isDouble()); + return data.asDouble; + } + + double toNumber() const { + MOZ_ASSERT(isNumber()); + return isDouble() ? toDouble() : double(toInt32()); + } + + JSString *toString() const { + MOZ_ASSERT(isString()); + return JSVAL_TO_STRING_IMPL(data); + } + + JSObject &toObject() const { + MOZ_ASSERT(isObject()); + return *JSVAL_TO_OBJECT_IMPL(data); + } + + JSObject *toObjectOrNull() const { + MOZ_ASSERT(isObjectOrNull()); + return JSVAL_TO_OBJECT_IMPL(data); + } + + void *toGCThing() const { + MOZ_ASSERT(isGCThing()); + return JSVAL_TO_GCTHING_IMPL(data); + } + + bool toBoolean() const { + MOZ_ASSERT(isBoolean()); + return JSVAL_TO_BOOLEAN_IMPL(data); + } + + uint32_t payloadAsRawUint32() const { + MOZ_ASSERT(!isDouble()); + return data.s.payload.u32; + } + + uint64_t asRawBits() const { + return data.asBits; + } + + JSValueType extractNonDoubleType() const { + return JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(data); + } + + /* + * Private API + * + * Private setters/getters allow the caller to read/write arbitrary types + * that fit in the 64-bit payload. It is the caller's responsibility, after + * storing to a value with setPrivateX to read only using getPrivateX. + * Privates values are given a type which ensures they are not marked. + */ + + void setPrivate(void *ptr) { + data = PRIVATE_PTR_TO_JSVAL_IMPL(ptr); + } + + void *toPrivate() const { + MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(data)); + return JSVAL_TO_PRIVATE_PTR_IMPL(data); + } + + void setPrivateUint32(uint32_t ui) { + MOZ_ASSERT(uint32_t(int32_t(ui)) == ui); + setInt32(int32_t(ui)); + } + + uint32_t toPrivateUint32() const { + return uint32_t(toInt32()); + } + + /* + * An unmarked value is just a void* cast as a Value. Thus, the Value is + * not safe for GC and must not be marked. This API avoids raw casts + * and the ensuing strict-aliasing warnings. + */ + + void setUnmarkedPtr(void *ptr) { + data.asPtr = ptr; + } + + void *toUnmarkedPtr() const { + return data.asPtr; + } + + const size_t *payloadWord() const { +#if JS_BITS_PER_WORD == 32 + return &data.s.payload.word; +#elif JS_BITS_PER_WORD == 64 + return &data.asWord; +#endif + } + + const uintptr_t *payloadUIntPtr() const { +#if JS_BITS_PER_WORD == 32 + return &data.s.payload.uintptr; +#elif JS_BITS_PER_WORD == 64 + return &data.asUIntPtr; +#endif + } + +#if !defined(_MSC_VER) && !defined(__sparc) + // Value must be POD so that MSVC will pass it by value and not in memory + // (bug 689101); the same is true for SPARC as well (bug 737344). More + // precisely, we don't want Value return values compiled as out params. + private: +#endif + + jsval_layout data; + + private: + void staticAssertions() { + JS_STATIC_ASSERT(sizeof(JSValueType) == 1); + JS_STATIC_ASSERT(sizeof(JSValueTag) == 4); + JS_STATIC_ASSERT(sizeof(JSBool) == 4); + JS_STATIC_ASSERT(sizeof(JSWhyMagic) <= 4); + JS_STATIC_ASSERT(sizeof(Value) == 8); + } + + friend jsval_layout (::JSVAL_TO_IMPL)(Value); + friend Value (::IMPL_TO_JSVAL)(jsval_layout l); +}; + +inline bool +IsPoisonedValue(const Value &v) +{ + if (v.isString()) + return IsPoisonedPtr(v.toString()); + if (v.isObject()) + return IsPoisonedPtr(&v.toObject()); + return false; +} + +/************************************************************************/ + +static inline Value +NullValue() +{ + Value v; + v.setNull(); + return v; +} + +static inline Value +UndefinedValue() +{ + Value v; + v.setUndefined(); + return v; +} + +static inline Value +Int32Value(int32_t i32) +{ + Value v; + v.setInt32(i32); + return v; +} + +static inline Value +DoubleValue(double dbl) +{ + Value v; + v.setDouble(dbl); + return v; +} + +static inline Value +StringValue(JSString *str) +{ + Value v; + v.setString(str); + return v; +} + +static inline Value +BooleanValue(bool boo) +{ + Value v; + v.setBoolean(boo); + return v; +} + +static inline Value +ObjectValue(JSObject &obj) +{ + Value v; + v.setObject(obj); + return v; +} + +static inline Value +ObjectValueCrashOnTouch() +{ + Value v; + v.setObject(*reinterpret_cast(0x42)); + return v; +} + +static inline Value +MagicValue(JSWhyMagic why) +{ + Value v; + v.setMagic(why); + return v; +} + +static inline Value +NumberValue(float f) +{ + Value v; + v.setNumber(f); + return v; +} + +static inline Value +NumberValue(double dbl) +{ + Value v; + v.setNumber(dbl); + return v; +} + +static inline Value +NumberValue(int8_t i) +{ + return Int32Value(i); +} + +static inline Value +NumberValue(uint8_t i) +{ + return Int32Value(i); +} + +static inline Value +NumberValue(int16_t i) +{ + return Int32Value(i); +} + +static inline Value +NumberValue(uint16_t i) +{ + return Int32Value(i); +} + +static inline Value +NumberValue(int32_t i) +{ + return Int32Value(i); +} + +static inline Value +NumberValue(uint32_t i) +{ + Value v; + v.setNumber(i); + return v; +} + +namespace detail { + +template +class MakeNumberValue +{ + public: + template + static inline Value create(const T t) + { + Value v; + if (JSVAL_INT_MIN <= t && t <= JSVAL_INT_MAX) + v.setInt32(int32_t(t)); + else + v.setDouble(double(t)); + return v; + } +}; + +template <> +class MakeNumberValue +{ + public: + template + static inline Value create(const T t) + { + Value v; + if (t <= JSVAL_INT_MAX) + v.setInt32(int32_t(t)); + else + v.setDouble(double(t)); + return v; + } +}; + +} // namespace detail + +template +static inline Value +NumberValue(const T t) +{ + MOZ_ASSERT(T(double(t)) == t, "value creation would be lossy"); + return detail::MakeNumberValue::is_signed>::create(t); +} + +static inline Value +ObjectOrNullValue(JSObject *obj) +{ + Value v; + v.setObjectOrNull(obj); + return v; +} + +static inline Value +PrivateValue(void *ptr) +{ + Value v; + v.setPrivate(ptr); + return v; +} + +static inline Value +PrivateUint32Value(uint32_t ui) +{ + Value v; + v.setPrivateUint32(ui); + return v; +} + +inline bool +SameType(const Value &lhs, const Value &rhs) +{ + return JSVAL_SAME_TYPE_IMPL(lhs.data, rhs.data); +} + +} // namespace JS + +/************************************************************************/ + +namespace js { + +template <> struct RootMethods +{ + static JS::Value initial() { return JS::UndefinedValue(); } + static ThingRootKind kind() { return THING_ROOT_VALUE; } + static bool poisoned(const JS::Value &v) { return JS::IsPoisonedValue(v); } +}; + +template <> struct RootMethods +{ + static JS::Value initial() { return JS::UndefinedValue(); } + static ThingRootKind kind() { return THING_ROOT_VALUE; } + static bool poisoned(const JS::Value &v) { return JS::IsPoisonedValue(v); } +}; + +template class MutableValueOperations; + +/* + * A class designed for CRTP use in implementing the non-mutating parts of the + * Value interface in Value-like classes. Outer must be a class inheriting + * ValueOperations with a visible extract() method returning the + * const Value* abstracted by Outer. + */ +template +class ValueOperations +{ + friend class MutableValueOperations; + const JS::Value * value() const { return static_cast(this)->extract(); } + + public: + bool isUndefined() const { return value()->isUndefined(); } + bool isNull() const { return value()->isNull(); } + bool isBoolean() const { return value()->isBoolean(); } + bool isTrue() const { return value()->isTrue(); } + bool isFalse() const { return value()->isFalse(); } + bool isNumber() const { return value()->isNumber(); } + bool isInt32() const { return value()->isInt32(); } + bool isDouble() const { return value()->isDouble(); } + bool isString() const { return value()->isString(); } + bool isObject() const { return value()->isObject(); } + bool isMagic() const { return value()->isMagic(); } + bool isMagic(JSWhyMagic why) const { return value()->isMagic(why); } + bool isMarkable() const { return value()->isMarkable(); } + bool isPrimitive() const { return value()->isPrimitive(); } + bool isGCThing() const { return value()->isGCThing(); } + + bool isNullOrUndefined() const { return value()->isNullOrUndefined(); } + bool isObjectOrNull() const { return value()->isObjectOrNull(); } + + bool toBoolean() const { return value()->toBoolean(); } + double toNumber() const { return value()->toNumber(); } + int32_t toInt32() const { return value()->toInt32(); } + double toDouble() const { return value()->toDouble(); } + JSString *toString() const { return value()->toString(); } + JSObject &toObject() const { return value()->toObject(); } + JSObject *toObjectOrNull() const { return value()->toObjectOrNull(); } + void *toGCThing() const { return value()->toGCThing(); } + + JSValueType extractNonDoubleType() const { return value()->extractNonDoubleType(); } + + JSWhyMagic whyMagic() const { return value()->whyMagic(); } +}; + +/* + * A class designed for CRTP use in implementing the mutating parts of the + * Value interface in Value-like classes. Outer must be a class inheriting + * MutableValueOperations with visible extractMutable() and extract() + * methods returning the const Value* and Value* abstracted by Outer. + */ +template +class MutableValueOperations : public ValueOperations +{ + JS::Value * value() { return static_cast(this)->extractMutable(); } + + public: + void setNull() { value()->setNull(); } + void setUndefined() { value()->setUndefined(); } + void setInt32(int32_t i) { value()->setInt32(i); } + void setDouble(double d) { value()->setDouble(d); } + void setString(JSString *str) { value()->setString(str); } + void setString(const JS::Anchor &str) { value()->setString(str); } + void setObject(JSObject &obj) { value()->setObject(obj); } + void setBoolean(bool b) { value()->setBoolean(b); } + void setMagic(JSWhyMagic why) { value()->setMagic(why); } + bool setNumber(uint32_t ui) { return value()->setNumber(ui); } + bool setNumber(double d) { return value()->setNumber(d); } + void setObjectOrNull(JSObject *arg) { value()->setObjectOrNull(arg); } +}; + +/* + * Augment the generic Handle interface when T = Value with type-querying + * and value-extracting operations. + */ +template <> +class HandleBase : public ValueOperations > +{ + friend class ValueOperations >; + const JS::Value * extract() const { + return static_cast*>(this)->address(); + } +}; + +/* + * Augment the generic MutableHandle interface when T = Value with + * type-querying, value-extracting, and mutating operations. + */ +template <> +class MutableHandleBase : public MutableValueOperations > +{ + friend class ValueOperations >; + const JS::Value * extract() const { + return static_cast*>(this)->address(); + } + + friend class MutableValueOperations >; + JS::Value * extractMutable() { + return static_cast*>(this)->address(); + } +}; + +/* + * Augment the generic Rooted interface when T = Value with type-querying, + * value-extracting, and mutating operations. + */ +template <> +class RootedBase : public MutableValueOperations > +{ + friend class ValueOperations >; + const JS::Value * extract() const { + return static_cast*>(this)->address(); + } + + friend class MutableValueOperations >; + JS::Value * extractMutable() { + return static_cast*>(this)->address(); + } +}; + +} // namespace js + +inline jsval_layout +JSVAL_TO_IMPL(JS::Value v) +{ + return v.data; +} + +inline JS::Value +IMPL_TO_JSVAL(jsval_layout l) +{ + JS::Value v; + v.data = l; + return v; +} + +namespace JS { + +#ifndef __GNUC__ +/* + * The default assignment operator for |struct C| has the signature: + * + * C& C::operator=(const C&) + * + * And in particular requires implicit conversion of |this| to type |C| for the + * return value. But |volatile C| cannot thus be converted to |C|, so just + * doing |sink = hold| as in the non-specialized version would fail to compile. + * Do the assignment on asBits instead, since I don't think we want to give + * jsval_layout an assignment operator returning |volatile jsval_layout|. + */ +template<> +inline Anchor::~Anchor() +{ + volatile uint64_t bits; + bits = JSVAL_TO_IMPL(hold).asBits; +} +#endif + +#ifdef DEBUG +namespace detail { + +struct ValueAlignmentTester { char c; JS::Value v; }; +MOZ_STATIC_ASSERT(sizeof(ValueAlignmentTester) == 16, + "JS::Value must be 16-byte-aligned"); + +struct LayoutAlignmentTester { char c; jsval_layout l; }; +MOZ_STATIC_ASSERT(sizeof(LayoutAlignmentTester) == 16, + "jsval_layout must be 16-byte-aligned"); + +} // namespace detail +#endif /* DEBUG */ + +} // namespace JS + +/* + * JS::Value and jsval are the same type; jsval is the old name, kept around + * for backwards compatibility along with all the JSVAL_* operations below. + * jsval_layout is an implementation detail and should not be used externally. + */ +typedef JS::Value jsval; + +MOZ_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(JS::Value), + "jsval_layout and JS::Value must have identical layouts"); + +/************************************************************************/ + +static inline JSBool +JSVAL_IS_NULL(jsval v) +{ + return JSVAL_IS_NULL_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline JSBool +JSVAL_IS_VOID(jsval v) +{ + return JSVAL_IS_UNDEFINED_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline JSBool +JSVAL_IS_INT(jsval v) +{ + return JSVAL_IS_INT32_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline int32_t +JSVAL_TO_INT(jsval v) +{ + MOZ_ASSERT(JSVAL_IS_INT(v)); + return JSVAL_TO_INT32_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline jsval +INT_TO_JSVAL(int32_t i) +{ + return IMPL_TO_JSVAL(INT32_TO_JSVAL_IMPL(i)); +} + +static inline JSBool +JSVAL_IS_DOUBLE(jsval v) +{ + return JSVAL_IS_DOUBLE_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline double +JSVAL_TO_DOUBLE(jsval v) +{ + jsval_layout l; + MOZ_ASSERT(JSVAL_IS_DOUBLE(v)); + l = JSVAL_TO_IMPL(v); + return l.asDouble; +} + +static inline jsval +DOUBLE_TO_JSVAL(double d) +{ + /* + * This is a manually inlined version of: + * d = JS_CANONICALIZE_NAN(d); + * return IMPL_TO_JSVAL(DOUBLE_TO_JSVAL_IMPL(d)); + * because GCC from XCode 3.1.4 miscompiles the above code. + */ + jsval_layout l; + if (MOZ_UNLIKELY(d != d)) + l.asBits = 0x7FF8000000000000LL; + else + l.asDouble = d; + return IMPL_TO_JSVAL(l); +} + +static inline jsval +UINT_TO_JSVAL(uint32_t i) +{ + if (i <= JSVAL_INT_MAX) + return INT_TO_JSVAL((int32_t)i); + return DOUBLE_TO_JSVAL((double)i); +} + +static inline JSBool +JSVAL_IS_NUMBER(jsval v) +{ + return JSVAL_IS_NUMBER_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline JSBool +JSVAL_IS_STRING(jsval v) +{ + return JSVAL_IS_STRING_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline JSString * +JSVAL_TO_STRING(jsval v) +{ + MOZ_ASSERT(JSVAL_IS_STRING(v)); + return JSVAL_TO_STRING_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline jsval +STRING_TO_JSVAL(JSString *str) +{ + return IMPL_TO_JSVAL(STRING_TO_JSVAL_IMPL(str)); +} + +static inline JSObject * +JSVAL_TO_OBJECT(jsval v) +{ + MOZ_ASSERT(JSVAL_IS_OBJECT_OR_NULL_IMPL(JSVAL_TO_IMPL(v))); + return JSVAL_TO_OBJECT_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline jsval +OBJECT_TO_JSVAL(JSObject *obj) +{ + if (obj) + return IMPL_TO_JSVAL(OBJECT_TO_JSVAL_IMPL(obj)); + return IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL, 0)); +} + +static inline JSBool +JSVAL_IS_BOOLEAN(jsval v) +{ + return JSVAL_IS_BOOLEAN_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline JSBool +JSVAL_TO_BOOLEAN(jsval v) +{ + MOZ_ASSERT(JSVAL_IS_BOOLEAN(v)); + return JSVAL_TO_BOOLEAN_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline jsval +BOOLEAN_TO_JSVAL(JSBool b) +{ + return IMPL_TO_JSVAL(BOOLEAN_TO_JSVAL_IMPL(b)); +} + +static inline JSBool +JSVAL_IS_PRIMITIVE(jsval v) +{ + return JSVAL_IS_PRIMITIVE_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline JSBool +JSVAL_IS_GCTHING(jsval v) +{ + return JSVAL_IS_GCTHING_IMPL(JSVAL_TO_IMPL(v)); +} + +static inline void * +JSVAL_TO_GCTHING(jsval v) +{ + MOZ_ASSERT(JSVAL_IS_GCTHING(v)); + return JSVAL_TO_GCTHING_IMPL(JSVAL_TO_IMPL(v)); +} + +/* To be GC-safe, privates are tagged as doubles. */ + +static inline jsval +PRIVATE_TO_JSVAL(void *ptr) +{ + return IMPL_TO_JSVAL(PRIVATE_PTR_TO_JSVAL_IMPL(ptr)); +} + +static inline void * +JSVAL_TO_PRIVATE(jsval v) +{ + MOZ_ASSERT(JSVAL_IS_DOUBLE(v)); + return JSVAL_TO_PRIVATE_PTR_IMPL(JSVAL_TO_IMPL(v)); +} + +#endif /* js_Value_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/js/Vector.h b/scripting/javascript/spidermonkey-mac/include/js/Vector.h new file mode 100644 index 0000000000..b8e2ea6985 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/js/Vector.h @@ -0,0 +1,1108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsvector_h_ +#define jsvector_h_ + +#include "mozilla/Attributes.h" +#include "mozilla/TypeTraits.h" + +#include "TemplateLib.h" +#include "Utility.h" + +/* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4345) +#endif + +namespace js { + +class TempAllocPolicy; + +template +class Vector; + +/* + * Check that the given capacity wastes the minimal amount of space if + * allocated on the heap. This means that cap*sizeof(T) is as close to a + * power-of-two as possible. growStorageBy() is responsible for ensuring + * this. + */ +template +static bool CapacityHasExcessSpace(size_t cap) +{ + size_t size = cap * sizeof(T); + return RoundUpPow2(size) - size >= sizeof(T); +} + +/* + * This template class provides a default implementation for vector operations + * when the element type is not known to be a POD, as judged by IsPod. + */ +template +struct VectorImpl +{ + /* Destroys constructed objects in the range [begin, end). */ + static inline void destroy(T *begin, T *end) { + for (T *p = begin; p != end; ++p) + p->~T(); + } + + /* Constructs objects in the uninitialized range [begin, end). */ + static inline void initialize(T *begin, T *end) { + for (T *p = begin; p != end; ++p) + new(p) T(); + } + + /* + * Copy-constructs objects in the uninitialized range + * [dst, dst+(srcend-srcbeg)) from the range [srcbeg, srcend). + */ + template + static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) { + for (const U *p = srcbeg; p != srcend; ++p, ++dst) + new(dst) T(*p); + } + + /* + * Move-constructs objects in the uninitialized range + * [dst, dst+(srcend-srcbeg)) from the range [srcbeg, srcend). + */ + template + static inline void moveConstruct(T *dst, const U *srcbeg, const U *srcend) { + for (const U *p = srcbeg; p != srcend; ++p, ++dst) + new(dst) T(Move(*p)); + } + + /* + * Copy-constructs objects in the uninitialized range [dst, dst+n) from the + * same object u. + */ + template + static inline void copyConstructN(T *dst, size_t n, const U &u) { + for (T *end = dst + n; dst != end; ++dst) + new(dst) T(u); + } + + /* + * Grows the given buffer to have capacity newCap, preserving the objects + * constructed in the range [begin, end) and updating v. Assumes that (1) + * newCap has not overflowed, and (2) multiplying newCap by sizeof(T) will + * not overflow. + */ + static inline bool growTo(Vector &v, size_t newCap) { + JS_ASSERT(!v.usingInlineStorage()); + JS_ASSERT(!CapacityHasExcessSpace(newCap)); + T *newbuf = reinterpret_cast(v.malloc_(newCap * sizeof(T))); + if (!newbuf) + return false; + for (T *dst = newbuf, *src = v.beginNoCheck(); src != v.endNoCheck(); ++dst, ++src) + new(dst) T(Move(*src)); + VectorImpl::destroy(v.beginNoCheck(), v.endNoCheck()); + v.free_(v.mBegin); + v.mBegin = newbuf; + /* v.mLength is unchanged. */ + v.mCapacity = newCap; + return true; + } +}; + +/* + * This partial template specialization provides a default implementation for + * vector operations when the element type is known to be a POD, as judged by + * IsPod. + */ +template +struct VectorImpl +{ + static inline void destroy(T *, T *) {} + + static inline void initialize(T *begin, T *end) { + /* + * You would think that memset would be a big win (or even break even) + * when we know T is a POD. But currently it's not. This is probably + * because |append| tends to be given small ranges and memset requires + * a function call that doesn't get inlined. + * + * memset(begin, 0, sizeof(T) * (end-begin)); + */ + for (T *p = begin; p != end; ++p) + new(p) T(); + } + + template + static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) { + /* + * See above memset comment. Also, notice that copyConstruct is + * currently templated (T != U), so memcpy won't work without + * requiring T == U. + * + * memcpy(dst, srcbeg, sizeof(T) * (srcend - srcbeg)); + */ + for (const U *p = srcbeg; p != srcend; ++p, ++dst) + *dst = *p; + } + + template + static inline void moveConstruct(T *dst, const U *srcbeg, const U *srcend) { + copyConstruct(dst, srcbeg, srcend); + } + + static inline void copyConstructN(T *dst, size_t n, const T &t) { + for (T *p = dst, *end = dst + n; p != end; ++p) + *p = t; + } + + static inline bool growTo(Vector &v, size_t newCap) { + JS_ASSERT(!v.usingInlineStorage()); + JS_ASSERT(!CapacityHasExcessSpace(newCap)); + size_t oldSize = sizeof(T) * v.mCapacity; + size_t newSize = sizeof(T) * newCap; + T *newbuf = reinterpret_cast(v.realloc_(v.mBegin, oldSize, newSize)); + if (!newbuf) + return false; + v.mBegin = newbuf; + /* v.mLength is unchanged. */ + v.mCapacity = newCap; + return true; + } +}; + +/* + * JS-friendly, STL-like container providing a short-lived, dynamic buffer. + * Vector calls the constructors/destructors of all elements stored in + * its internal buffer, so non-PODs may be safely used. Additionally, + * Vector will store the first N elements in-place before resorting to + * dynamic allocation. + * + * T requirements: + * - default and copy constructible, assignable, destructible + * - operations do not throw + * N requirements: + * - any value, however, N is clamped to min/max values + * AllocPolicy: + * - see "Allocation policies" in jsalloc.h (default js::TempAllocPolicy) + * + * N.B: Vector is not reentrant: T member functions called during Vector member + * functions must not call back into the same object. + */ +template +class Vector : private AllocPolicy +{ + // typedef typename tl::StaticAssert::result>::result _; + + /* utilities */ + + static const bool sElemIsPod = mozilla::IsPod::value; + typedef VectorImpl Impl; + friend struct VectorImpl; + + bool growStorageBy(size_t incr); + bool convertToHeapStorage(size_t newCap); + + template inline bool growByImpl(size_t inc); + + /* magic constants */ + + static const int sMaxInlineBytes = 1024; + + /* compute constants */ + + /* + * Consider element size to be 1 for buffer sizing if there are + * 0 inline elements. This allows us to compile when the definition + * of the element type is not visible here. + * + * Explicit specialization is only allowed at namespace scope, so + * in order to keep everything here, we use a dummy template + * parameter with partial specialization. + */ + template + struct ElemSize { + static const size_t result = sizeof(T); + }; + template + struct ElemSize<0, Dummy> { + static const size_t result = 1; + }; + + static const size_t sInlineCapacity = + tl::Min::result>::result; + + /* Calculate inline buffer size; avoid 0-sized array. */ + static const size_t sInlineBytes = + tl::Max<1, sInlineCapacity * ElemSize::result>::result; + + /* member data */ + + /* + * Pointer to the buffer, be it inline or heap-allocated. Only [mBegin, + * mBegin + mLength) hold valid constructed T objects. The range [mBegin + + * mLength, mBegin + mCapacity) holds uninitialized memory. The range + * [mBegin + mLength, mBegin + mReserved) also holds uninitialized memory + * previously allocated by a call to reserve(). + */ + T *mBegin; + size_t mLength; /* Number of elements in the Vector. */ + size_t mCapacity; /* Max number of elements storable in the Vector without resizing. */ +#ifdef DEBUG + size_t mReserved; /* Max elements of reserved or used space in this vector. */ +#endif + + mozilla::AlignedStorage storage; + +#ifdef DEBUG + friend class ReentrancyGuard; + bool entered; +#endif + + Vector(const Vector &) MOZ_DELETE; + Vector &operator=(const Vector &) MOZ_DELETE; + + /* private accessors */ + + bool usingInlineStorage() const { + return mBegin == inlineStorage(); + } + + T *inlineStorage() const { + return (T *)storage.addr(); + } + + T *beginNoCheck() const { + return mBegin; + } + + T *endNoCheck() { + return mBegin + mLength; + } + + const T *endNoCheck() const { + return mBegin + mLength; + } + +#ifdef DEBUG + size_t reserved() const { + JS_ASSERT(mReserved <= mCapacity); + JS_ASSERT(mLength <= mReserved); + return mReserved; + } +#endif + + /* Append operations guaranteed to succeed due to pre-reserved space. */ + template void internalAppend(U u); + void internalAppendN(const T &t, size_t n); + template void internalAppend(const U *begin, size_t length); + template void internalAppend(const Vector &other); + + public: + static const size_t sMaxInlineStorage = N; + + typedef T ElementType; + + Vector(AllocPolicy = AllocPolicy()); + Vector(MoveRef); /* Move constructor. */ + Vector &operator=(MoveRef); /* Move assignment. */ + ~Vector(); + + /* accessors */ + + const AllocPolicy &allocPolicy() const { + return *this; + } + + AllocPolicy &allocPolicy() { + return *this; + } + + enum { InlineLength = N }; + + size_t length() const { + return mLength; + } + + bool empty() const { + return mLength == 0; + } + + size_t capacity() const { + return mCapacity; + } + + T *begin() { + JS_ASSERT(!entered); + return mBegin; + } + + const T *begin() const { + JS_ASSERT(!entered); + return mBegin; + } + + T *end() { + JS_ASSERT(!entered); + return mBegin + mLength; + } + + const T *end() const { + JS_ASSERT(!entered); + return mBegin + mLength; + } + + T &operator[](size_t i) { + JS_ASSERT(!entered && i < mLength); + return begin()[i]; + } + + const T &operator[](size_t i) const { + JS_ASSERT(!entered && i < mLength); + return begin()[i]; + } + + T &back() { + JS_ASSERT(!entered && !empty()); + return *(end() - 1); + } + + const T &back() const { + JS_ASSERT(!entered && !empty()); + return *(end() - 1); + } + + class Range { + friend class Vector; + T *cur_, *end_; + Range(T *cur, T *end) : cur_(cur), end_(end) {} + public: + Range() {} + bool empty() const { return cur_ == end_; } + size_t remain() const { return end_ - cur_; } + T &front() const { return *cur_; } + void popFront() { JS_ASSERT(!empty()); ++cur_; } + T popCopyFront() { JS_ASSERT(!empty()); return *cur_++; } + }; + + Range all() { + return Range(begin(), end()); + } + + /* mutators */ + + /* Given that the Vector is empty and has no inline storage, grow to |capacity|. */ + bool initCapacity(size_t request); + + /* If reserve(length() + N) succeeds, the N next appends are guaranteed to succeed. */ + bool reserve(size_t request); + + /* + * Destroy elements in the range [end() - incr, end()). Does not deallocate + * or unreserve storage for those elements. + */ + void shrinkBy(size_t incr); + + /* Grow the vector by incr elements. */ + bool growBy(size_t incr); + + /* Call shrinkBy or growBy based on whether newSize > length(). */ + bool resize(size_t newLength); + + /* Leave new elements as uninitialized memory. */ + bool growByUninitialized(size_t incr); + bool resizeUninitialized(size_t newLength); + + /* Shorthand for shrinkBy(length()). */ + void clear(); + + /* Clears and releases any heap-allocated storage. */ + void clearAndFree(); + + /* If true, appending |needed| elements will not call realloc(). */ + bool canAppendWithoutRealloc(size_t needed) const; + + /* + * Potentially fallible append operations. + * + * The function templates that take an unspecified type U require a + * const T & or a MoveRef. The MoveRef variants move their + * operands into the vector, instead of copying them. If they fail, the + * operand is left unmoved. + */ + template bool append(U t); + bool appendN(const T &t, size_t n); + template bool append(const U *begin, const U *end); + template bool append(const U *begin, size_t length); + template bool append(const Vector &other); + + /* + * Guaranteed-infallible append operations for use upon vectors whose + * memory has been pre-reserved. + */ + template void infallibleAppend(const U &u) { + internalAppend(u); + } + void infallibleAppendN(const T &t, size_t n) { + internalAppendN(t, n); + } + template void infallibleAppend(const U *aBegin, const U *aEnd) { + internalAppend(aBegin, mozilla::PointerRangeSize(aBegin, aEnd)); + } + template void infallibleAppend(const U *aBegin, size_t aLength) { + internalAppend(aBegin, aLength); + } + template void infallibleAppend(const Vector &other) { + internalAppend(other); + } + + void popBack(); + + T popCopy(); + + /* + * Transfers ownership of the internal buffer used by Vector to the caller. + * After this call, the Vector is empty. Since the returned buffer may need + * to be allocated (if the elements are currently stored in-place), the + * call can fail, returning NULL. + * + * N.B. Although a T*, only the range [0, length()) is constructed. + */ + T *extractRawBuffer(); + + /* + * Transfer ownership of an array of objects into the Vector. + * N.B. This call assumes that there are no uninitialized elements in the + * passed array. + */ + void replaceRawBuffer(T *p, size_t length); + + /* + * Places |val| at position |p|, shifting existing elements from |p| + * onward one position higher. On success, |p| should not be reused + * because it will be a dangling pointer if reallocation of the vector + * storage occurred; the return value should be used instead. On failure, + * NULL is returned. + * + * Example usage: + * + * if (!(p = vec.insert(p, val))) + * + * + */ + T *insert(T *p, const T &val); + + /* + * Removes the element |t|, which must fall in the bounds [begin, end), + * shifting existing elements from |t + 1| onward one position lower. + */ + void erase(T *t); + + /* + * Measure the size of the Vector's heap-allocated storage. + */ + size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const; + + /* + * Like sizeOfExcludingThis, but also measures the size of the Vector + * object (which must be heap-allocated) itself. + */ + size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const; + + void swap(Vector &other); +}; + +/* This does the re-entrancy check plus several other sanity checks. */ +#define REENTRANCY_GUARD_ET_AL \ + ReentrancyGuard g(*this); \ + JS_ASSERT_IF(usingInlineStorage(), mCapacity == sInlineCapacity); \ + JS_ASSERT(reserved() <= mCapacity); \ + JS_ASSERT(mLength <= reserved()); \ + JS_ASSERT(mLength <= mCapacity) + +/* Vector Implementation */ + +template +JS_ALWAYS_INLINE +Vector::Vector(AllocPolicy ap) + : AllocPolicy(ap), mBegin((T *)storage.addr()), mLength(0), + mCapacity(sInlineCapacity) +#ifdef DEBUG + , mReserved(sInlineCapacity), entered(false) +#endif +{} + +/* Move constructor. */ +template +JS_ALWAYS_INLINE +Vector::Vector(MoveRef rhs) + : AllocPolicy(rhs) +#ifdef DEBUG + , entered(false) +#endif +{ + mLength = rhs->mLength; + mCapacity = rhs->mCapacity; +#ifdef DEBUG + mReserved = rhs->mReserved; +#endif + + if (rhs->usingInlineStorage()) { + /* We can't move the buffer over in this case, so copy elements. */ + mBegin = (T *)storage.addr(); + Impl::moveConstruct(mBegin, rhs->beginNoCheck(), rhs->endNoCheck()); + /* + * Leave rhs's mLength, mBegin, mCapacity, and mReserved as they are. + * The elements in its in-line storage still need to be destroyed. + */ + } else { + /* + * Take src's buffer, and turn src into an empty vector using + * in-line storage. + */ + mBegin = rhs->mBegin; + rhs->mBegin = (T *) rhs->storage.addr(); + rhs->mCapacity = sInlineCapacity; + rhs->mLength = 0; +#ifdef DEBUG + rhs->mReserved = sInlineCapacity; +#endif + } +} + +/* Move assignment. */ +template +JS_ALWAYS_INLINE +Vector & +Vector::operator=(MoveRef rhs) +{ + this->~Vector(); + new(this) Vector(rhs); + return *this; +} + +template +JS_ALWAYS_INLINE +Vector::~Vector() +{ + REENTRANCY_GUARD_ET_AL; + Impl::destroy(beginNoCheck(), endNoCheck()); + if (!usingInlineStorage()) + this->free_(beginNoCheck()); +} + +/* + * This function will create a new heap buffer with capacity newCap, + * move all elements in the inline buffer to this new buffer, + * and fail on OOM. + */ +template +inline bool +Vector::convertToHeapStorage(size_t newCap) +{ + JS_ASSERT(usingInlineStorage()); + + /* Allocate buffer. */ + JS_ASSERT(!CapacityHasExcessSpace(newCap)); + T *newBuf = reinterpret_cast(this->malloc_(newCap * sizeof(T))); + if (!newBuf) + return false; + + /* Copy inline elements into heap buffer. */ + Impl::moveConstruct(newBuf, beginNoCheck(), endNoCheck()); + Impl::destroy(beginNoCheck(), endNoCheck()); + + /* Switch in heap buffer. */ + mBegin = newBuf; + /* mLength is unchanged. */ + mCapacity = newCap; + return true; +} + +template +JS_NEVER_INLINE bool +Vector::growStorageBy(size_t incr) +{ + JS_ASSERT(mLength + incr > mCapacity); + JS_ASSERT_IF(!usingInlineStorage(), !CapacityHasExcessSpace(mCapacity)); + + /* + * When choosing a new capacity, its size should is as close to 2^N bytes + * as possible. 2^N-sized requests are best because they are unlikely to + * be rounded up by the allocator. Asking for a 2^N number of elements + * isn't as good, because if sizeof(T) is not a power-of-two that would + * result in a non-2^N request size. + */ + + size_t newCap; + + if (incr == 1) { + if (usingInlineStorage()) { + /* This case occurs in ~70--80% of the calls to this function. */ + size_t newSize = tl::RoundUpPow2<(sInlineCapacity + 1) * sizeof(T)>::result; + newCap = newSize / sizeof(T); + goto convert; + } + + if (mLength == 0) { + /* This case occurs in ~0--10% of the calls to this function. */ + newCap = 1; + goto grow; + } + + /* This case occurs in ~15--20% of the calls to this function. */ + + /* + * Will mLength*4*sizeof(T) overflow? This condition limits a Vector + * to 1GB of memory on a 32-bit system, which is a reasonable limit. + * It also ensures that the ((char *)end() - (char *)begin()) does not + * overflow ptrdiff_t (see Bug 510319). + */ + if (mLength & tl::MulOverflowMask<4 * sizeof(T)>::result) { + this->reportAllocOverflow(); + return false; + } + + /* + * If we reach here, the existing capacity will have a size that is + * already as close to 2^N as sizeof(T) will allow. Just double the + * capacity, and then there might be space for one more element. + */ + newCap = mLength * 2; + if (CapacityHasExcessSpace(newCap)) + newCap += 1; + + } else { + /* This case occurs in ~2% of the calls to this function. */ + size_t newMinCap = mLength + incr; + + /* Did mLength+incr overflow? Will newCap*sizeof(T) overflow? */ + if (newMinCap < mLength || + newMinCap & tl::MulOverflowMask<2 * sizeof(T)>::result) + { + this->reportAllocOverflow(); + return false; + } + + size_t newMinSize = newMinCap * sizeof(T); + size_t newSize = RoundUpPow2(newMinSize); + newCap = newSize / sizeof(T); + } + + if (usingInlineStorage()) { + convert: + return convertToHeapStorage(newCap); + } + + grow: + return Impl::growTo(*this, newCap); +} + +template +inline bool +Vector::initCapacity(size_t request) +{ + JS_ASSERT(empty()); + JS_ASSERT(usingInlineStorage()); + if (request == 0) + return true; + T *newbuf = reinterpret_cast(this->malloc_(request * sizeof(T))); + if (!newbuf) + return false; + mBegin = newbuf; + mCapacity = request; +#ifdef DEBUG + mReserved = request; +#endif + return true; +} + +template +inline bool +Vector::reserve(size_t request) +{ + REENTRANCY_GUARD_ET_AL; + if (request > mCapacity && !growStorageBy(request - mLength)) + return false; + +#ifdef DEBUG + if (request > mReserved) + mReserved = request; + JS_ASSERT(mLength <= mReserved); + JS_ASSERT(mReserved <= mCapacity); +#endif + return true; +} + +template +inline void +Vector::shrinkBy(size_t incr) +{ + REENTRANCY_GUARD_ET_AL; + JS_ASSERT(incr <= mLength); + Impl::destroy(endNoCheck() - incr, endNoCheck()); + mLength -= incr; +} + +template +template +JS_ALWAYS_INLINE bool +Vector::growByImpl(size_t incr) +{ + REENTRANCY_GUARD_ET_AL; + if (incr > mCapacity - mLength && !growStorageBy(incr)) + return false; + + JS_ASSERT(mLength + incr <= mCapacity); + T *newend = endNoCheck() + incr; + if (InitNewElems) + Impl::initialize(endNoCheck(), newend); + mLength += incr; +#ifdef DEBUG + if (mLength > mReserved) + mReserved = mLength; +#endif + return true; +} + +template +JS_ALWAYS_INLINE bool +Vector::growBy(size_t incr) +{ + return growByImpl(incr); +} + +template +JS_ALWAYS_INLINE bool +Vector::growByUninitialized(size_t incr) +{ + return growByImpl(incr); +} + +template +STATIC_POSTCONDITION(!return || ubound(this->begin()) >= newLength) +inline bool +Vector::resize(size_t newLength) +{ + size_t curLength = mLength; + if (newLength > curLength) + return growBy(newLength - curLength); + shrinkBy(curLength - newLength); + return true; +} + +template +JS_ALWAYS_INLINE bool +Vector::resizeUninitialized(size_t newLength) +{ + size_t curLength = mLength; + if (newLength > curLength) + return growByUninitialized(newLength - curLength); + shrinkBy(curLength - newLength); + return true; +} + +template +inline void +Vector::clear() +{ + REENTRANCY_GUARD_ET_AL; + Impl::destroy(beginNoCheck(), endNoCheck()); + mLength = 0; +} + +template +inline void +Vector::clearAndFree() +{ + clear(); + + if (usingInlineStorage()) + return; + + this->free_(beginNoCheck()); + mBegin = (T *)storage.addr(); + mCapacity = sInlineCapacity; +#ifdef DEBUG + mReserved = sInlineCapacity; +#endif +} + +template +inline bool +Vector::canAppendWithoutRealloc(size_t needed) const +{ + return mLength + needed <= mCapacity; +} + +template +template +JS_ALWAYS_INLINE bool +Vector::append(U t) +{ + REENTRANCY_GUARD_ET_AL; + if (mLength == mCapacity && !growStorageBy(1)) + return false; + +#ifdef DEBUG + if (mLength + 1 > mReserved) + mReserved = mLength + 1; +#endif + internalAppend(t); + return true; +} + +template +template +JS_ALWAYS_INLINE void +Vector::internalAppend(U u) +{ + JS_ASSERT(mLength + 1 <= mReserved); + JS_ASSERT(mReserved <= mCapacity); + new(endNoCheck()) T(u); + ++mLength; +} + +template +JS_ALWAYS_INLINE bool +Vector::appendN(const T &t, size_t needed) +{ + REENTRANCY_GUARD_ET_AL; + if (mLength + needed > mCapacity && !growStorageBy(needed)) + return false; + +#ifdef DEBUG + if (mLength + needed > mReserved) + mReserved = mLength + needed; +#endif + internalAppendN(t, needed); + return true; +} + +template +JS_ALWAYS_INLINE void +Vector::internalAppendN(const T &t, size_t needed) +{ + JS_ASSERT(mLength + needed <= mReserved); + JS_ASSERT(mReserved <= mCapacity); + Impl::copyConstructN(endNoCheck(), needed, t); + mLength += needed; +} + +template +inline T * +Vector::insert(T *p, const T &val) +{ + JS_ASSERT(begin() <= p && p <= end()); + size_t pos = p - begin(); + JS_ASSERT(pos <= mLength); + size_t oldLength = mLength; + if (pos == oldLength) { + if (!append(val)) + return NULL; + } else { + T oldBack = back(); + if (!append(oldBack)) /* Dup the last element. */ + return NULL; + for (size_t i = oldLength; i > pos; --i) + (*this)[i] = (*this)[i - 1]; + (*this)[pos] = val; + } + return begin() + pos; +} + +template +inline void +Vector::erase(T *it) +{ + JS_ASSERT(begin() <= it && it < end()); + while (it + 1 != end()) { + *it = *(it + 1); + ++it; + } + popBack(); +} + +template +template +JS_ALWAYS_INLINE bool +Vector::append(const U *insBegin, const U *insEnd) +{ + REENTRANCY_GUARD_ET_AL; + size_t needed = mozilla::PointerRangeSize(insBegin, insEnd); + if (mLength + needed > mCapacity && !growStorageBy(needed)) + return false; + +#ifdef DEBUG + if (mLength + needed > mReserved) + mReserved = mLength + needed; +#endif + internalAppend(insBegin, needed); + return true; +} + +template +template +JS_ALWAYS_INLINE void +Vector::internalAppend(const U *insBegin, size_t insLength) +{ + JS_ASSERT(mLength + insLength <= mReserved); + JS_ASSERT(mReserved <= mCapacity); + Impl::copyConstruct(endNoCheck(), insBegin, insBegin + insLength); + mLength += insLength; +} + +template +template +inline bool +Vector::append(const Vector &other) +{ + return append(other.begin(), other.end()); +} + +template +template +inline void +Vector::internalAppend(const Vector &other) +{ + internalAppend(other.begin(), other.length()); +} + +template +template +JS_ALWAYS_INLINE bool +Vector::append(const U *insBegin, size_t insLength) +{ + return this->append(insBegin, insBegin + insLength); +} + +template +JS_ALWAYS_INLINE void +Vector::popBack() +{ + REENTRANCY_GUARD_ET_AL; + JS_ASSERT(!empty()); + --mLength; + endNoCheck()->~T(); +} + +template +JS_ALWAYS_INLINE T +Vector::popCopy() +{ + T ret = back(); + popBack(); + return ret; +} + +template +inline T * +Vector::extractRawBuffer() +{ + T *ret; + if (usingInlineStorage()) { + ret = reinterpret_cast(this->malloc_(mLength * sizeof(T))); + if (!ret) + return NULL; + Impl::copyConstruct(ret, beginNoCheck(), endNoCheck()); + Impl::destroy(beginNoCheck(), endNoCheck()); + /* mBegin, mCapacity are unchanged. */ + mLength = 0; + } else { + ret = mBegin; + mBegin = (T *)storage.addr(); + mLength = 0; + mCapacity = sInlineCapacity; +#ifdef DEBUG + mReserved = sInlineCapacity; +#endif + } + return ret; +} + +template +inline void +Vector::replaceRawBuffer(T *p, size_t aLength) +{ + REENTRANCY_GUARD_ET_AL; + + /* Destroy what we have. */ + Impl::destroy(beginNoCheck(), endNoCheck()); + if (!usingInlineStorage()) + this->free_(beginNoCheck()); + + /* Take in the new buffer. */ + if (aLength <= sInlineCapacity) { + /* + * We convert to inline storage if possible, even though p might + * otherwise be acceptable. Maybe this behaviour should be + * specifiable with an argument to this function. + */ + mBegin = (T *)storage.addr(); + mLength = aLength; + mCapacity = sInlineCapacity; + Impl::moveConstruct(mBegin, p, p + aLength); + Impl::destroy(p, p + aLength); + this->free_(p); + } else { + mBegin = p; + mLength = aLength; + mCapacity = aLength; + } +#ifdef DEBUG + mReserved = aLength; +#endif +} + +template +inline size_t +Vector::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const +{ + return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck()); +} + +template +inline size_t +Vector::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const +{ + return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); +} + +template +inline void +Vector::swap(Vector &other) +{ + // TODO Implement N != 0 + JS_STATIC_ASSERT(N == 0); + + // This only works when inline storage is always empty. + if (!usingInlineStorage() && other.usingInlineStorage()) { + other.mBegin = mBegin; + mBegin = inlineStorage(); + } else if (usingInlineStorage() && !other.usingInlineStorage()) { + mBegin = other.mBegin; + other.mBegin = other.inlineStorage(); + } else if (!usingInlineStorage() && !other.usingInlineStorage()) { + Swap(mBegin, other.mBegin); + } else { + // This case is a no-op, since we'd set both to use their inline storage. + } + + Swap(mLength, other.mLength); + Swap(mCapacity, other.mCapacity); +#ifdef DEBUG + Swap(mReserved, other.mReserved); +#endif +} + +} /* namespace js */ + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif /* jsvector_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsalloc.h b/scripting/javascript/spidermonkey-mac/include/jsalloc.h new file mode 100644 index 0000000000..7d76a7c701 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsalloc.h @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsalloc_h_ +#define jsalloc_h_ + +#include "jsutil.h" + +namespace js { + +/* + * Allocation policies. These model the concept: + * - public copy constructor, assignment, destructor + * - void *malloc_(size_t) + * Responsible for OOM reporting on NULL return value. + * - void *calloc_(size_t) + * Responsible for OOM reporting on NULL return value. + * - void *realloc_(size_t) + * Responsible for OOM reporting on NULL return value. + * The *used* bytes of the previous buffer is passed in + * (rather than the old allocation size), in addition to + * the *new* allocation size requested. + * - void free_(void *) + * - reportAllocOverflow() + * Called on overflow before the container returns NULL. + */ + +/* Policy for using system memory functions and doing no error reporting. */ +class SystemAllocPolicy +{ + public: + void *malloc_(size_t bytes) { return js_malloc(bytes); } + void *calloc_(size_t bytes) { return js_calloc(bytes); } + void *realloc_(void *p, size_t oldBytes, size_t bytes) { return js_realloc(p, bytes); } + void free_(void *p) { js_free(p); } + void reportAllocOverflow() const {} +}; + +/* + * Allocation policy that calls the system memory functions and reports errors + * to the context. Since the JSContext given on construction is stored for + * the lifetime of the container, this policy may only be used for containers + * whose lifetime is a shorter than the given JSContext. + * + * FIXME bug 647103 - rewrite this in terms of temporary allocation functions, + * not the system ones. + */ +class TempAllocPolicy +{ + JSContext *const cx_; + + /* + * Non-inline helper to call JSRuntime::onOutOfMemory with minimal + * code bloat. + */ + JS_FRIEND_API(void *) onOutOfMemory(void *p, size_t nbytes); + + public: + TempAllocPolicy(JSContext *cx) : cx_(cx) {} + + JSContext *context() const { + return cx_; + } + + void *malloc_(size_t bytes) { + void *p = js_malloc(bytes); + if (JS_UNLIKELY(!p)) + p = onOutOfMemory(NULL, bytes); + return p; + } + + void *calloc_(size_t bytes) { + void *p = js_calloc(bytes); + if (JS_UNLIKELY(!p)) + p = onOutOfMemory(NULL, bytes); + return p; + } + + void *realloc_(void *p, size_t oldBytes, size_t bytes) { + void *p2 = js_realloc(p, bytes); + if (JS_UNLIKELY(!p2)) + p2 = onOutOfMemory(p2, bytes); + return p2; + } + + void free_(void *p) { + js_free(p); + } + + JS_FRIEND_API(void) reportAllocOverflow() const; +}; + +} /* namespace js */ + +#endif /* jsalloc_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsapi.h.REMOVED.git-id b/scripting/javascript/spidermonkey-mac/include/jsapi.h.REMOVED.git-id new file mode 100644 index 0000000000..8d449c8dba --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsapi.h.REMOVED.git-id @@ -0,0 +1 @@ +0d7798c67f3b31bcb033a3663a609649637264ce \ No newline at end of file diff --git a/scripting/javascript/spidermonkey-mac/include/jsclass.h b/scripting/javascript/spidermonkey-mac/include/jsclass.h new file mode 100644 index 0000000000..71aabc50f7 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsclass.h @@ -0,0 +1,401 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=79 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsclass_h__ +#define jsclass_h__ +/* + * A JSClass acts as a vtable for JS objects that allows JSAPI clients to + * control various aspects of the behavior of an object like property lookup. + * js::Class is an engine-private extension that allows more control over + * object behavior and, e.g., allows custom slow layout. + */ +#include "jsapi.h" +#include "jsprvtd.h" + +#ifdef __cplusplus + +namespace js { + +class PropertyName; +class SpecialId; +class PropertyId; + +static JS_ALWAYS_INLINE jsid +SPECIALID_TO_JSID(const SpecialId &sid); + +/* + * We partition the ways to refer to a property into three: by an index + * (uint32_t); by a string whose characters do not represent an index + * (PropertyName, see vm/String.h); and by various special values. + * + * Special values are encoded using SpecialId, which is layout-compatible but + * non-interconvertible with jsid. A SpecialId is used for JSID_VOID, which + * does not occur in JS scripts but may be used to indicate the absence of a + * valid identifier. In the future, a SpecialId may also be an object used by + * Harmony-proposed private names. + */ +class SpecialId +{ + uintptr_t bits_; + + /* Needs access to raw bits. */ + friend JS_ALWAYS_INLINE jsid SPECIALID_TO_JSID(const SpecialId &sid); + friend class PropertyId; + + static const uintptr_t TYPE_VOID = JSID_TYPE_VOID; + static const uintptr_t TYPE_OBJECT = JSID_TYPE_OBJECT; + static const uintptr_t TYPE_MASK = JSID_TYPE_MASK; + + SpecialId(uintptr_t bits) : bits_(bits) { } + + public: + SpecialId() : bits_(TYPE_VOID) { } + + /* Object-valued */ + + SpecialId(JSObject &obj) + : bits_(uintptr_t(&obj) | TYPE_OBJECT) + { + JS_ASSERT(&obj != NULL); + JS_ASSERT((uintptr_t(&obj) & TYPE_MASK) == 0); + } + + bool isObject() const { + return (bits_ & TYPE_MASK) == TYPE_OBJECT && bits_ != TYPE_OBJECT; + } + + JSObject *toObject() const { + JS_ASSERT(isObject()); + return reinterpret_cast(bits_ & ~TYPE_MASK); + } + + /* Empty */ + + static SpecialId empty() { + SpecialId sid(TYPE_OBJECT); + JS_ASSERT(sid.isEmpty()); + return sid; + } + + bool isEmpty() const { + return bits_ == TYPE_OBJECT; + } + + /* Void */ + + static SpecialId voidId() { + SpecialId sid(TYPE_VOID); + JS_ASSERT(sid.isVoid()); + return sid; + } + + bool isVoid() const { + return bits_ == TYPE_VOID; + } +}; + +static JS_ALWAYS_INLINE jsid +SPECIALID_TO_JSID(const SpecialId &sid) +{ + jsid id; + JSID_BITS(id) = sid.bits_; + JS_ASSERT_IF(sid.isObject(), JSID_IS_OBJECT(id) && JSID_TO_OBJECT(id) == sid.toObject()); + JS_ASSERT_IF(sid.isVoid(), JSID_IS_VOID(id)); + JS_ASSERT_IF(sid.isEmpty(), JSID_IS_EMPTY(id)); + return id; +} + +static JS_ALWAYS_INLINE bool +JSID_IS_SPECIAL(jsid id) +{ + return JSID_IS_OBJECT(id) || JSID_IS_EMPTY(id) || JSID_IS_VOID(id); +} + +static JS_ALWAYS_INLINE SpecialId +JSID_TO_SPECIALID(jsid id) +{ + JS_ASSERT(JSID_IS_SPECIAL(id)); + if (JSID_IS_OBJECT(id)) + return SpecialId(*JSID_TO_OBJECT(id)); + if (JSID_IS_EMPTY(id)) + return SpecialId::empty(); + JS_ASSERT(JSID_IS_VOID(id)); + return SpecialId::voidId(); +} + +typedef JS::Handle HandleSpecialId; + +/* js::Class operation signatures. */ + +typedef JSBool +(* LookupGenericOp)(JSContext *cx, HandleObject obj, HandleId id, + MutableHandleObject objp, MutableHandleShape propp); +typedef JSBool +(* LookupPropOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, + MutableHandleObject objp, MutableHandleShape propp); +typedef JSBool +(* LookupElementOp)(JSContext *cx, HandleObject obj, uint32_t index, + MutableHandleObject objp, MutableHandleShape propp); +typedef JSBool +(* LookupSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, + MutableHandleObject objp, MutableHandleShape propp); +typedef JSBool +(* DefineGenericOp)(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, + PropertyOp getter, StrictPropertyOp setter, unsigned attrs); +typedef JSBool +(* DefinePropOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue value, + PropertyOp getter, StrictPropertyOp setter, unsigned attrs); +typedef JSBool +(* DefineElementOp)(JSContext *cx, HandleObject obj, uint32_t index, HandleValue value, + PropertyOp getter, StrictPropertyOp setter, unsigned attrs); +typedef JSBool +(* DefineSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, HandleValue value, + PropertyOp getter, StrictPropertyOp setter, unsigned attrs); +typedef JSBool +(* GenericIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, MutableHandleValue vp); +typedef JSBool +(* PropertyIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, MutableHandleValue vp); +typedef JSBool +(* ElementIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp); +typedef JSBool +(* ElementIfPresentOp)(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp, bool* present); +typedef JSBool +(* SpecialIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, MutableHandleValue vp); +typedef JSBool +(* StrictGenericIdOp)(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp, JSBool strict); +typedef JSBool +(* StrictPropertyIdOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, MutableHandleValue vp, JSBool strict); +typedef JSBool +(* StrictElementIdOp)(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleValue vp, JSBool strict); +typedef JSBool +(* StrictSpecialIdOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, MutableHandleValue vp, JSBool strict); +typedef JSBool +(* GenericAttributesOp)(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp); +typedef JSBool +(* PropertyAttributesOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp); +typedef JSBool +(* ElementAttributesOp)(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp); +typedef JSBool +(* SpecialAttributesOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp); +typedef JSBool +(* DeletePropertyOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, MutableHandleValue vp, JSBool strict); +typedef JSBool +(* DeleteElementOp)(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleValue vp, JSBool strict); +typedef JSBool +(* DeleteSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, MutableHandleValue vp, JSBool strict); + + +typedef JSObject * +(* ObjectOp)(JSContext *cx, HandleObject obj); +typedef void +(* FinalizeOp)(FreeOp *fop, RawObject obj); + +#define JS_CLASS_MEMBERS \ + const char *name; \ + uint32_t flags; \ + \ + /* Mandatory non-null function pointer members. */ \ + JSPropertyOp addProperty; \ + JSPropertyOp delProperty; \ + JSPropertyOp getProperty; \ + JSStrictPropertyOp setProperty; \ + JSEnumerateOp enumerate; \ + JSResolveOp resolve; \ + JSConvertOp convert; \ + FinalizeOp finalize; \ + \ + /* Optionally non-null members start here. */ \ + JSCheckAccessOp checkAccess; \ + JSNative call; \ + JSHasInstanceOp hasInstance; \ + JSNative construct; \ + JSTraceOp trace + +/* + * The helper struct to measure the size of JS_CLASS_MEMBERS to know how much + * we have to padd js::Class to match the size of JSClass; + */ +struct ClassSizeMeasurement +{ + JS_CLASS_MEMBERS; +}; + +struct ClassExtension +{ + JSObjectOp outerObject; + JSObjectOp innerObject; + JSIteratorOp iteratorObject; + + /* + * isWrappedNative is true only if the class is an XPCWrappedNative. + * WeakMaps use this to override the wrapper disposal optimization. + */ + bool isWrappedNative; + + /* + * If an object is used as a key in a weakmap, it may be desirable for the + * garbage collector to keep that object around longer than it otherwise + * would. A common case is when the key is a wrapper around an object in + * another compartment, and we want to avoid collecting the wrapper (and + * removing the weakmap entry) as long as the wrapped object is alive. In + * that case, the wrapped object is returned by the wrapper's + * weakmapKeyDelegateOp hook. As long as the wrapper is used as a weakmap + * key, it will not be collected (and remain in the weakmap) until the + * wrapped object is collected. + */ + JSWeakmapKeyDelegateOp weakmapKeyDelegateOp; +}; + +#define JS_NULL_CLASS_EXT {NULL,NULL,NULL,false,NULL} + +struct ObjectOps +{ + LookupGenericOp lookupGeneric; + LookupPropOp lookupProperty; + LookupElementOp lookupElement; + LookupSpecialOp lookupSpecial; + DefineGenericOp defineGeneric; + DefinePropOp defineProperty; + DefineElementOp defineElement; + DefineSpecialOp defineSpecial; + GenericIdOp getGeneric; + PropertyIdOp getProperty; + ElementIdOp getElement; + ElementIfPresentOp getElementIfPresent; /* can be null */ + SpecialIdOp getSpecial; + StrictGenericIdOp setGeneric; + StrictPropertyIdOp setProperty; + StrictElementIdOp setElement; + StrictSpecialIdOp setSpecial; + GenericAttributesOp getGenericAttributes; + PropertyAttributesOp getPropertyAttributes; + ElementAttributesOp getElementAttributes; + SpecialAttributesOp getSpecialAttributes; + GenericAttributesOp setGenericAttributes; + PropertyAttributesOp setPropertyAttributes; + ElementAttributesOp setElementAttributes; + SpecialAttributesOp setSpecialAttributes; + DeletePropertyOp deleteProperty; + DeleteElementOp deleteElement; + DeleteSpecialOp deleteSpecial; + + JSNewEnumerateOp enumerate; + ObjectOp thisObject; +}; + +#define JS_NULL_OBJECT_OPS \ + {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, \ + NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, \ + NULL,NULL,NULL} + +struct Class +{ + JS_CLASS_MEMBERS; + ClassExtension ext; + ObjectOps ops; + uint8_t pad[sizeof(JSClass) - sizeof(ClassSizeMeasurement) - + sizeof(ClassExtension) - sizeof(ObjectOps)]; + + /* Class is not native and its map is not a scope. */ + static const uint32_t NON_NATIVE = JSCLASS_INTERNAL_FLAG2; + + bool isNative() const { + return !(flags & NON_NATIVE); + } + + bool hasPrivate() const { + return !!(flags & JSCLASS_HAS_PRIVATE); + } + + bool emulatesUndefined() const { + return flags & JSCLASS_EMULATES_UNDEFINED; + } + + static size_t offsetOfFlags() { return offsetof(Class, flags); } +}; + +JS_STATIC_ASSERT(offsetof(JSClass, name) == offsetof(Class, name)); +JS_STATIC_ASSERT(offsetof(JSClass, flags) == offsetof(Class, flags)); +JS_STATIC_ASSERT(offsetof(JSClass, addProperty) == offsetof(Class, addProperty)); +JS_STATIC_ASSERT(offsetof(JSClass, delProperty) == offsetof(Class, delProperty)); +JS_STATIC_ASSERT(offsetof(JSClass, getProperty) == offsetof(Class, getProperty)); +JS_STATIC_ASSERT(offsetof(JSClass, setProperty) == offsetof(Class, setProperty)); +JS_STATIC_ASSERT(offsetof(JSClass, enumerate) == offsetof(Class, enumerate)); +JS_STATIC_ASSERT(offsetof(JSClass, resolve) == offsetof(Class, resolve)); +JS_STATIC_ASSERT(offsetof(JSClass, convert) == offsetof(Class, convert)); +JS_STATIC_ASSERT(offsetof(JSClass, finalize) == offsetof(Class, finalize)); +JS_STATIC_ASSERT(offsetof(JSClass, checkAccess) == offsetof(Class, checkAccess)); +JS_STATIC_ASSERT(offsetof(JSClass, call) == offsetof(Class, call)); +JS_STATIC_ASSERT(offsetof(JSClass, construct) == offsetof(Class, construct)); +JS_STATIC_ASSERT(offsetof(JSClass, hasInstance) == offsetof(Class, hasInstance)); +JS_STATIC_ASSERT(offsetof(JSClass, trace) == offsetof(Class, trace)); +JS_STATIC_ASSERT(sizeof(JSClass) == sizeof(Class)); + +static JS_ALWAYS_INLINE JSClass * +Jsvalify(Class *c) +{ + return (JSClass *)c; +} +static JS_ALWAYS_INLINE const JSClass * +Jsvalify(const Class *c) +{ + return (const JSClass *)c; +} + +static JS_ALWAYS_INLINE Class * +Valueify(JSClass *c) +{ + return (Class *)c; +} +static JS_ALWAYS_INLINE const Class * +Valueify(const JSClass *c) +{ + return (const Class *)c; +} + +/* + * Enumeration describing possible values of the [[Class]] internal property + * value of objects. + */ +enum ESClassValue { + ESClass_Array, ESClass_Number, ESClass_String, ESClass_Boolean, + ESClass_RegExp, ESClass_ArrayBuffer +}; + +/* + * Return whether the given object has the given [[Class]] internal property + * value. Beware, this query says nothing about the js::Class of the JSObject + * so the caller must not assume anything about obj's representation (e.g., obj + * may be a proxy). + */ +inline bool +ObjectClassIs(JSObject &obj, ESClassValue classValue, JSContext *cx); + +/* Just a helper that checks v.isObject before calling ObjectClassIs. */ +inline bool +IsObjectWithClass(const Value &v, ESClassValue classValue, JSContext *cx); + +inline bool +IsPoisonedSpecialId(js::SpecialId iden) +{ + if (iden.isObject()) + return IsPoisonedPtr(iden.toObject()); + return false; +} + +template <> struct RootMethods +{ + static SpecialId initial() { return SpecialId(); } + static ThingRootKind kind() { return THING_ROOT_ID; } + static bool poisoned(SpecialId id) { return IsPoisonedSpecialId(id); } +}; + +} /* namespace js */ + +#endif /* __cplusplus */ + +#endif /* jsclass_h__ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsclist.h b/scripting/javascript/spidermonkey-mac/include/jsclist.h new file mode 100644 index 0000000000..4881104eee --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsclist.h @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsclist_h___ +#define jsclist_h___ + +#include "jstypes.h" + +/* +** Circular linked list +*/ +typedef struct JSCListStr { + struct JSCListStr *next; + struct JSCListStr *prev; +} JSCList; + +/* +** Insert element "_e" into the list, before "_l". +*/ +#define JS_INSERT_BEFORE(_e,_l) \ + JS_BEGIN_MACRO \ + (_e)->next = (_l); \ + (_e)->prev = (_l)->prev; \ + (_l)->prev->next = (_e); \ + (_l)->prev = (_e); \ + JS_END_MACRO + +/* +** Insert element "_e" into the list, after "_l". +*/ +#define JS_INSERT_AFTER(_e,_l) \ + JS_BEGIN_MACRO \ + (_e)->next = (_l)->next; \ + (_e)->prev = (_l); \ + (_l)->next->prev = (_e); \ + (_l)->next = (_e); \ + JS_END_MACRO + +/* +** Return the element following element "_e" +*/ +#define JS_NEXT_LINK(_e) \ + ((_e)->next) +/* +** Return the element preceding element "_e" +*/ +#define JS_PREV_LINK(_e) \ + ((_e)->prev) + +/* +** Append an element "_e" to the end of the list "_l" +*/ +#define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l) + +/* +** Insert an element "_e" at the head of the list "_l" +*/ +#define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l) + +/* Return the head/tail of the list */ +#define JS_LIST_HEAD(_l) (_l)->next +#define JS_LIST_TAIL(_l) (_l)->prev + +/* +** Remove the element "_e" from it's circular list. +*/ +#define JS_REMOVE_LINK(_e) \ + JS_BEGIN_MACRO \ + (_e)->prev->next = (_e)->next; \ + (_e)->next->prev = (_e)->prev; \ + JS_END_MACRO + +/* +** Remove the element "_e" from it's circular list. Also initializes the +** linkage. +*/ +#define JS_REMOVE_AND_INIT_LINK(_e) \ + JS_BEGIN_MACRO \ + (_e)->prev->next = (_e)->next; \ + (_e)->next->prev = (_e)->prev; \ + (_e)->next = (_e); \ + (_e)->prev = (_e); \ + JS_END_MACRO + +/* +** Return non-zero if the given circular list "_l" is empty, zero if the +** circular list is not empty +*/ +#define JS_CLIST_IS_EMPTY(_l) \ + ((_l)->next == (_l)) + +/* +** Initialize a circular list +*/ +#define JS_INIT_CLIST(_l) \ + JS_BEGIN_MACRO \ + (_l)->next = (_l); \ + (_l)->prev = (_l); \ + JS_END_MACRO + +#define JS_INIT_STATIC_CLIST(_l) \ + {(_l), (_l)} + +#endif /* jsclist_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jscpucfg.h b/scripting/javascript/spidermonkey-mac/include/jscpucfg.h new file mode 100644 index 0000000000..3d2022dbe2 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jscpucfg.h @@ -0,0 +1,121 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef js_cpucfg___ +#define js_cpucfg___ + +#define JS_HAVE_LONG_LONG + +#if defined(_WIN64) + +# if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) +# define IS_LITTLE_ENDIAN 1 +# undef IS_BIG_ENDIAN +# define JS_BYTES_PER_DOUBLE 8 +# define JS_BYTES_PER_WORD 8 +# define JS_BITS_PER_WORD_LOG2 6 +# define JS_ALIGN_OF_POINTER 8 +# else /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ +# error "CPU type is unknown" +# endif /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ + +#elif defined(_WIN32) || defined(XP_OS2) + +# ifdef __WATCOMC__ +# define HAVE_VA_LIST_AS_ARRAY 1 +# endif + +# define IS_LITTLE_ENDIAN 1 +# undef IS_BIG_ENDIAN +# define JS_BYTES_PER_DOUBLE 8 +# define JS_BYTES_PER_WORD 4 +# define JS_BITS_PER_WORD_LOG2 5 +# define JS_ALIGN_OF_POINTER 4 + +#elif defined(__APPLE__) +# if __LITTLE_ENDIAN__ +# define IS_LITTLE_ENDIAN 1 +# undef IS_BIG_ENDIAN +# elif __BIG_ENDIAN__ +# undef IS_LITTLE_ENDIAN +# define IS_BIG_ENDIAN 1 +# endif + +#elif defined(JS_HAVE_ENDIAN_H) +# include + +# if defined(__BYTE_ORDER) +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define IS_LITTLE_ENDIAN 1 +# undef IS_BIG_ENDIAN +# elif __BYTE_ORDER == __BIG_ENDIAN +# undef IS_LITTLE_ENDIAN +# define IS_BIG_ENDIAN 1 +# endif +# else /* !defined(__BYTE_ORDER) */ +# error "endian.h does not define __BYTE_ORDER. Cannot determine endianness." +# endif + +/* BSDs */ +#elif defined(JS_HAVE_MACHINE_ENDIAN_H) +# include +# include + +# if defined(_BYTE_ORDER) +# if _BYTE_ORDER == _LITTLE_ENDIAN +# define IS_LITTLE_ENDIAN 1 +# undef IS_BIG_ENDIAN +# elif _BYTE_ORDER == _BIG_ENDIAN +# undef IS_LITTLE_ENDIAN +# define IS_BIG_ENDIAN 1 +# endif +# else /* !defined(_BYTE_ORDER) */ +# error "machine/endian.h does not define _BYTE_ORDER. Cannot determine endianness." +# endif + +#elif defined(JS_HAVE_SYS_ISA_DEFS_H) +# include + +# if defined(_BIG_ENDIAN) +# undef IS_LITTLE_ENDIAN +# define IS_BIG_ENDIAN 1 +# elif defined(_LITTLE_ENDIAN) +# define IS_LITTLE_ENDIAN 1 +# undef IS_BIG_ENDIAN +# else /* !defined(_LITTLE_ENDIAN) */ +# error "sys/isa_defs.h does not define _BIG_ENDIAN or _LITTLE_ENDIAN. Cannot determine endianness." +# endif +# if !defined(JS_STACK_GROWTH_DIRECTION) +# if defined(_STACK_GROWS_UPWARD) +# define JS_STACK_GROWTH_DIRECTION (1) +# elif defined(_STACK_GROWS_DOWNWARD) +# define JS_STACK_GROWTH_DIRECTION (-1) +# endif +# endif + +#elif defined(__sparc) || defined(__sparc__) || \ + defined(_POWER) || defined(__powerpc__) || \ + defined(__ppc__) || defined(__hppa) || \ + defined(_MIPSEB) || defined(_BIG_ENDIAN) +/* IA64 running HP-UX will have _BIG_ENDIAN defined. + * IA64 running Linux will have endian.h and be handled above. + */ +# undef IS_LITTLE_ENDIAN +# define IS_BIG_ENDIAN 1 + +#else /* !defined(__sparc) && !defined(__sparc__) && ... */ +# error "Cannot determine endianness of your platform. Please add support to jscpucfg.h." +#endif + +#ifndef JS_STACK_GROWTH_DIRECTION +# ifdef __hppa +# define JS_STACK_GROWTH_DIRECTION (1) +# else +# define JS_STACK_GROWTH_DIRECTION (-1) +# endif +#endif + +#endif /* js_cpucfg___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsdbgapi.h b/scripting/javascript/spidermonkey-mac/include/jsdbgapi.h new file mode 100644 index 0000000000..ba40cd3e01 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsdbgapi.h @@ -0,0 +1,475 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsdbgapi_h___ +#define jsdbgapi_h___ +/* + * JS debugger API. + */ +#include "jsapi.h" +#include "jsprvtd.h" + +namespace JS { + +struct FrameDescription +{ + JSScript *script; + unsigned lineno; + JSFunction *fun; +}; + +struct StackDescription +{ + unsigned nframes; + FrameDescription *frames; +}; + +extern JS_PUBLIC_API(StackDescription *) +DescribeStack(JSContext *cx, unsigned maxFrames); + +extern JS_PUBLIC_API(void) +FreeStackDescription(JSContext *cx, StackDescription *desc); + +extern JS_PUBLIC_API(char *) +FormatStackDump(JSContext *cx, char *buf, + JSBool showArgs, JSBool showLocals, + JSBool showThisProps); + +} + +# ifdef DEBUG +JS_FRIEND_API(void) js_DumpValue(const js::Value &val); +JS_FRIEND_API(void) js_DumpId(jsid id); +JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = NULL); +# endif + +JS_FRIEND_API(void) +js_DumpBacktrace(JSContext *cx); + +extern JS_PUBLIC_API(JSCompartment *) +JS_EnterCompartmentOfScript(JSContext *cx, JSScript *target); + +extern JS_PUBLIC_API(JSString *) +JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent); + +/* + * Currently, we only support runtime-wide debugging. In the future, we should + * be able to support compartment-wide debugging. + */ +extern JS_PUBLIC_API(void) +JS_SetRuntimeDebugMode(JSRuntime *rt, JSBool debug); + +/* + * Debug mode is a compartment-wide mode that enables a debugger to attach + * to and interact with running methodjit-ed frames. In particular, it causes + * every function to be compiled as if an eval was present (so eval-in-frame) + * can work, and it ensures that functions can be re-JITed for other debug + * features. In general, it is not safe to interact with frames that were live + * before debug mode was enabled. For this reason, it is also not safe to + * enable debug mode while frames are live. + */ + +/* Get current state of debugging mode. */ +extern JS_PUBLIC_API(JSBool) +JS_GetDebugMode(JSContext *cx); + +/* + * Turn on/off debugging mode for all compartments. This returns false if any code + * from any of the runtime's compartments is running or on the stack. + */ +JS_FRIEND_API(JSBool) +JS_SetDebugModeForAllCompartments(JSContext *cx, JSBool debug); + +/* + * Turn on/off debugging mode for a single compartment. This should only be + * used when no code from this compartment is running or on the stack in any + * thread. + */ +JS_FRIEND_API(JSBool) +JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug); + +/* + * Turn on/off debugging mode for a context's compartment. + */ +JS_FRIEND_API(JSBool) +JS_SetDebugMode(JSContext *cx, JSBool debug); + +/* Turn on single step mode. */ +extern JS_PUBLIC_API(JSBool) +JS_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep); + +/* The closure argument will be marked. */ +extern JS_PUBLIC_API(JSBool) +JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc, + JSTrapHandler handler, jsval closure); + +extern JS_PUBLIC_API(void) +JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc, + JSTrapHandler *handlerp, jsval *closurep); + +extern JS_PUBLIC_API(void) +JS_ClearScriptTraps(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(void) +JS_ClearAllTrapsForCompartment(JSContext *cx); + +extern JS_PUBLIC_API(JSBool) +JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure); + +extern JS_PUBLIC_API(JSBool) +JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep); + +/************************************************************************/ + +extern JS_PUBLIC_API(JSBool) +JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id, + JSWatchPointHandler handler, JSObject *closure); + +extern JS_PUBLIC_API(JSBool) +JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id, + JSWatchPointHandler *handlerp, JSObject **closurep); + +extern JS_PUBLIC_API(JSBool) +JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj); + +extern JS_PUBLIC_API(JSBool) +JS_ClearAllWatchPoints(JSContext *cx); + +/************************************************************************/ + +// RawScript because this needs to be callable from a signal handler +extern JS_PUBLIC_API(unsigned) +JS_PCToLineNumber(JSContext *cx, js::RawScript script, jsbytecode *pc); + +extern JS_PUBLIC_API(jsbytecode *) +JS_LineNumberToPC(JSContext *cx, JSScript *script, unsigned lineno); + +extern JS_PUBLIC_API(jsbytecode *) +JS_EndPC(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(JSBool) +JS_GetLinePCs(JSContext *cx, JSScript *script, + unsigned startLine, unsigned maxLines, + unsigned* count, unsigned** lines, jsbytecode*** pcs); + +extern JS_PUBLIC_API(unsigned) +JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun); + +extern JS_PUBLIC_API(JSBool) +JS_FunctionHasLocalNames(JSContext *cx, JSFunction *fun); + +/* + * N.B. The mark is in the context temp pool and thus the caller must take care + * to call JS_ReleaseFunctionLocalNameArray in a LIFO manner (wrt to any other + * call that may use the temp pool. + */ +extern JS_PUBLIC_API(uintptr_t *) +JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp); + +extern JS_PUBLIC_API(JSAtom *) +JS_LocalNameToAtom(uintptr_t w); + +extern JS_PUBLIC_API(JSString *) +JS_AtomKey(JSAtom *atom); + +extern JS_PUBLIC_API(void) +JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark); + +extern JS_PUBLIC_API(JSScript *) +JS_GetFunctionScript(JSContext *cx, JSFunction *fun); + +extern JS_PUBLIC_API(JSNative) +JS_GetFunctionNative(JSContext *cx, JSFunction *fun); + +extern JS_PUBLIC_API(JSPrincipals *) +JS_GetScriptPrincipals(JSScript *script); + +extern JS_PUBLIC_API(JSPrincipals *) +JS_GetScriptOriginPrincipals(JSScript *script); + +JS_PUBLIC_API(JSFunction *) +JS_GetScriptFunction(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(JSObject *) +JS_GetParentOrScopeChain(JSContext *cx, JSObject *obj); + +/************************************************************************/ + +/* + * This is almost JS_GetClass(obj)->name except that certain debug-only + * proxies are made transparent. In particular, this function turns the class + * of any scope (returned via JS_GetFrameScopeChain or JS_GetFrameCalleeObject) + * from "Proxy" to "Call", "Block", "With" etc. + */ +extern JS_PUBLIC_API(const char *) +JS_GetDebugClassName(JSObject *obj); + +/************************************************************************/ + +extern JS_PUBLIC_API(const char *) +JS_GetScriptFilename(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(const jschar *) +JS_GetScriptSourceMap(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(unsigned) +JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(unsigned) +JS_GetScriptLineExtent(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(JSVersion) +JS_GetScriptVersion(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(bool) +JS_GetScriptUserBit(JSScript *script); + +extern JS_PUBLIC_API(void) +JS_SetScriptUserBit(JSScript *script, bool b); + +extern JS_PUBLIC_API(bool) +JS_GetScriptIsSelfHosted(JSScript *script); + +/************************************************************************/ + +/* + * Hook setters for script creation and destruction, see jsprvtd.h for the + * typedefs. These macros provide binary compatibility and newer, shorter + * synonyms. + */ +#define JS_SetNewScriptHook JS_SetNewScriptHookProc +#define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc + +extern JS_PUBLIC_API(void) +JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata); + +extern JS_PUBLIC_API(void) +JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook, + void *callerdata); + +/************************************************************************/ + +typedef struct JSPropertyDesc { + jsval id; /* primary id, atomized string, or int */ + jsval value; /* property value */ + uint8_t flags; /* flags, see below */ + uint8_t spare; /* unused */ + jsval alias; /* alias id if JSPD_ALIAS flag */ +} JSPropertyDesc; + +#define JSPD_ENUMERATE 0x01 /* visible to for/in loop */ +#define JSPD_READONLY 0x02 /* assignment is error */ +#define JSPD_PERMANENT 0x04 /* property cannot be deleted */ +#define JSPD_ALIAS 0x08 /* property has an alias id */ +#define JSPD_EXCEPTION 0x40 /* exception occurred fetching the property, */ + /* value is exception */ +#define JSPD_ERROR 0x80 /* native getter returned JS_FALSE without */ + /* throwing an exception */ + +typedef struct JSPropertyDescArray { + uint32_t length; /* number of elements in array */ + JSPropertyDesc *array; /* alloc'd by Get, freed by Put */ +} JSPropertyDescArray; + +typedef struct JSScopeProperty JSScopeProperty; + +extern JS_PUBLIC_API(JSBool) +JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda); + +extern JS_PUBLIC_API(void) +JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda); + +/************************************************************************/ + +/* + * JSAbstractFramePtr is the public version of AbstractFramePtr, a pointer to a + * StackFrame or baseline JIT frame. + */ +class JS_PUBLIC_API(JSAbstractFramePtr) +{ + uintptr_t ptr_; + + protected: + JSAbstractFramePtr() + : ptr_(0) + { } + + public: + explicit JSAbstractFramePtr(void *raw); + + uintptr_t raw() const { return ptr_; } + + operator bool() const { return !!ptr_; } + + JSObject *scopeChain(JSContext *cx); + JSObject *callObject(JSContext *cx); + + JSFunction *maybeFun(); + JSScript *script(); + + bool getThisValue(JSContext *cx, JS::MutableHandleValue thisv); + + bool isDebuggerFrame(); + + bool evaluateInStackFrame(JSContext *cx, + const char *bytes, unsigned length, + const char *filename, unsigned lineno, + JS::MutableHandleValue rval); + + bool evaluateUCInStackFrame(JSContext *cx, + const jschar *chars, unsigned length, + const char *filename, unsigned lineno, + JS::MutableHandleValue rval); +}; + +class JS_PUBLIC_API(JSNullFramePtr) : public JSAbstractFramePtr +{ + public: + JSNullFramePtr() + : JSAbstractFramePtr() + {} +}; + +/* + * This class does not work when IonMonkey is active. It's only used by jsd, + * which can only be used when IonMonkey is disabled. + * + * To find the calling script and line number, use JS_DescribeSciptedCaller. + * To summarize the call stack, use JS::DescribeStack. + */ +class JS_PUBLIC_API(JSBrokenFrameIterator) +{ + void *data_; + + public: + JSBrokenFrameIterator(JSContext *cx); + ~JSBrokenFrameIterator(); + + bool done() const; + JSBrokenFrameIterator& operator++(); + + JSAbstractFramePtr abstractFramePtr() const; + jsbytecode *pc() const; + + bool isConstructing() const; +}; + +/* + * This hook captures high level script execution and function calls (JS or + * native). It is used by JS_SetExecuteHook to hook top level scripts and by + * JS_SetCallHook to hook function calls. It will get called twice per script + * or function call: just before execution begins and just after it finishes. + * In both cases the 'current' frame is that of the executing code. + * + * The 'before' param is JS_TRUE for the hook invocation before the execution + * and JS_FALSE for the invocation after the code has run. + * + * The 'ok' param is significant only on the post execution invocation to + * signify whether or not the code completed 'normally'. + * + * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook + * for the 'before'invocation, but is whatever value is returned from that + * invocation for the 'after' invocation. Thus, the hook implementor *could* + * allocate a structure in the 'before' invocation and return a pointer to that + * structure. The pointer would then be handed to the hook for the 'after' + * invocation. Alternately, the 'before' could just return the same value as + * in 'closure' to cause the 'after' invocation to be called with the same + * 'closure' value as the 'before'. + * + * Returning NULL in the 'before' hook will cause the 'after' hook *not* to + * be called. + */ +typedef void * +(* JSInterpreterHook)(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, + JSBool before, JSBool *ok, void *closure); + +typedef JSBool +(* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report, + void *closure); + +typedef struct JSDebugHooks { + JSInterruptHook interruptHook; + void *interruptHookData; + JSNewScriptHook newScriptHook; + void *newScriptHookData; + JSDestroyScriptHook destroyScriptHook; + void *destroyScriptHookData; + JSDebuggerHandler debuggerHandler; + void *debuggerHandlerData; + JSSourceHandler sourceHandler; + void *sourceHandlerData; + JSInterpreterHook executeHook; + void *executeHookData; + JSInterpreterHook callHook; + void *callHookData; + JSThrowHook throwHook; + void *throwHookData; + JSDebugErrorHook debugErrorHook; + void *debugErrorHookData; +} JSDebugHooks; + +/************************************************************************/ + +extern JS_PUBLIC_API(JSBool) +JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure); + +extern JS_PUBLIC_API(JSBool) +JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure); + +extern JS_PUBLIC_API(JSBool) +JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure); + +extern JS_PUBLIC_API(JSBool) +JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure); + +extern JS_PUBLIC_API(JSBool) +JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure); + +extern JS_PUBLIC_API(JSBool) +JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure); + +/************************************************************************/ + +extern JS_FRIEND_API(void) +js_RevertVersion(JSContext *cx); + +extern JS_PUBLIC_API(const JSDebugHooks *) +JS_GetGlobalDebugHooks(JSRuntime *rt); + +/** + * Add various profiling-related functions as properties of the given object. + */ +extern JS_PUBLIC_API(JSBool) +JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj); + +/* Defined in vm/Debugger.cpp. */ +extern JS_PUBLIC_API(JSBool) +JS_DefineDebuggerObject(JSContext *cx, JSObject *obj); + +extern JS_PUBLIC_API(void) +JS_DumpBytecode(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(void) +JS_DumpCompartmentBytecode(JSContext *cx); + +extern JS_PUBLIC_API(void) +JS_DumpPCCounts(JSContext *cx, JSScript *script); + +extern JS_PUBLIC_API(void) +JS_DumpCompartmentPCCounts(JSContext *cx); + +extern JS_PUBLIC_API(JSObject *) +JS_UnwrapObject(JSObject *obj); + +extern JS_PUBLIC_API(JSObject *) +JS_UnwrapObjectAndInnerize(JSObject *obj); + +/* Call the context debug handler on the topmost scripted frame. */ +extern JS_FRIEND_API(JSBool) +js_CallContextDebugHandler(JSContext *cx); + +#endif /* jsdbgapi_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsdhash.h b/scripting/javascript/spidermonkey-mac/include/jsdhash.h new file mode 100644 index 0000000000..c8f02b18b7 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsdhash.h @@ -0,0 +1,611 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsdhash_h___ +#define jsdhash_h___ + +/* + * Double hashing, a la Knuth 6. + * + * Try to keep this file in sync with xpcom/glue/pldhash.h. + */ +#include "jstypes.h" +#include "jsutil.h" + +#if defined(__GNUC__) && defined(__i386__) && !defined(XP_OS2) +#define JS_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall)) +#elif defined(XP_WIN) +#define JS_DHASH_FASTCALL __fastcall +#else +#define JS_DHASH_FASTCALL +#endif + +#ifdef DEBUG_XXXbrendan +#define JS_DHASHMETER 1 +#endif + +/* Table size limit, do not equal or exceed (see min&maxAlphaFrac, below). */ +#undef JS_DHASH_SIZE_LIMIT +#define JS_DHASH_SIZE_LIMIT JS_BIT(24) + +/* Minimum table size, or gross entry count (net is at most .75 loaded). */ +#ifndef JS_DHASH_MIN_SIZE +#define JS_DHASH_MIN_SIZE 16 +#elif (JS_DHASH_MIN_SIZE & (JS_DHASH_MIN_SIZE - 1)) != 0 +#error "JS_DHASH_MIN_SIZE must be a power of two!" +#endif + +/* + * Multiplicative hash uses an unsigned 32 bit integer and the golden ratio, + * expressed as a fixed-point 32-bit fraction. + */ +#define JS_DHASH_BITS 32 +#define JS_DHASH_GOLDEN_RATIO 0x9E3779B9U + +/* Primitive and forward-struct typedefs. */ +typedef uint32_t JSDHashNumber; +typedef struct JSDHashEntryHdr JSDHashEntryHdr; +typedef struct JSDHashEntryStub JSDHashEntryStub; +typedef struct JSDHashTable JSDHashTable; +typedef struct JSDHashTableOps JSDHashTableOps; + +/* + * Table entry header structure. + * + * In order to allow in-line allocation of key and value, we do not declare + * either here. Instead, the API uses const void *key as a formal parameter. + * The key need not be stored in the entry; it may be part of the value, but + * need not be stored at all. + * + * Callback types are defined below and grouped into the JSDHashTableOps + * structure, for single static initialization per hash table sub-type. + * + * Each hash table sub-type should nest the JSDHashEntryHdr structure at the + * front of its particular entry type. The keyHash member contains the result + * of multiplying the hash code returned from the hashKey callback (see below) + * by JS_DHASH_GOLDEN_RATIO, then constraining the result to avoid the magic 0 + * and 1 values. The stored keyHash value is table size invariant, and it is + * maintained automatically by JS_DHashTableOperate -- users should never set + * it, and its only uses should be via the entry macros below. + * + * The JS_DHASH_ENTRY_IS_LIVE macro tests whether entry is neither free nor + * removed. An entry may be either busy or free; if busy, it may be live or + * removed. Consumers of this API should not access members of entries that + * are not live. + * + * However, use JS_DHASH_ENTRY_IS_BUSY for faster liveness testing of entries + * returned by JS_DHashTableOperate, as JS_DHashTableOperate never returns a + * non-live, busy (i.e., removed) entry pointer to its caller. See below for + * more details on JS_DHashTableOperate's calling rules. + */ +struct JSDHashEntryHdr { + JSDHashNumber keyHash; /* every entry must begin like this */ +}; + +MOZ_ALWAYS_INLINE bool +JS_DHASH_ENTRY_IS_FREE(JSDHashEntryHdr* entry) +{ + return entry->keyHash == 0; +} +MOZ_ALWAYS_INLINE bool +JS_DHASH_ENTRY_IS_BUSY(JSDHashEntryHdr* entry) +{ + return !JS_DHASH_ENTRY_IS_FREE(entry); +} +MOZ_ALWAYS_INLINE bool +JS_DHASH_ENTRY_IS_LIVE(JSDHashEntryHdr* entry) +{ + return entry->keyHash >= 2; +} + +/* + * A JSDHashTable is currently 8 words (without the JS_DHASHMETER overhead) + * on most architectures, and may be allocated on the stack or within another + * structure or class (see below for the Init and Finish functions to use). + * + * To decide whether to use double hashing vs. chaining, we need to develop a + * trade-off relation, as follows: + * + * Let alpha be the load factor, esize the entry size in words, count the + * entry count, and pow2 the power-of-two table size in entries. + * + * (JSDHashTable overhead) > (JSHashTable overhead) + * (unused table entry space) > (malloc and .next overhead per entry) + + * (buckets overhead) + * (1 - alpha) * esize * pow2 > 2 * count + pow2 + * + * Notice that alpha is by definition (count / pow2): + * + * (1 - alpha) * esize * pow2 > 2 * alpha * pow2 + pow2 + * (1 - alpha) * esize > 2 * alpha + 1 + * + * esize > (1 + 2 * alpha) / (1 - alpha) + * + * This assumes both tables must keep keyHash, key, and value for each entry, + * where key and value point to separately allocated strings or structures. + * If key and value can be combined into one pointer, then the trade-off is: + * + * esize > (1 + 3 * alpha) / (1 - alpha) + * + * If the entry value can be a subtype of JSDHashEntryHdr, rather than a type + * that must be allocated separately and referenced by an entry.value pointer + * member, and provided key's allocation can be fused with its entry's, then + * k (the words wasted per entry with chaining) is 4. + * + * To see these curves, feed gnuplot input like so: + * + * gnuplot> f(x,k) = (1 + k * x) / (1 - x) + * gnuplot> plot [0:.75] f(x,2), f(x,3), f(x,4) + * + * For k of 2 and a well-loaded table (alpha > .5), esize must be more than 4 + * words for chaining to be more space-efficient than double hashing. + * + * Solving for alpha helps us decide when to shrink an underloaded table: + * + * esize > (1 + k * alpha) / (1 - alpha) + * esize - alpha * esize > 1 + k * alpha + * esize - 1 > (k + esize) * alpha + * (esize - 1) / (k + esize) > alpha + * + * alpha < (esize - 1) / (esize + k) + * + * Therefore double hashing should keep alpha >= (esize - 1) / (esize + k), + * assuming esize is not too large (in which case, chaining should probably be + * used for any alpha). For esize=2 and k=3, we want alpha >= .2; for esize=3 + * and k=2, we want alpha >= .4. For k=4, esize could be 6, and alpha >= .5 + * would still obtain. See the JS_DHASH_MIN_ALPHA macro further below. + * + * The current implementation uses a configurable lower bound on alpha, which + * defaults to .25, when deciding to shrink the table (while still respecting + * JS_DHASH_MIN_SIZE). + * + * Note a qualitative difference between chaining and double hashing: under + * chaining, entry addresses are stable across table shrinks and grows. With + * double hashing, you can't safely hold an entry pointer and use it after an + * ADD or REMOVE operation, unless you sample table->generation before adding + * or removing, and compare the sample after, dereferencing the entry pointer + * only if table->generation has not changed. + * + * The moral of this story: there is no one-size-fits-all hash table scheme, + * but for small table entry size, and assuming entry address stability is not + * required, double hashing wins. + */ +struct JSDHashTable { + const JSDHashTableOps *ops; /* virtual operations, see below */ + void *data; /* ops- and instance-specific data */ + int16_t hashShift; /* multiplicative hash shift */ + uint8_t maxAlphaFrac; /* 8-bit fixed point max alpha */ + uint8_t minAlphaFrac; /* 8-bit fixed point min alpha */ + uint32_t entrySize; /* number of bytes in an entry */ + uint32_t entryCount; /* number of entries in table */ + uint32_t removedCount; /* removed entry sentinels in table */ + uint32_t generation; /* entry storage generation number */ + char *entryStore; /* entry storage */ +#ifdef JS_DHASHMETER + struct JSDHashStats { + uint32_t searches; /* total number of table searches */ + uint32_t steps; /* hash chain links traversed */ + uint32_t hits; /* searches that found key */ + uint32_t misses; /* searches that didn't find key */ + uint32_t lookups; /* number of JS_DHASH_LOOKUPs */ + uint32_t addMisses; /* adds that miss, and do work */ + uint32_t addOverRemoved; /* adds that recycled a removed entry */ + uint32_t addHits; /* adds that hit an existing entry */ + uint32_t addFailures; /* out-of-memory during add growth */ + uint32_t removeHits; /* removes that hit, and do work */ + uint32_t removeMisses; /* useless removes that miss */ + uint32_t removeFrees; /* removes that freed entry directly */ + uint32_t removeEnums; /* removes done by Enumerate */ + uint32_t grows; /* table expansions */ + uint32_t shrinks; /* table contractions */ + uint32_t compresses; /* table compressions */ + uint32_t enumShrinks; /* contractions after Enumerate */ + } stats; +#endif +}; + +/* + * Size in entries (gross, not net of free and removed sentinels) for table. + * We store hashShift rather than sizeLog2 to optimize the collision-free case + * in SearchTable. + */ +#define JS_DHASH_TABLE_SIZE(table) JS_BIT(JS_DHASH_BITS - (table)->hashShift) + +/* + * Table space at entryStore is allocated and freed using these callbacks. + * The allocator should return null on error only (not if called with nbytes + * equal to 0; but note that jsdhash.c code will never call with 0 nbytes). + */ +typedef void * +(* JSDHashAllocTable)(JSDHashTable *table, uint32_t nbytes); + +typedef void +(* JSDHashFreeTable) (JSDHashTable *table, void *ptr); + +/* + * Compute the hash code for a given key to be looked up, added, or removed + * from table. A hash code may have any JSDHashNumber value. + */ +typedef JSDHashNumber +(* JSDHashHashKey) (JSDHashTable *table, const void *key); + +/* + * Compare the key identifying entry in table with the provided key parameter. + * Return JS_TRUE if keys match, JS_FALSE otherwise. + */ +typedef JSBool +(* JSDHashMatchEntry)(JSDHashTable *table, const JSDHashEntryHdr *entry, + const void *key); + +/* + * Copy the data starting at from to the new entry storage at to. Do not add + * reference counts for any strong references in the entry, however, as this + * is a "move" operation: the old entry storage at from will be freed without + * any reference-decrementing callback shortly. + */ +typedef void +(* JSDHashMoveEntry)(JSDHashTable *table, const JSDHashEntryHdr *from, + JSDHashEntryHdr *to); + +/* + * Clear the entry and drop any strong references it holds. This callback is + * invoked during a JS_DHASH_REMOVE operation (see below for operation codes), + * but only if the given key is found in the table. + */ +typedef void +(* JSDHashClearEntry)(JSDHashTable *table, JSDHashEntryHdr *entry); + +/* + * Called when a table (whether allocated dynamically by itself, or nested in + * a larger structure, or allocated on the stack) is finished. This callback + * allows table->ops-specific code to finalize table->data. + */ +typedef void +(* JSDHashFinalize) (JSDHashTable *table); + +/* + * Initialize a new entry, apart from keyHash. This function is called when + * JS_DHashTableOperate's JS_DHASH_ADD case finds no existing entry for the + * given key, and must add a new one. At that point, entry->keyHash is not + * set yet, to avoid claiming the last free entry in a severely overloaded + * table. + */ +typedef JSBool +(* JSDHashInitEntry)(JSDHashTable *table, JSDHashEntryHdr *entry, + const void *key); + +/* + * Finally, the "vtable" structure for JSDHashTable. The first eight hooks + * must be provided by implementations; they're called unconditionally by the + * generic jsdhash.c code. Hooks after these may be null. + * + * Summary of allocation-related hook usage with C++ placement new emphasis: + * allocTable Allocate raw bytes with malloc, no ctors run. + * freeTable Free raw bytes with free, no dtors run. + * initEntry Call placement new using default key-based ctor. + * Return JS_TRUE on success, JS_FALSE on error. + * moveEntry Call placement new using copy ctor, run dtor on old + * entry storage. + * clearEntry Run dtor on entry. + * finalize Stub unless table->data was initialized and needs to + * be finalized. + * + * Note the reason why initEntry is optional: the default hooks (stubs) clear + * entry storage: On successful JS_DHashTableOperate(tbl, key, JS_DHASH_ADD), + * the returned entry pointer addresses an entry struct whose keyHash member + * has been set non-zero, but all other entry members are still clear (null). + * JS_DHASH_ADD callers can test such members to see whether the entry was + * newly created by the JS_DHASH_ADD call that just succeeded. If placement + * new or similar initialization is required, define an initEntry hook. Of + * course, the clearEntry hook must zero or null appropriately. + * + * XXX assumes 0 is null for pointer types. + */ +struct JSDHashTableOps { + /* Mandatory hooks. All implementations must provide these. */ + JSDHashAllocTable allocTable; + JSDHashFreeTable freeTable; + JSDHashHashKey hashKey; + JSDHashMatchEntry matchEntry; + JSDHashMoveEntry moveEntry; + JSDHashClearEntry clearEntry; + JSDHashFinalize finalize; + + /* Optional hooks start here. If null, these are not called. */ + JSDHashInitEntry initEntry; +}; + +/* + * Default implementations for the above ops. + */ +extern JS_PUBLIC_API(void *) +JS_DHashAllocTable(JSDHashTable *table, uint32_t nbytes); + +extern JS_PUBLIC_API(void) +JS_DHashFreeTable(JSDHashTable *table, void *ptr); + +extern JS_PUBLIC_API(JSDHashNumber) +JS_DHashStringKey(JSDHashTable *table, const void *key); + +/* A minimal entry contains a keyHash header and a void key pointer. */ +struct JSDHashEntryStub { + JSDHashEntryHdr hdr; + const void *key; +}; + +extern JS_PUBLIC_API(JSDHashNumber) +JS_DHashVoidPtrKeyStub(JSDHashTable *table, const void *key); + +extern JS_PUBLIC_API(JSBool) +JS_DHashMatchEntryStub(JSDHashTable *table, + const JSDHashEntryHdr *entry, + const void *key); + +extern JS_PUBLIC_API(JSBool) +JS_DHashMatchStringKey(JSDHashTable *table, + const JSDHashEntryHdr *entry, + const void *key); + +extern JS_PUBLIC_API(void) +JS_DHashMoveEntryStub(JSDHashTable *table, + const JSDHashEntryHdr *from, + JSDHashEntryHdr *to); + +extern JS_PUBLIC_API(void) +JS_DHashClearEntryStub(JSDHashTable *table, JSDHashEntryHdr *entry); + +extern JS_PUBLIC_API(void) +JS_DHashFreeStringKey(JSDHashTable *table, JSDHashEntryHdr *entry); + +extern JS_PUBLIC_API(void) +JS_DHashFinalizeStub(JSDHashTable *table); + +/* + * If you use JSDHashEntryStub or a subclass of it as your entry struct, and + * if your entries move via memcpy and clear via memset(0), you can use these + * stub operations. + */ +extern JS_PUBLIC_API(const JSDHashTableOps *) +JS_DHashGetStubOps(void); + +/* + * Dynamically allocate a new JSDHashTable using malloc, initialize it using + * JS_DHashTableInit, and return its address. Return null on malloc failure. + * Note that the entry storage at table->entryStore will be allocated using + * the ops->allocTable callback. + */ +extern JS_PUBLIC_API(JSDHashTable *) +JS_NewDHashTable(const JSDHashTableOps *ops, void *data, uint32_t entrySize, + uint32_t capacity); + +/* + * Finalize table's data, free its entry storage (via table->ops->freeTable), + * and return the memory starting at table to the malloc heap. + */ +extern JS_PUBLIC_API(void) +JS_DHashTableDestroy(JSDHashTable *table); + +/* + * Initialize table with ops, data, entrySize, and capacity. Capacity is a + * guess for the smallest table size at which the table will usually be less + * than 75% loaded (the table will grow or shrink as needed; capacity serves + * only to avoid inevitable early growth from JS_DHASH_MIN_SIZE). + */ +extern JS_PUBLIC_API(JSBool) +JS_DHashTableInit(JSDHashTable *table, const JSDHashTableOps *ops, void *data, + uint32_t entrySize, uint32_t capacity); + +/* + * Set maximum and minimum alpha for table. The defaults are 0.75 and .25. + * maxAlpha must be in [0.5, 0.9375] for the default JS_DHASH_MIN_SIZE; or if + * MinSize=JS_DHASH_MIN_SIZE <= 256, in [0.5, (float)(MinSize-1)/MinSize]; or + * else in [0.5, 255.0/256]. minAlpha must be in [0, maxAlpha / 2), so that + * we don't shrink on the very next remove after growing a table upon adding + * an entry that brings entryCount past maxAlpha * tableSize. + */ +extern JS_PUBLIC_API(void) +JS_DHashTableSetAlphaBounds(JSDHashTable *table, + float maxAlpha, + float minAlpha); + +/* + * Call this macro with k, the number of pointer-sized words wasted per entry + * under chaining, to compute the minimum alpha at which double hashing still + * beats chaining. + */ +#define JS_DHASH_MIN_ALPHA(table, k) \ + ((float)((table)->entrySize / sizeof(void *) - 1) \ + / ((table)->entrySize / sizeof(void *) + (k))) + +/* + * Default max/min alpha, and macros to compute the value for the |capacity| + * parameter to JS_NewDHashTable and JS_DHashTableInit, given default or any + * max alpha, such that adding entryCount entries right after initializing the + * table will not require a reallocation (so JS_DHASH_ADD can't fail for those + * JS_DHashTableOperate calls). + * + * NB: JS_DHASH_CAP is a helper macro meant for use only in JS_DHASH_CAPACITY. + * Don't use it directly! + */ +#define JS_DHASH_DEFAULT_MAX_ALPHA 0.75 +#define JS_DHASH_DEFAULT_MIN_ALPHA 0.25 + +#define JS_DHASH_CAP(entryCount, maxAlpha) \ + ((uint32_t)((double)(entryCount) / (maxAlpha))) + +#define JS_DHASH_CAPACITY(entryCount, maxAlpha) \ + (JS_DHASH_CAP(entryCount, maxAlpha) + \ + (((JS_DHASH_CAP(entryCount, maxAlpha) * (uint8_t)(0x100 * (maxAlpha))) \ + >> 8) < (entryCount))) + +#define JS_DHASH_DEFAULT_CAPACITY(entryCount) \ + JS_DHASH_CAPACITY(entryCount, JS_DHASH_DEFAULT_MAX_ALPHA) + +/* + * Finalize table's data, free its entry storage using table->ops->freeTable, + * and leave its members unchanged from their last live values (which leaves + * pointers dangling). If you want to burn cycles clearing table, it's up to + * your code to call memset. + */ +extern JS_PUBLIC_API(void) +JS_DHashTableFinish(JSDHashTable *table); + +/* + * To consolidate keyHash computation and table grow/shrink code, we use a + * single entry point for lookup, add, and remove operations. The operation + * codes are declared here, along with codes returned by JSDHashEnumerator + * functions, which control JS_DHashTableEnumerate's behavior. + */ +typedef enum JSDHashOperator { + JS_DHASH_LOOKUP = 0, /* lookup entry */ + JS_DHASH_ADD = 1, /* add entry */ + JS_DHASH_REMOVE = 2, /* remove entry, or enumerator says remove */ + JS_DHASH_NEXT = 0, /* enumerator says continue */ + JS_DHASH_STOP = 1 /* enumerator says stop */ +} JSDHashOperator; + +/* + * To lookup a key in table, call: + * + * entry = JS_DHashTableOperate(table, key, JS_DHASH_LOOKUP); + * + * If JS_DHASH_ENTRY_IS_BUSY(entry) is true, key was found and it identifies + * entry. If JS_DHASH_ENTRY_IS_FREE(entry) is true, key was not found. + * + * To add an entry identified by key to table, call: + * + * entry = JS_DHashTableOperate(table, key, JS_DHASH_ADD); + * + * If entry is null upon return, then either the table is severely overloaded, + * and memory can't be allocated for entry storage via table->ops->allocTable; + * Or if table->ops->initEntry is non-null, the table->ops->initEntry op may + * have returned false. + * + * Otherwise, entry->keyHash has been set so that JS_DHASH_ENTRY_IS_BUSY(entry) + * is true, and it is up to the caller to initialize the key and value parts + * of the entry sub-type, if they have not been set already (i.e. if entry was + * not already in the table, and if the optional initEntry hook was not used). + * + * To remove an entry identified by key from table, call: + * + * (void) JS_DHashTableOperate(table, key, JS_DHASH_REMOVE); + * + * If key's entry is found, it is cleared (via table->ops->clearEntry) and + * the entry is marked so that JS_DHASH_ENTRY_IS_FREE(entry). This operation + * returns null unconditionally; you should ignore its return value. + */ +extern JS_PUBLIC_API(JSDHashEntryHdr *) JS_DHASH_FASTCALL +JS_DHashTableOperate(JSDHashTable *table, const void *key, JSDHashOperator op); + +/* + * Remove an entry already accessed via LOOKUP or ADD. + * + * NB: this is a "raw" or low-level routine, intended to be used only where + * the inefficiency of a full JS_DHashTableOperate (which rehashes in order + * to find the entry given its key) is not tolerable. This function does not + * shrink the table if it is underloaded. It does not update stats #ifdef + * JS_DHASHMETER, either. + */ +extern JS_PUBLIC_API(void) +JS_DHashTableRawRemove(JSDHashTable *table, JSDHashEntryHdr *entry); + +/* + * Enumerate entries in table using etor: + * + * count = JS_DHashTableEnumerate(table, etor, arg); + * + * JS_DHashTableEnumerate calls etor like so: + * + * op = etor(table, entry, number, arg); + * + * where number is a zero-based ordinal assigned to live entries according to + * their order in table->entryStore. + * + * The return value, op, is treated as a set of flags. If op is JS_DHASH_NEXT, + * then continue enumerating. If op contains JS_DHASH_REMOVE, then clear (via + * table->ops->clearEntry) and free entry. Then we check whether op contains + * JS_DHASH_STOP; if so, stop enumerating and return the number of live entries + * that were enumerated so far. Return the total number of live entries when + * enumeration completes normally. + * + * If etor calls JS_DHashTableOperate on table with op != JS_DHASH_LOOKUP, it + * must return JS_DHASH_STOP; otherwise undefined behavior results. + * + * If any enumerator returns JS_DHASH_REMOVE, table->entryStore may be shrunk + * or compressed after enumeration, but before JS_DHashTableEnumerate returns. + * Such an enumerator therefore can't safely set aside entry pointers, but an + * enumerator that never returns JS_DHASH_REMOVE can set pointers to entries + * aside, e.g., to avoid copying live entries into an array of the entry type. + * Copying entry pointers is cheaper, and safe so long as the caller of such a + * "stable" Enumerate doesn't use the set-aside pointers after any call either + * to PL_DHashTableOperate, or to an "unstable" form of Enumerate, which might + * grow or shrink entryStore. + * + * If your enumerator wants to remove certain entries, but set aside pointers + * to other entries that it retains, it can use JS_DHashTableRawRemove on the + * entries to be removed, returning JS_DHASH_NEXT to skip them. Likewise, if + * you want to remove entries, but for some reason you do not want entryStore + * to be shrunk or compressed, you can call JS_DHashTableRawRemove safely on + * the entry being enumerated, rather than returning JS_DHASH_REMOVE. + */ +typedef JSDHashOperator +(* JSDHashEnumerator)(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32_t number, void *arg); + +extern JS_PUBLIC_API(uint32_t) +JS_DHashTableEnumerate(JSDHashTable *table, JSDHashEnumerator etor, void *arg); + +typedef size_t +(* JSDHashSizeOfEntryExcludingThisFun)(JSDHashEntryHdr *hdr, + JSMallocSizeOfFun mallocSizeOf, + void *arg); + +/** + * Measure the size of the table's entry storage, and if + * |sizeOfEntryExcludingThis| is non-NULL, measure the size of things pointed + * to by entries. Doesn't measure |ops| because it's often shared between + * tables, nor |data| because it's opaque. + */ +extern JS_PUBLIC_API(size_t) +JS_DHashTableSizeOfExcludingThis(const JSDHashTable *table, + JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, + JSMallocSizeOfFun mallocSizeOf, + void *arg = NULL); + +/** + * Like JS_DHashTableSizeOfExcludingThis, but includes sizeof(*this). + */ +extern JS_PUBLIC_API(size_t) +JS_DHashTableSizeOfIncludingThis(const JSDHashTable *table, + JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, + JSMallocSizeOfFun mallocSizeOf, + void *arg = NULL); + +#ifdef DEBUG +/** + * Mark a table as immutable for the remainder of its lifetime. This + * changes the implementation from ASSERTing one set of invariants to + * ASSERTing a different set. + * + * When a table is NOT marked as immutable, the table implementation + * asserts that the table is not mutated from its own callbacks. It + * assumes the caller protects the table from being accessed on multiple + * threads simultaneously. + * + * When the table is marked as immutable, the re-entry assertions will + * no longer trigger erroneously due to multi-threaded access. Instead, + * mutations will cause assertions. + */ +extern JS_PUBLIC_API(void) +JS_DHashMarkTableImmutable(JSDHashTable *table); +#endif + +#ifdef JS_DHASHMETER +#include + +extern JS_PUBLIC_API(void) +JS_DHashTableDumpMeter(JSDHashTable *table, JSDHashEnumerator dump, FILE *fp); +#endif + +#endif /* jsdhash_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsfriendapi.h b/scripting/javascript/spidermonkey-mac/include/jsfriendapi.h new file mode 100644 index 0000000000..01b44b4ac3 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsfriendapi.h @@ -0,0 +1,1454 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsfriendapi_h___ +#define jsfriendapi_h___ + +#include "mozilla/GuardObjects.h" + +#include "jsclass.h" +#include "jscpucfg.h" +#include "jspubtd.h" +#include "jsprvtd.h" + +/* + * This macro checks if the stack pointer has exceeded a given limit. If + * |tolerance| is non-zero, it returns true only if the stack pointer has + * exceeded the limit by more than |tolerance| bytes. + */ +#if JS_STACK_GROWTH_DIRECTION > 0 +# define JS_CHECK_STACK_SIZE_WITH_TOLERANCE(limit, sp, tolerance) \ + ((uintptr_t)(sp) < (limit)+(tolerance)) +#else +# define JS_CHECK_STACK_SIZE_WITH_TOLERANCE(limit, sp, tolerance) \ + ((uintptr_t)(sp) > (limit)-(tolerance)) +#endif + +#define JS_CHECK_STACK_SIZE(limit, lval) JS_CHECK_STACK_SIZE_WITH_TOLERANCE(limit, lval, 0) + +extern JS_FRIEND_API(void) +JS_SetGrayGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); + +extern JS_FRIEND_API(JSString *) +JS_GetAnonymousString(JSRuntime *rt); + +extern JS_FRIEND_API(JSObject *) +JS_FindCompilationScope(JSContext *cx, JSRawObject obj); + +extern JS_FRIEND_API(JSFunction *) +JS_GetObjectFunction(JSRawObject obj); + +extern JS_FRIEND_API(JSBool) +JS_SplicePrototype(JSContext *cx, JSObject *obj, JSObject *proto); + +extern JS_FRIEND_API(JSObject *) +JS_NewObjectWithUniqueType(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); + +extern JS_FRIEND_API(uint32_t) +JS_ObjectCountDynamicSlots(JSHandleObject obj); + +extern JS_FRIEND_API(size_t) +JS_SetProtoCalled(JSContext *cx); + +extern JS_FRIEND_API(size_t) +JS_GetCustomIteratorCount(JSContext *cx); + +extern JS_FRIEND_API(JSBool) +JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *obj, JSObject **ret); + +/* + * Determine whether the given object is backed by a DeadObjectProxy. + * + * Such objects hold no other objects (they have no outgoing reference edges) + * and will throw if you touch them (e.g. by reading/writing a property). + */ +extern JS_FRIEND_API(JSBool) +JS_IsDeadWrapper(JSObject *obj); + +/* + * Used by the cycle collector to trace through the shape and all + * shapes it reaches, marking all non-shape children found in the + * process. Uses bounded stack space. + */ +extern JS_FRIEND_API(void) +JS_TraceShapeCycleCollectorChildren(JSTracer *trc, void *shape); + +enum { + JS_TELEMETRY_GC_REASON, + JS_TELEMETRY_GC_IS_COMPARTMENTAL, + JS_TELEMETRY_GC_MS, + JS_TELEMETRY_GC_MAX_PAUSE_MS, + JS_TELEMETRY_GC_MARK_MS, + JS_TELEMETRY_GC_SWEEP_MS, + JS_TELEMETRY_GC_MARK_ROOTS_MS, + JS_TELEMETRY_GC_MARK_GRAY_MS, + JS_TELEMETRY_GC_SLICE_MS, + JS_TELEMETRY_GC_MMU_50, + JS_TELEMETRY_GC_RESET, + JS_TELEMETRY_GC_INCREMENTAL_DISABLED, + JS_TELEMETRY_GC_NON_INCREMENTAL, + JS_TELEMETRY_GC_SCC_SWEEP_TOTAL_MS, + JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS +}; + +typedef void +(* JSAccumulateTelemetryDataCallback)(int id, uint32_t sample); + +extern JS_FRIEND_API(void) +JS_SetAccumulateTelemetryCallback(JSRuntime *rt, JSAccumulateTelemetryDataCallback callback); + +extern JS_FRIEND_API(JSPrincipals *) +JS_GetCompartmentPrincipals(JSCompartment *compartment); + +extern JS_FRIEND_API(void) +JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals); + +/* Safe to call with input obj == NULL. Returns non-NULL iff obj != NULL. */ +extern JS_FRIEND_API(JSObject *) +JS_ObjectToInnerObject(JSContext *cx, JSObject *obj); + +/* Requires obj != NULL. */ +extern JS_FRIEND_API(JSObject *) +JS_ObjectToOuterObject(JSContext *cx, JSObject *obj); + +extern JS_FRIEND_API(JSObject *) +JS_CloneObject(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent); + +extern JS_FRIEND_API(JSBool) +js_GetterOnlyPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp); + +JS_FRIEND_API(void) +js_ReportOverRecursed(JSContext *maybecx); + +#ifdef DEBUG + +/* + * Routines to print out values during debugging. These are FRIEND_API to help + * the debugger find them and to support temporarily hacking js_Dump* calls + * into other code. + */ + +extern JS_FRIEND_API(void) +js_DumpString(JSString *str); + +extern JS_FRIEND_API(void) +js_DumpAtom(JSAtom *atom); + +extern JS_FRIEND_API(void) +js_DumpObject(JSObject *obj); + +extern JS_FRIEND_API(void) +js_DumpChars(const jschar *s, size_t n); +#endif + +extern JS_FRIEND_API(bool) +JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj); + +extern JS_FRIEND_API(JSBool) +JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *desc); + +extern JS_FRIEND_API(JSBool) +JS_WrapAutoIdVector(JSContext *cx, JS::AutoIdVector &props); + +extern JS_FRIEND_API(JSBool) +JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op, + js::MutableHandleValue statep, js::MutableHandleId idp); + +struct JSFunctionSpecWithHelp { + const char *name; + JSNative call; + uint16_t nargs; + uint16_t flags; + const char *usage; + const char *help; +}; + +#define JS_FN_HELP(name,call,nargs,flags,usage,help) \ + {name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, usage, help} +#define JS_FS_HELP_END \ + {NULL, NULL, 0, 0, NULL, NULL} + +extern JS_FRIEND_API(bool) +JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj, const JSFunctionSpecWithHelp *fs); + +typedef bool (* JS_SourceHook)(JSContext *cx, JSScript *script, jschar **src, uint32_t *length); + +extern JS_FRIEND_API(void) +JS_SetSourceHook(JSRuntime *rt, JS_SourceHook hook); + +namespace js { + +extern mozilla::ThreadLocal TlsPerThreadData; + +inline JSRuntime * +GetRuntime(const JSContext *cx) +{ + return ContextFriendFields::get(cx)->runtime; +} + +inline JSCompartment * +GetContextCompartment(const JSContext *cx) +{ + return ContextFriendFields::get(cx)->compartment; +} + +inline JS::Zone * +GetContextZone(const JSContext *cx) +{ + return ContextFriendFields::get(cx)->zone_; +} + +extern JS_FRIEND_API(JS::Zone *) +GetCompartmentZone(JSCompartment *comp); + +typedef bool +(* PreserveWrapperCallback)(JSContext *cx, JSObject *obj); + + /* + * Dump the complete object graph of heap-allocated things. + * fp is the file for the dump output. + */ +extern JS_FRIEND_API(void) +DumpHeapComplete(JSRuntime *rt, FILE *fp); + +class JS_FRIEND_API(AutoSwitchCompartment) { + private: + JSContext *cx; + JSCompartment *oldCompartment; + public: + AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment + MOZ_GUARD_OBJECT_NOTIFIER_PARAM); + AutoSwitchCompartment(JSContext *cx, JSHandleObject target + MOZ_GUARD_OBJECT_NOTIFIER_PARAM); + ~AutoSwitchCompartment(); + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER +}; + +#ifdef OLD_GETTER_SETTER_METHODS +JS_FRIEND_API(JSBool) obj_defineGetter(JSContext *cx, unsigned argc, js::Value *vp); +JS_FRIEND_API(JSBool) obj_defineSetter(JSContext *cx, unsigned argc, js::Value *vp); +#endif + +extern JS_FRIEND_API(bool) +IsSystemCompartment(JSCompartment *comp); + +extern JS_FRIEND_API(bool) +IsSystemZone(JS::Zone *zone); + +extern JS_FRIEND_API(bool) +IsAtomsCompartment(JSCompartment *comp); + +/* + * Check whether it is OK to assign an undeclared variable with the name + * |propname| at the current location in script. It is not an error if there is + * no current script location, or if that location is not an assignment to an + * undeclared variable. Reports an error if one needs to be reported (and, + * particularly, always reports when it returns false). + */ +extern JS_FRIEND_API(bool) +ReportIfUndeclaredVarAssignment(JSContext *cx, HandleString propname); + +struct WeakMapTracer; + +/* + * Weak map tracer callback, called once for every binding of every + * weak map that was live at the time of the last garbage collection. + * + * m will be NULL if the weak map is not contained in a JS Object. + */ +typedef void +(* WeakMapTraceCallback)(WeakMapTracer *trc, JSObject *m, + void *k, JSGCTraceKind kkind, + void *v, JSGCTraceKind vkind); + +struct WeakMapTracer { + JSRuntime *runtime; + WeakMapTraceCallback callback; + + WeakMapTracer(JSRuntime *rt, WeakMapTraceCallback cb) + : runtime(rt), callback(cb) {} +}; + +extern JS_FRIEND_API(void) +TraceWeakMaps(WeakMapTracer *trc); + +extern JS_FRIEND_API(bool) +AreGCGrayBitsValid(JSRuntime *rt); + +typedef void +(*GCThingCallback)(void *closure, void *gcthing); + +extern JS_FRIEND_API(void) +VisitGrayWrapperTargets(JS::Zone *zone, GCThingCallback callback, void *closure); + +extern JS_FRIEND_API(JSObject *) +GetWeakmapKeyDelegate(JSObject *key); + +JS_FRIEND_API(JSGCTraceKind) +GCThingTraceKind(void *thing); + +/* + * Invoke cellCallback on every gray JS_OBJECT in the given zone. + */ +extern JS_FRIEND_API(void) +IterateGrayObjects(JS::Zone *zone, GCThingCallback cellCallback, void *data); + +#ifdef JS_HAS_CTYPES +extern JS_FRIEND_API(size_t) +SizeOfDataIfCDataObject(JSMallocSizeOfFun mallocSizeOf, JSObject *obj); +#endif + +extern JS_FRIEND_API(JSCompartment *) +GetAnyCompartmentInZone(JS::Zone *zone); + +/* + * Shadow declarations of JS internal structures, for access by inline access + * functions below. Do not use these structures in any other way. When adding + * new fields for access by inline methods, make sure to add static asserts to + * the original header file to ensure that offsets are consistent. + */ +namespace shadow { + +struct TypeObject { + Class *clasp; + JSObject *proto; +}; + +struct BaseShape { + js::Class *clasp; + JSObject *parent; + JSCompartment *compartment; +}; + +class Shape { +public: + shadow::BaseShape *base; + jsid _1; + uint32_t slotInfo; + + static const uint32_t FIXED_SLOTS_SHIFT = 27; +}; + +struct Object { + shadow::Shape *shape; + shadow::TypeObject *type; + js::Value *slots; + js::Value *_1; + + size_t numFixedSlots() const { return shape->slotInfo >> Shape::FIXED_SLOTS_SHIFT; } + Value *fixedSlots() const { + return (Value *)(uintptr_t(this) + sizeof(shadow::Object)); + } + + js::Value &slotRef(size_t slot) const { + size_t nfixed = numFixedSlots(); + if (slot < nfixed) + return fixedSlots()[slot]; + return slots[slot - nfixed]; + } +}; + +struct Function { + Object base; + uint16_t nargs; + uint16_t flags; + /* Used only for natives */ + Native native; + const JSJitInfo *jitinfo; + void *_1; +}; + +struct Atom { + size_t _; + const jschar *chars; +}; + +} /* namespace shadow */ + +extern JS_FRIEND_DATA(js::Class) CallClass; +extern JS_FRIEND_DATA(js::Class) DeclEnvClass; +extern JS_FRIEND_DATA(js::Class) FunctionClass; +extern JS_FRIEND_DATA(js::Class) FunctionProxyClass; +extern JS_FRIEND_DATA(js::Class) OuterWindowProxyClass; +extern JS_FRIEND_DATA(js::Class) ObjectProxyClass; +extern JS_FRIEND_DATA(js::Class) ObjectClass; + +inline js::Class * +GetObjectClass(RawObject obj) +{ + return reinterpret_cast(obj)->type->clasp; +} + +inline JSClass * +GetObjectJSClass(RawObject obj) +{ + return js::Jsvalify(GetObjectClass(obj)); +} + +inline bool +IsInnerObject(JSObject *obj) { + return !!GetObjectClass(obj)->ext.outerObject; +} + +inline bool +IsOuterObject(JSObject *obj) { + return !!GetObjectClass(obj)->ext.innerObject; +} + +JS_FRIEND_API(bool) +IsScopeObject(RawObject obj); + +inline JSObject * +GetObjectParent(RawObject obj) +{ + JS_ASSERT(!IsScopeObject(obj)); + return reinterpret_cast(obj)->shape->base->parent; +} + +static JS_ALWAYS_INLINE JSCompartment * +GetObjectCompartment(JSObject *obj) +{ + return reinterpret_cast(obj)->shape->base->compartment; +} + +JS_FRIEND_API(JSObject *) +GetObjectParentMaybeScope(RawObject obj); + +JS_FRIEND_API(JSObject *) +GetGlobalForObjectCrossCompartment(RawObject obj); + +JS_FRIEND_API(void) +NotifyAnimationActivity(RawObject obj); + +JS_FRIEND_API(bool) +IsOriginalScriptFunction(JSFunction *fun); + +/* + * Return the outermost enclosing function (script) of the scripted caller. + * This function returns NULL in several cases: + * - no script is running on the context + * - the caller is in global or eval code + * In particular, this function will "stop" its outermost search at eval() and + * thus it will really return the outermost enclosing function *since the + * innermost eval*. + */ +JS_FRIEND_API(JSScript *) +GetOutermostEnclosingFunctionOfScriptedCaller(JSContext *cx); + +JS_FRIEND_API(JSFunction *) +DefineFunctionWithReserved(JSContext *cx, JSObject *obj, const char *name, JSNative call, + unsigned nargs, unsigned attrs); + +JS_FRIEND_API(JSFunction *) +NewFunctionWithReserved(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, + JSObject *parent, const char *name); + +JS_FRIEND_API(JSFunction *) +NewFunctionByIdWithReserved(JSContext *cx, JSNative native, unsigned nargs, unsigned flags, + JSObject *parent, jsid id); + +JS_FRIEND_API(JSObject *) +InitClassWithReserved(JSContext *cx, JSObject *obj, JSObject *parent_proto, + JSClass *clasp, JSNative constructor, unsigned nargs, + JSPropertySpec *ps, JSFunctionSpec *fs, + JSPropertySpec *static_ps, JSFunctionSpec *static_fs); + +JS_FRIEND_API(const Value &) +GetFunctionNativeReserved(RawObject fun, size_t which); + +JS_FRIEND_API(void) +SetFunctionNativeReserved(RawObject fun, size_t which, const Value &val); + +inline bool +GetObjectProto(JSContext *cx, JSObject *obj, JSObject **proto) +{ + js::Class *clasp = GetObjectClass(obj); + if (clasp == &js::ObjectProxyClass || + clasp == &js::OuterWindowProxyClass || + clasp == &js::FunctionProxyClass) + { + return JS_GetPrototype(cx, obj, proto); + } + + *proto = reinterpret_cast(obj)->type->proto; + return true; +} + +inline void * +GetObjectPrivate(RawObject obj) +{ + const shadow::Object *nobj = reinterpret_cast(obj); + void **addr = reinterpret_cast(&nobj->fixedSlots()[nobj->numFixedSlots()]); + return *addr; +} + +/* + * Get a slot that is both reserved for object's clasp *and* is fixed (fits + * within the maximum capacity for the object's fixed slots). + */ +inline const Value & +GetReservedSlot(RawObject obj, size_t slot) +{ + JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); + return reinterpret_cast(obj)->slotRef(slot); +} + +JS_FRIEND_API(void) +SetReservedSlotWithBarrier(RawObject obj, size_t slot, const Value &value); + +inline void +SetReservedSlot(RawObject obj, size_t slot, const Value &value) +{ + JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); + shadow::Object *sobj = reinterpret_cast(obj); + if (sobj->slotRef(slot).isMarkable() +#ifdef JSGC_GENERATIONAL + || value.isMarkable() +#endif + ) + { + SetReservedSlotWithBarrier(obj, slot, value); + } else { + sobj->slotRef(slot) = value; + } +} + +JS_FRIEND_API(uint32_t) +GetObjectSlotSpan(RawObject obj); + +inline const Value & +GetObjectSlot(RawObject obj, size_t slot) +{ + JS_ASSERT(slot < GetObjectSlotSpan(obj)); + return reinterpret_cast(obj)->slotRef(slot); +} + +inline const jschar * +GetAtomChars(JSAtom *atom) +{ + return reinterpret_cast(atom)->chars; +} + +inline JSLinearString * +AtomToLinearString(JSAtom *atom) +{ + return reinterpret_cast(atom); +} + +static inline js::PropertyOp +CastAsJSPropertyOp(RawObject object) +{ + return JS_DATA_TO_FUNC_PTR(js::PropertyOp, object); +} + +static inline js::StrictPropertyOp +CastAsJSStrictPropertyOp(RawObject object) +{ + return JS_DATA_TO_FUNC_PTR(js::StrictPropertyOp, object); +} + +JS_FRIEND_API(bool) +GetPropertyNames(JSContext *cx, RawObject obj, unsigned flags, js::AutoIdVector *props); + +JS_FRIEND_API(bool) +AppendUnique(JSContext *cx, AutoIdVector &base, AutoIdVector &others); + +JS_FRIEND_API(bool) +GetGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp); + +JS_FRIEND_API(bool) +StringIsArrayIndex(JSLinearString *str, uint32_t *indexp); + +JS_FRIEND_API(void) +SetPreserveWrapperCallback(JSRuntime *rt, PreserveWrapperCallback callback); + +JS_FRIEND_API(bool) +IsObjectInContextCompartment(RawObject obj, const JSContext *cx); + +/* + * NB: these flag bits are encoded into the bytecode stream in the immediate + * operand of JSOP_ITER, so don't change them without advancing vm/Xdr.h's + * XDR_BYTECODE_VERSION. + */ +#define JSITER_ENUMERATE 0x1 /* for-in compatible hidden default iterator */ +#define JSITER_FOREACH 0x2 /* return [key, value] pair rather than key */ +#define JSITER_KEYVALUE 0x4 /* destructuring for-in wants [key, value] */ +#define JSITER_OWNONLY 0x8 /* iterate over obj's own properties only */ +#define JSITER_HIDDEN 0x10 /* also enumerate non-enumerable properties */ +#define JSITER_FOR_OF 0x20 /* harmony for-of loop */ + +inline uintptr_t +GetNativeStackLimit(const JSRuntime *rt) +{ + return PerThreadDataFriendFields::getMainThread(rt)->nativeStackLimit; +} + +/* + * These macros report a stack overflow and run |onerror| if we are close to + * using up the C stack. The JS_CHECK_CHROME_RECURSION variant gives us a little + * extra space so that we can ensure that crucial code is able to run. + */ + +#define JS_CHECK_RECURSION(cx, onerror) \ + JS_BEGIN_MACRO \ + int stackDummy_; \ + if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(js::GetRuntime(cx)), &stackDummy_)) { \ + js_ReportOverRecursed(cx); \ + onerror; \ + } \ + JS_END_MACRO + +#define JS_CHECK_CHROME_RECURSION(cx, onerror) \ + JS_BEGIN_MACRO \ + int stackDummy_; \ + if (!JS_CHECK_STACK_SIZE_WITH_TOLERANCE(js::GetNativeStackLimit(js::GetRuntime(cx)), \ + &stackDummy_, \ + 1024 * sizeof(size_t))) \ + { \ + js_ReportOverRecursed(cx); \ + onerror; \ + } \ + JS_END_MACRO + +JS_FRIEND_API(void) +StartPCCountProfiling(JSContext *cx); + +JS_FRIEND_API(void) +StopPCCountProfiling(JSContext *cx); + +JS_FRIEND_API(void) +PurgePCCounts(JSContext *cx); + +JS_FRIEND_API(size_t) +GetPCCountScriptCount(JSContext *cx); + +JS_FRIEND_API(JSString *) +GetPCCountScriptSummary(JSContext *cx, size_t script); + +JS_FRIEND_API(JSString *) +GetPCCountScriptContents(JSContext *cx, size_t script); + +/* + * A call stack can be specified to the JS engine such that all JS entry/exits + * to functions push/pop an entry to/from the specified stack. + * + * For more detailed information, see vm/SPSProfiler.h + */ +class ProfileEntry +{ + /* + * All fields are marked volatile to prevent the compiler from re-ordering + * instructions. Namely this sequence: + * + * entry[size] = ...; + * size++; + * + * If the size modification were somehow reordered before the stores, then + * if a sample were taken it would be examining bogus information. + * + * A ProfileEntry represents both a C++ profile entry and a JS one. Both use + * the string as a description, but JS uses the sp as NULL to indicate that + * it is a JS entry. The script_ is then only ever examined for a JS entry, + * and the idx is used by both, but with different meanings. + */ + const char * volatile string; // Descriptive string of this entry + void * volatile sp; // Relevant stack pointer for the entry + JSScript * volatile script_; // if js(), non-null script which is running + int32_t volatile idx; // if js(), idx of pc, otherwise line number + + public: + /* + * All of these methods are marked with the 'volatile' keyword because SPS's + * representation of the stack is stored such that all ProfileEntry + * instances are volatile. These methods would not be available unless they + * were marked as volatile as well + */ + + bool js() volatile { + JS_ASSERT_IF(sp == NULL, script_ != NULL); + return sp == NULL; + } + + uint32_t line() volatile { JS_ASSERT(!js()); return idx; } + JSScript *script() volatile { JS_ASSERT(js()); return script_; } + void *stackAddress() volatile { return sp; } + const char *label() volatile { return string; } + + void setLine(uint32_t aLine) volatile { JS_ASSERT(!js()); idx = aLine; } + void setLabel(const char *aString) volatile { string = aString; } + void setStackAddress(void *aSp) volatile { sp = aSp; } + void setScript(JSScript *aScript) volatile { script_ = aScript; } + + /* we can't know the layout of JSScript, so look in vm/SPSProfiler.cpp */ + JS_FRIEND_API(jsbytecode *) pc() volatile; + JS_FRIEND_API(void) setPC(jsbytecode *pc) volatile; + + static size_t offsetOfString() { return offsetof(ProfileEntry, string); } + static size_t offsetOfStackAddress() { return offsetof(ProfileEntry, sp); } + static size_t offsetOfPCIdx() { return offsetof(ProfileEntry, idx); } + static size_t offsetOfScript() { return offsetof(ProfileEntry, script_); } + + /* + * The index used in the entry can either be a line number or the offset of + * a pc into a script's code. To signify a NULL pc, use a -1 index. This is + * checked against in pc() and setPC() to set/get the right pc. + */ + static const int32_t NullPCIndex = -1; +}; + +JS_FRIEND_API(void) +SetRuntimeProfilingStack(JSRuntime *rt, ProfileEntry *stack, uint32_t *size, + uint32_t max); + +JS_FRIEND_API(void) +EnableRuntimeProfilingStack(JSRuntime *rt, bool enabled); + +JS_FRIEND_API(jsbytecode*) +ProfilingGetPC(JSRuntime *rt, RawScript script, void *ip); + +#ifdef JS_THREADSAFE +JS_FRIEND_API(void *) +GetOwnerThread(const JSContext *cx); + +JS_FRIEND_API(bool) +ContextHasOutstandingRequests(const JSContext *cx); +#endif + +JS_FRIEND_API(bool) +HasUnrootedGlobal(const JSContext *cx); + +typedef void +(* ActivityCallback)(void *arg, JSBool active); + +/* + * Sets a callback that is run whenever the runtime goes idle - the + * last active request ceases - and begins activity - when it was + * idle and a request begins. + */ +JS_FRIEND_API(void) +SetActivityCallback(JSRuntime *rt, ActivityCallback cb, void *arg); + +extern JS_FRIEND_API(const JSStructuredCloneCallbacks *) +GetContextStructuredCloneCallbacks(JSContext *cx); + +extern JS_FRIEND_API(bool) +CanCallContextDebugHandler(JSContext *cx); + +extern JS_FRIEND_API(JSTrapStatus) +CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval); + +extern JS_FRIEND_API(bool) +IsContextRunningJS(JSContext *cx); + +typedef void +(* AnalysisPurgeCallback)(JSRuntime *rt, JSFlatString *desc); + +extern JS_FRIEND_API(AnalysisPurgeCallback) +SetAnalysisPurgeCallback(JSRuntime *rt, AnalysisPurgeCallback callback); + +typedef JSBool +(* DOMInstanceClassMatchesProto)(JSHandleObject protoObject, uint32_t protoID, + uint32_t depth); +struct JSDOMCallbacks { + DOMInstanceClassMatchesProto instanceClassMatchesProto; +}; +typedef struct JSDOMCallbacks DOMCallbacks; + +extern JS_FRIEND_API(void) +SetDOMCallbacks(JSRuntime *rt, const DOMCallbacks *callbacks); + +extern JS_FRIEND_API(const DOMCallbacks *) +GetDOMCallbacks(JSRuntime *rt); + +extern JS_FRIEND_API(JSObject *) +GetTestingFunctions(JSContext *cx); + +/* + * Helper to convert FreeOp to JSFreeOp when the definition of FreeOp is not + * available and the compiler does not know that FreeOp inherits from + * JSFreeOp. + */ +inline JSFreeOp * +CastToJSFreeOp(FreeOp *fop) +{ + return reinterpret_cast(fop); +} + +/* Implemented in jsexn.cpp. */ + +/* + * Get an error type name from a JSExnType constant. + * Returns NULL for invalid arguments and JSEXN_INTERNALERR + */ +extern JS_FRIEND_API(const jschar*) +GetErrorTypeName(JSContext* cx, int16_t exnType); + +#ifdef DEBUG +extern JS_FRIEND_API(unsigned) +GetEnterCompartmentDepth(JSContext* cx); +#endif + +/* Implemented in jswrapper.cpp. */ +typedef enum NukeReferencesToWindow { + NukeWindowReferences, + DontNukeWindowReferences +} NukeReferencesToWindow; + +/* + * These filters are designed to be ephemeral stack classes, and thus don't + * do any rooting or holding of their members. + */ +struct CompartmentFilter { + virtual bool match(JSCompartment *c) const = 0; +}; + +struct AllCompartments : public CompartmentFilter { + virtual bool match(JSCompartment *c) const { return true; } +}; + +struct ContentCompartmentsOnly : public CompartmentFilter { + virtual bool match(JSCompartment *c) const { + return !IsSystemCompartment(c); + } +}; + +struct ChromeCompartmentsOnly : public CompartmentFilter { + virtual bool match(JSCompartment *c) const { + return IsSystemCompartment(c); + } +}; + +struct SingleCompartment : public CompartmentFilter { + JSCompartment *ours; + SingleCompartment(JSCompartment *c) : ours(c) {} + virtual bool match(JSCompartment *c) const { return c == ours; } +}; + +struct CompartmentsWithPrincipals : public CompartmentFilter { + JSPrincipals *principals; + CompartmentsWithPrincipals(JSPrincipals *p) : principals(p) {} + virtual bool match(JSCompartment *c) const { + return JS_GetCompartmentPrincipals(c) == principals; + } +}; + +extern JS_FRIEND_API(JSBool) +NukeCrossCompartmentWrappers(JSContext* cx, + const CompartmentFilter& sourceFilter, + const CompartmentFilter& targetFilter, + NukeReferencesToWindow nukeReferencesToWindow); + +/* Specify information about ListBase proxies in the DOM, for use by ICs. */ +JS_FRIEND_API(void) +SetListBaseInformation(void *listBaseHandlerFamily, uint32_t listBaseExpandoSlot); + +void *GetListBaseHandlerFamily(); +uint32_t GetListBaseExpandoSlot(); + +} /* namespace js */ + +/* Implemented in jsdate.cpp. */ + +/* + * Detect whether the internal date value is NaN. (Because failure is + * out-of-band for js_DateGet*) + */ +extern JS_FRIEND_API(JSBool) +js_DateIsValid(JSObject* obj); + +extern JS_FRIEND_API(double) +js_DateGetMsecSinceEpoch(JSRawObject obj); + +/* Implemented in jscntxt.cpp. */ + +/* + * Report an exception, which is currently realized as a printf-style format + * string and its arguments. + */ +typedef enum JSErrNum { +#define MSG_DEF(name, number, count, exception, format) \ + name = number, +#include "js.msg" +#undef MSG_DEF + JSErr_Limit +} JSErrNum; + +extern JS_FRIEND_API(const JSErrorFormatString *) +js_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber); + +/* Implemented in jsclone.cpp. */ + +extern JS_FRIEND_API(uint64_t) +js_GetSCOffset(JSStructuredCloneWriter* writer); + +/* Typed Array functions, implemented in jstypedarray.cpp */ + +namespace js { +namespace ArrayBufferView { + +enum ViewType { + TYPE_INT8 = 0, + TYPE_UINT8, + TYPE_INT16, + TYPE_UINT16, + TYPE_INT32, + TYPE_UINT32, + TYPE_FLOAT32, + TYPE_FLOAT64, + + /* + * Special type that is a uint8_t, but assignments are clamped to [0, 256). + * Treat the raw data type as a uint8_t. + */ + TYPE_UINT8_CLAMPED, + + /* + * Type returned for a DataView. Note that there is no single element type + * in this case. + */ + TYPE_DATAVIEW, + + TYPE_MAX +}; + +} /* namespace ArrayBufferView */ +} /* namespace js */ + +typedef js::ArrayBufferView::ViewType JSArrayBufferViewType; + +/* + * Create a new typed array with nelements elements. + * + * These functions (except the WithBuffer variants) fill in the array with zeros. + */ + +extern JS_FRIEND_API(JSObject *) +JS_NewInt8Array(JSContext *cx, uint32_t nelements); +extern JS_FRIEND_API(JSObject *) +JS_NewUint8Array(JSContext *cx, uint32_t nelements); +extern JS_FRIEND_API(JSObject *) +JS_NewUint8ClampedArray(JSContext *cx, uint32_t nelements); + +extern JS_FRIEND_API(JSObject *) +JS_NewInt16Array(JSContext *cx, uint32_t nelements); +extern JS_FRIEND_API(JSObject *) +JS_NewUint16Array(JSContext *cx, uint32_t nelements); +extern JS_FRIEND_API(JSObject *) +JS_NewInt32Array(JSContext *cx, uint32_t nelements); +extern JS_FRIEND_API(JSObject *) +JS_NewUint32Array(JSContext *cx, uint32_t nelements); +extern JS_FRIEND_API(JSObject *) +JS_NewFloat32Array(JSContext *cx, uint32_t nelements); +extern JS_FRIEND_API(JSObject *) +JS_NewFloat64Array(JSContext *cx, uint32_t nelements); + +/* + * Create a new typed array and copy in values from the given object. The + * object is used as if it were an array; that is, the new array (if + * successfully created) will have length given by array.length, and its + * elements will be those specified by array[0], array[1], and so on, after + * conversion to the typed array element type. + */ + +extern JS_FRIEND_API(JSObject *) +JS_NewInt8ArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewUint8ArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewUint8ClampedArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewInt16ArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewUint16ArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewInt32ArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewUint32ArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewFloat32ArrayFromArray(JSContext *cx, JSObject *array); +extern JS_FRIEND_API(JSObject *) +JS_NewFloat64ArrayFromArray(JSContext *cx, JSObject *array); + +/* + * Create a new typed array using the given ArrayBuffer for storage. byteOffset + * must not exceed (signed) INT32_MAX. The length value is optional; if -1 is + * passed, enough elements to use up the remainder of the byte array is used as + * the default value. + */ + +extern JS_FRIEND_API(JSObject *) +JS_NewInt8ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewUint8ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewUint8ClampedArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewInt16ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewUint16ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewInt32ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewUint32ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewFloat32ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); +extern JS_FRIEND_API(JSObject *) +JS_NewFloat64ArrayWithBuffer(JSContext *cx, JSObject *arrayBuffer, + uint32_t byteOffset, int32_t length); + +/* + * Create a new ArrayBuffer with the given byte length. + */ +extern JS_FRIEND_API(JSObject *) +JS_NewArrayBuffer(JSContext *cx, uint32_t nbytes); + +/* + * Check whether obj supports JS_GetTypedArray* APIs. Note that this may return + * false if a security wrapper is encountered that denies the unwrapping. If + * this test or one of the JS_Is*Array tests succeeds, then it is safe to call + * the various accessor JSAPI calls defined below. + */ +extern JS_FRIEND_API(JSBool) +JS_IsTypedArrayObject(JSObject *obj); + +/* + * Check whether obj supports JS_GetArrayBufferView* APIs. Note that this may + * return false if a security wrapper is encountered that denies the + * unwrapping. If this test or one of the more specific tests succeeds, then it + * is safe to call the various ArrayBufferView accessor JSAPI calls defined + * below. + */ +extern JS_FRIEND_API(JSBool) +JS_IsArrayBufferViewObject(JSObject *obj); + +/* + * Test for specific typed array types (ArrayBufferView subtypes) + */ + +extern JS_FRIEND_API(JSBool) +JS_IsInt8Array(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsUint8Array(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsUint8ClampedArray(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsInt16Array(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsUint16Array(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsInt32Array(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsUint32Array(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsFloat32Array(JSObject *obj); +extern JS_FRIEND_API(JSBool) +JS_IsFloat64Array(JSObject *obj); + +/* + * Unwrap Typed arrays all at once. Return NULL without throwing if the object + * cannot be viewed as the correct typed array, or the typed array object on + * success, filling both outparameters. + */ +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsInt8Array(JSObject *obj, uint32_t *length, int8_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsUint8Array(JSObject *obj, uint32_t *length, uint8_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsUint8ClampedArray(JSObject *obj, uint32_t *length, uint8_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsInt16Array(JSObject *obj, uint32_t *length, int16_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsUint16Array(JSObject *obj, uint32_t *length, uint16_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsInt32Array(JSObject *obj, uint32_t *length, int32_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsUint32Array(JSObject *obj, uint32_t *length, uint32_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsFloat32Array(JSObject *obj, uint32_t *length, float **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsFloat64Array(JSObject *obj, uint32_t *length, double **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsArrayBufferView(JSObject *obj, uint32_t *length, uint8_t **data); +extern JS_FRIEND_API(JSObject *) +JS_GetObjectAsArrayBuffer(JSObject *obj, uint32_t *length, uint8_t **data); + +/* + * Get the type of elements in a typed array, or TYPE_DATAVIEW if a DataView. + * + * |obj| must have passed a JS_IsArrayBufferView/JS_Is*Array test, or somehow + * be known that it would pass such a test: it is an ArrayBufferView or a + * wrapper of an ArrayBufferView, and the unwrapping will succeed. + */ +extern JS_FRIEND_API(JSArrayBufferViewType) +JS_GetArrayBufferViewType(JSObject *obj); + +/* + * Check whether obj supports the JS_GetArrayBuffer* APIs. Note that this may + * return false if a security wrapper is encountered that denies the + * unwrapping. If this test succeeds, then it is safe to call the various + * accessor JSAPI calls defined below. + */ +extern JS_FRIEND_API(JSBool) +JS_IsArrayBufferObject(JSObject *obj); + +/* + * Return the available byte length of an array buffer. + * + * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known + * that it would pass such a test: it is an ArrayBuffer or a wrapper of an + * ArrayBuffer, and the unwrapping will succeed. + */ +extern JS_FRIEND_API(uint32_t) +JS_GetArrayBufferByteLength(JSObject *obj); + +/* + * Return a pointer to an array buffer's data. The buffer is still owned by the + * array buffer object, and should not be modified on another thread. The + * returned pointer is stable across GCs. + * + * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known + * that it would pass such a test: it is an ArrayBuffer or a wrapper of an + * ArrayBuffer, and the unwrapping will succeed. + */ +extern JS_FRIEND_API(uint8_t *) +JS_GetArrayBufferData(JSObject *obj); + +/* + * Return the number of elements in a typed array. + * + * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow + * be known that it would pass such a test: it is a typed array or a wrapper of + * a typed array, and the unwrapping will succeed. + */ +extern JS_FRIEND_API(uint32_t) +JS_GetTypedArrayLength(JSObject *obj); + +/* + * Return the byte offset from the start of an array buffer to the start of a + * typed array view. + * + * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow + * be known that it would pass such a test: it is a typed array or a wrapper of + * a typed array, and the unwrapping will succeed. + */ +extern JS_FRIEND_API(uint32_t) +JS_GetTypedArrayByteOffset(JSObject *obj); + +/* + * Return the byte length of a typed array. + * + * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow + * be known that it would pass such a test: it is a typed array or a wrapper of + * a typed array, and the unwrapping will succeed. + */ +extern JS_FRIEND_API(uint32_t) +JS_GetTypedArrayByteLength(JSObject *obj); + +/* + * Check whether obj supports JS_ArrayBufferView* APIs. Note that this may + * return false if a security wrapper is encountered that denies the + * unwrapping. + */ +extern JS_FRIEND_API(JSBool) +JS_IsArrayBufferViewObject(JSObject *obj); + +/* + * More generic name for JS_GetTypedArrayByteLength to cover DataViews as well + */ +extern JS_FRIEND_API(uint32_t) +JS_GetArrayBufferViewByteLength(JSObject *obj); + +/* + * Return a pointer to the start of the data referenced by a typed array. The + * data is still owned by the typed array, and should not be modified on + * another thread. + * + * |obj| must have passed a JS_Is*Array test, or somehow be known that it would + * pass such a test: it is a typed array or a wrapper of a typed array, and the + * unwrapping will succeed. + */ + +extern JS_FRIEND_API(int8_t *) +JS_GetInt8ArrayData(JSObject *obj); +extern JS_FRIEND_API(uint8_t *) +JS_GetUint8ArrayData(JSObject *obj); +extern JS_FRIEND_API(uint8_t *) +JS_GetUint8ClampedArrayData(JSObject *obj); +extern JS_FRIEND_API(int16_t *) +JS_GetInt16ArrayData(JSObject *obj); +extern JS_FRIEND_API(uint16_t *) +JS_GetUint16ArrayData(JSObject *obj); +extern JS_FRIEND_API(int32_t *) +JS_GetInt32ArrayData(JSObject *obj); +extern JS_FRIEND_API(uint32_t *) +JS_GetUint32ArrayData(JSObject *obj); +extern JS_FRIEND_API(float *) +JS_GetFloat32ArrayData(JSObject *obj); +extern JS_FRIEND_API(double *) +JS_GetFloat64ArrayData(JSObject *obj); + +/* + * Same as above, but for any kind of ArrayBufferView. Prefer the type-specific + * versions when possible. + */ +extern JS_FRIEND_API(void *) +JS_GetArrayBufferViewData(JSObject *obj); + +/* + * Return the ArrayBuffer underlying an ArrayBufferView. If the buffer has been + * neutered, this will still return the neutered buffer. |obj| must be an + * object that would return true for JS_IsArrayBufferViewObject(). + */ +extern JS_FRIEND_API(JSObject *) +JS_GetArrayBufferViewBuffer(JSObject *obj); + +/* + * Check whether obj supports JS_GetDataView* APIs. + */ +JS_FRIEND_API(JSBool) +JS_IsDataViewObject(JSObject *obj); + +/* + * Return the byte offset of a data view into its array buffer. |obj| must be a + * DataView. + * + * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that + * it would pass such a test: it is a data view or a wrapper of a data view, + * and the unwrapping will succeed. + */ +JS_FRIEND_API(uint32_t) +JS_GetDataViewByteOffset(JSObject *obj); + +/* + * Return the byte length of a data view. + * + * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that + * it would pass such a test: it is a data view or a wrapper of a data view, + * and the unwrapping will succeed. If cx is NULL, then DEBUG builds may be + * unable to assert when unwrapping should be disallowed. + */ +JS_FRIEND_API(uint32_t) +JS_GetDataViewByteLength(JSObject *obj); + +/* + * Return a pointer to the beginning of the data referenced by a DataView. + * + * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that + * it would pass such a test: it is a data view or a wrapper of a data view, + * and the unwrapping will succeed. If cx is NULL, then DEBUG builds may be + * unable to assert when unwrapping should be disallowed. + */ +JS_FRIEND_API(void *) +JS_GetDataViewData(JSObject *obj); + +/* + * This struct contains metadata passed from the DOM to the JS Engine for JIT + * optimizations on DOM property accessors. Eventually, this should be made + * available to general JSAPI users, but we are not currently ready to do so. + */ +typedef bool +(* JSJitPropertyOp)(JSContext *cx, JSHandleObject thisObj, + void *specializedThis, JS::Value *vp); +typedef bool +(* JSJitMethodOp)(JSContext *cx, JSHandleObject thisObj, + void *specializedThis, unsigned argc, JS::Value *vp); + +struct JSJitInfo { + enum OpType { + Getter, + Setter, + Method + }; + + JSJitPropertyOp op; + uint32_t protoID; + uint32_t depth; + OpType type; + bool isInfallible; /* Is op fallible? False in setters. */ + bool isConstant; /* Getting a construction-time constant? */ + bool isPure; /* As long as no non-pure DOM things happen, will + keep returning the same value for the given + "this" object" */ + JSValueType returnType; /* The return type tag. Might be JSVAL_TYPE_UNKNOWN */ +}; + +static JS_ALWAYS_INLINE const JSJitInfo * +FUNCTION_VALUE_TO_JITINFO(const JS::Value& v) +{ + JS_ASSERT(js::GetObjectClass(&v.toObject()) == &js::FunctionClass); + return reinterpret_cast(&v.toObject())->jitinfo; +} + +/* Statically asserted in jsfun.h. */ +static const unsigned JS_FUNCTION_INTERPRETED_BIT = 0x1; + +static JS_ALWAYS_INLINE void +SET_JITINFO(JSFunction * func, const JSJitInfo *info) +{ + js::shadow::Function *fun = reinterpret_cast(func); + JS_ASSERT(!(fun->flags & JS_FUNCTION_INTERPRETED_BIT)); + fun->jitinfo = info; +} + +/* + * Engine-internal extensions of jsid. This code is here only until we + * eliminate Gecko's dependencies on it! + */ + +static JS_ALWAYS_INLINE jsid +JSID_FROM_BITS(size_t bits) +{ + jsid id; + JSID_BITS(id) = bits; + return id; +} + +/* + * Must not be used on atoms that are representable as integer jsids. + * Prefer NameToId or AtomToId over this function: + * + * A PropertyName is an atom that does not contain an integer in the range + * [0, UINT32_MAX]. However, jsid can only hold an integer in the range + * [0, JSID_INT_MAX] (where JSID_INT_MAX == 2^31-1). Thus, for the range of + * integers (JSID_INT_MAX, UINT32_MAX], to represent as a jsid 'id', it must be + * the case JSID_IS_ATOM(id) and !JSID_TO_ATOM(id)->isPropertyName(). In most + * cases when creating a jsid, code does not have to care about this corner + * case because: + * + * - When given an arbitrary JSAtom*, AtomToId must be used, which checks for + * integer atoms representable as integer jsids, and does this conversion. + * + * - When given a PropertyName*, NameToId can be used which which does not need + * to do any dynamic checks. + * + * Thus, it is only the rare third case which needs this function, which + * handles any JSAtom* that is known not to be representable with an int jsid. + */ +static JS_ALWAYS_INLINE jsid +NON_INTEGER_ATOM_TO_JSID(JSAtom *atom) +{ + JS_ASSERT(((size_t)atom & 0x7) == 0); + jsid id = JSID_FROM_BITS((size_t)atom); + JS_ASSERT(id == INTERNED_STRING_TO_JSID(NULL, (JSString*)atom)); + return id; +} + +/* All strings stored in jsids are atomized, but are not necessarily property names. */ +static JS_ALWAYS_INLINE JSBool +JSID_IS_ATOM(jsid id) +{ + return JSID_IS_STRING(id); +} + +static JS_ALWAYS_INLINE JSBool +JSID_IS_ATOM(jsid id, JSAtom *atom) +{ + return id == JSID_FROM_BITS((size_t)atom); +} + +static JS_ALWAYS_INLINE JSAtom * +JSID_TO_ATOM(jsid id) +{ + return (JSAtom *)JSID_TO_STRING(id); +} + +JS_STATIC_ASSERT(sizeof(jsid) == JS_BYTES_PER_WORD); + +namespace js { + +static JS_ALWAYS_INLINE Value +IdToValue(jsid id) +{ + if (JSID_IS_STRING(id)) + return StringValue(JSID_TO_STRING(id)); + if (JS_LIKELY(JSID_IS_INT(id))) + return Int32Value(JSID_TO_INT(id)); + if (JS_LIKELY(JSID_IS_OBJECT(id))) + return ObjectValue(*JSID_TO_OBJECT(id)); + JS_ASSERT(JSID_IS_VOID(id)); + return UndefinedValue(); +} + +static JS_ALWAYS_INLINE jsval +IdToJsval(jsid id) +{ + return IdToValue(id); +} + +extern JS_FRIEND_API(bool) +IsReadOnlyDateMethod(JS::IsAcceptableThis test, JS::NativeImpl method); + +extern JS_FRIEND_API(bool) +IsTypedArrayThisCheck(JS::IsAcceptableThis test); + +enum CTypesActivityType { + CTYPES_CALL_BEGIN, + CTYPES_CALL_END, + CTYPES_CALLBACK_BEGIN, + CTYPES_CALLBACK_END +}; + +typedef void +(* CTypesActivityCallback)(JSContext *cx, CTypesActivityType type); + +/* + * Sets a callback that is run whenever js-ctypes is about to be used when + * calling into C. + */ +JS_FRIEND_API(void) +SetCTypesActivityCallback(JSRuntime *rt, CTypesActivityCallback cb); + +class JS_FRIEND_API(AutoCTypesActivityCallback) { + private: + JSContext *cx; + CTypesActivityCallback callback; + CTypesActivityType endType; + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER + + public: + AutoCTypesActivityCallback(JSContext *cx, CTypesActivityType beginType, + CTypesActivityType endType + MOZ_GUARD_OBJECT_NOTIFIER_PARAM); + ~AutoCTypesActivityCallback() { + DoEndCallback(); + } + void DoEndCallback() { + if (callback) { + callback(cx, endType); + callback = NULL; + } + } +}; + +#ifdef DEBUG +extern JS_FRIEND_API(void) +assertEnteredPolicy(JSContext *cx, JSObject *obj, jsid id); +#else +inline void assertEnteredPolicy(JSContext *cx, JSObject *obj, jsid id) {}; +#endif + +/* ES5 8.12.8. */ +extern JS_FRIEND_API(JSBool) +DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp); + +} /* namespace js */ + +extern JS_FRIEND_API(JSBool) +js_DefineOwnProperty(JSContext *cx, JSObject *objArg, jsid idArg, + const js::PropertyDescriptor& descriptor, JSBool *bp); + +extern JS_FRIEND_API(JSBool) +js_ReportIsNotFunction(JSContext *cx, const JS::Value& v); + +#endif /* jsfriendapi_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jslock.h b/scripting/javascript/spidermonkey-mac/include/jslock.h new file mode 100644 index 0000000000..025aaea0af --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jslock.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef jslock_h__ +#define jslock_h__ + +#include "jsapi.h" + +#ifdef JS_THREADSAFE + +# include "pratom.h" +# include "prlock.h" +# include "prcvar.h" +# include "prthread.h" +# include "prinit.h" + +# define JS_ATOMIC_INCREMENT(p) PR_ATOMIC_INCREMENT((int32_t *)(p)) +# define JS_ATOMIC_DECREMENT(p) PR_ATOMIC_DECREMENT((int32_t *)(p)) +# define JS_ATOMIC_ADD(p,v) PR_ATOMIC_ADD((int32_t *)(p), (int32_t)(v)) +# define JS_ATOMIC_SET(p,v) PR_ATOMIC_SET((int32_t *)(p), (int32_t)(v)) + +namespace js { + // Defined in jsgc.cpp. + unsigned GetCPUCount(); +} + +#else /* JS_THREADSAFE */ + +typedef struct PRThread PRThread; +typedef struct PRCondVar PRCondVar; +typedef struct PRLock PRLock; + +# define JS_ATOMIC_INCREMENT(p) (++*(p)) +# define JS_ATOMIC_DECREMENT(p) (--*(p)) +# define JS_ATOMIC_ADD(p,v) (*(p) += (v)) +# define JS_ATOMIC_SET(p,v) (*(p) = (v)) + +#endif /* JS_THREADSAFE */ + +#endif /* jslock_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/json.h b/scripting/javascript/spidermonkey-mac/include/json.h new file mode 100644 index 0000000000..bb21f91451 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/json.h @@ -0,0 +1,46 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef json_h___ +#define json_h___ + +#include "jsprvtd.h" +#include "jspubtd.h" +#include "jsapi.h" + +#include "js/Vector.h" + +#define JSON_MAX_DEPTH 2048 +#define JSON_PARSER_BUFSIZE 1024 + +extern JSObject * +js_InitJSONClass(JSContext *cx, js::HandleObject obj); + +extern JSBool +js_Stringify(JSContext *cx, js::MutableHandleValue vp, + JSObject *replacer, js::Value space, + js::StringBuffer &sb); + +// Avoid build errors on certain platforms that define these names as constants +#undef STRICT +#undef LEGACY + +/* + * The type of JSON decoding to perform. Strict decoding is to-the-spec; + * legacy decoding accepts a few non-JSON syntaxes historically accepted by the + * implementation. (Full description of these deviations is deliberately + * omitted.) New users should use strict decoding rather than legacy decoding, + * as legacy decoding might be removed at a future time. + */ +enum DecodingMode { STRICT, LEGACY }; + +namespace js { + +extern JS_FRIEND_API(JSBool) +ParseJSONWithReviver(JSContext *cx, JS::StableCharPtr chars, size_t length, HandleValue filter, + MutableHandleValue vp, DecodingMode decodingMode = STRICT); + +} /* namespace js */ + +#endif /* json_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsperf.h b/scripting/javascript/spidermonkey-mac/include/jsperf.h new file mode 100644 index 0000000000..265478c33e --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsperf.h @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsperf_h___ +#define jsperf_h___ + +#include "jsapi.h" + +namespace JS { + +/* + * JS::PerfMeasurement is a generic way to access detailed performance + * measurement APIs provided by your operating system. The details of + * exactly how this works and what can be measured are highly + * system-specific, but this interface is (one hopes) implementable + * on top of all of them. + * + * To use this API, create a PerfMeasurement object, passing its + * constructor a bitmask indicating which events you are interested + * in. Thereafter, Start() zeroes all counters and starts timing; + * Stop() stops timing again; and the counters for the events you + * requested are available as data values after calling Stop(). The + * object may be reused for many measurements. + */ +class JS_FRIEND_API(PerfMeasurement) +{ + protected: + // Implementation-specific data, if any. + void* impl; + + public: + /* + * Events that may be measured. Taken directly from the list of + * "generalized hardware performance event types" in the Linux + * perf_event API, plus some of the "software events". + */ + enum EventMask { + CPU_CYCLES = 0x00000001, + INSTRUCTIONS = 0x00000002, + CACHE_REFERENCES = 0x00000004, + CACHE_MISSES = 0x00000008, + BRANCH_INSTRUCTIONS = 0x00000010, + BRANCH_MISSES = 0x00000020, + BUS_CYCLES = 0x00000040, + PAGE_FAULTS = 0x00000080, + MAJOR_PAGE_FAULTS = 0x00000100, + CONTEXT_SWITCHES = 0x00000200, + CPU_MIGRATIONS = 0x00000400, + + ALL = 0x000007ff, + NUM_MEASURABLE_EVENTS = 11 + }; + + /* + * Bitmask of events that will be measured when this object is + * active (between Start() and Stop()). This may differ from the + * bitmask passed to the constructor if the platform does not + * support measuring all of the requested events. + */ + const EventMask eventsMeasured; + + /* + * Counters for each measurable event. + * Immediately after one of these objects is created, all of the + * counters for enabled events will be zero, and all of the + * counters for disabled events will be uint64_t(-1). + */ + uint64_t cpu_cycles; + uint64_t instructions; + uint64_t cache_references; + uint64_t cache_misses; + uint64_t branch_instructions; + uint64_t branch_misses; + uint64_t bus_cycles; + uint64_t page_faults; + uint64_t major_page_faults; + uint64_t context_switches; + uint64_t cpu_migrations; + + /* + * Prepare to measure the indicated set of events. If not all of + * the requested events can be measured on the current platform, + * then the eventsMeasured bitmask will only include the subset of + * |toMeasure| corresponding to the events that can be measured. + */ + PerfMeasurement(EventMask toMeasure); + + /* Done with this set of measurements, tear down OS-level state. */ + ~PerfMeasurement(); + + /* Start a measurement cycle. */ + void start(); + + /* + * End a measurement cycle, and for each enabled counter, add the + * number of measured events of that type to the appropriate + * visible variable. + */ + void stop(); + + /* Reset all enabled counters to zero. */ + void reset(); + + /* + * True if this platform supports measuring _something_, i.e. it's + * not using the stub implementation. + */ + static bool canMeasureSomething(); +}; + +/* Inject a Javascript wrapper around the above C++ class into the + * Javascript object passed as an argument (this will normally be a + * global object). The JS-visible API is identical to the C++ API. + */ +extern JS_FRIEND_API(JSObject*) + RegisterPerfMeasurement(JSContext *cx, JSRawObject global); + +/* + * Given a jsval which contains an instance of the aforementioned + * wrapper class, extract the C++ object. Returns NULL if the + * jsval is not an instance of the wrapper. + */ +extern JS_FRIEND_API(PerfMeasurement*) + ExtractPerfMeasurement(jsval wrapper); + +} // namespace JS + +#endif // jsperf_h___ diff --git a/scripting/javascript/spidermonkey-mac/include/jsprf.h b/scripting/javascript/spidermonkey-mac/include/jsprf.h new file mode 100644 index 0000000000..4c2bef91d2 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsprf.h @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsprf_h___ +#define jsprf_h___ + +/* +** API for PR printf like routines. Supports the following formats +** %d - decimal +** %u - unsigned decimal +** %x - unsigned hex +** %X - unsigned uppercase hex +** %o - unsigned octal +** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above +** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above +** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above +** %s - ascii string +** %hs - ucs2 string +** %c - character +** %p - pointer (deals with machine dependent pointer size) +** %f - float +** %g - float +*/ +#include "jstypes.h" +#include +#include + +/* +** sprintf into a fixed size buffer. Guarantees that a NUL is at the end +** of the buffer. Returns the length of the written output, NOT including +** the NUL, or (uint32_t)-1 if an error occurs. +*/ +extern JS_PUBLIC_API(uint32_t) JS_snprintf(char *out, uint32_t outlen, const char *fmt, ...); + +/* +** sprintf into a malloc'd buffer. Return a pointer to the malloc'd +** buffer on success, NULL on failure. Call "JS_smprintf_free" to release +** the memory returned. +*/ +extern JS_PUBLIC_API(char*) JS_smprintf(const char *fmt, ...); + +/* +** Free the memory allocated, for the caller, by JS_smprintf +*/ +extern JS_PUBLIC_API(void) JS_smprintf_free(char *mem); + +/* +** "append" sprintf into a malloc'd buffer. "last" is the last value of +** the malloc'd buffer. sprintf will append data to the end of last, +** growing it as necessary using realloc. If last is NULL, JS_sprintf_append +** will allocate the initial string. The return value is the new value of +** last for subsequent calls, or NULL if there is a malloc failure. +*/ +extern JS_PUBLIC_API(char*) JS_sprintf_append(char *last, const char *fmt, ...); + +/* +** sprintf into a function. The function "f" is called with a string to +** place into the output. "arg" is an opaque pointer used by the stuff +** function to hold any state needed to do the storage of the output +** data. The return value is a count of the number of characters fed to +** the stuff function, or (uint32_t)-1 if an error occurs. +*/ +typedef int (*JSStuffFunc)(void *arg, const char *s, uint32_t slen); + +extern JS_PUBLIC_API(uint32_t) JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...); + +/* +** va_list forms of the above. +*/ +extern JS_PUBLIC_API(uint32_t) JS_vsnprintf(char *out, uint32_t outlen, const char *fmt, va_list ap); +extern JS_PUBLIC_API(char*) JS_vsmprintf(const char *fmt, va_list ap); +extern JS_PUBLIC_API(char*) JS_vsprintf_append(char *last, const char *fmt, va_list ap); +extern JS_PUBLIC_API(uint32_t) JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap); + +#endif /* jsprf_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsprototypes.h b/scripting/javascript/spidermonkey-mac/include/jsprototypes.h new file mode 100644 index 0000000000..27f5c84450 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsprototypes.h @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* A higher-order macro for enumerating all JSProtoKey values. */ + +#ifndef jsprototypes_h___ +#define jsprototypes_h___ + +#include "jsversion.h" + +/* + * Enumerator codes in the second column must not change -- they are part of + * the JS XDR API. Also note the symbols in the third column are extern "C"; + * clients should use extern "C" {} as appropriate when using this macro. + */ + +#define JS_FOR_EACH_PROTOTYPE(macro) \ + macro(Null, 0, js_InitNullClass) \ + macro(Object, 1, js_InitObjectClass) \ + macro(Function, 2, js_InitFunctionClass) \ + macro(Array, 3, js_InitArrayClass) \ + macro(Boolean, 4, js_InitBooleanClass) \ + macro(JSON, 5, js_InitJSONClass) \ + macro(Date, 6, js_InitDateClass) \ + macro(Math, 7, js_InitMathClass) \ + macro(Number, 8, js_InitNumberClass) \ + macro(String, 9, js_InitStringClass) \ + macro(RegExp, 10, js_InitRegExpClass) \ + macro(Error, 11, js_InitExceptionClasses) \ + macro(InternalError, 12, js_InitExceptionClasses) \ + macro(EvalError, 13, js_InitExceptionClasses) \ + macro(RangeError, 14, js_InitExceptionClasses) \ + macro(ReferenceError, 15, js_InitExceptionClasses) \ + macro(SyntaxError, 16, js_InitExceptionClasses) \ + macro(TypeError, 17, js_InitExceptionClasses) \ + macro(URIError, 18, js_InitExceptionClasses) \ + macro(Iterator, 19, js_InitIteratorClasses) \ + macro(StopIteration, 20, js_InitIteratorClasses) \ + macro(ArrayBuffer, 21, js_InitTypedArrayClasses) \ + macro(Int8Array, 22, js_InitTypedArrayClasses) \ + macro(Uint8Array, 23, js_InitTypedArrayClasses) \ + macro(Int16Array, 24, js_InitTypedArrayClasses) \ + macro(Uint16Array, 25, js_InitTypedArrayClasses) \ + macro(Int32Array, 26, js_InitTypedArrayClasses) \ + macro(Uint32Array, 27, js_InitTypedArrayClasses) \ + macro(Float32Array, 28, js_InitTypedArrayClasses) \ + macro(Float64Array, 29, js_InitTypedArrayClasses) \ + macro(Uint8ClampedArray, 30, js_InitTypedArrayClasses) \ + macro(Proxy, 31, js_InitProxyClass) \ + macro(WeakMap, 32, js_InitWeakMapClass) \ + macro(Map, 33, js_InitMapClass) \ + macro(Set, 34, js_InitSetClass) \ + macro(DataView, 35, js_InitTypedArrayClasses) \ + macro(ParallelArray, 36, js_InitParallelArrayClass) \ + macro(Intl, 37, js_InitIntlClass) \ + +#endif /* jsprototypes_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsproxy.h b/scripting/javascript/spidermonkey-mac/include/jsproxy.h new file mode 100644 index 0000000000..0637ceac8f --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsproxy.h @@ -0,0 +1,435 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsproxy_h___ +#define jsproxy_h___ + +#include "jsapi.h" +#include "jsfriendapi.h" + +namespace js { + +class JS_FRIEND_API(Wrapper); + +/* + * A proxy is a JSObject that implements generic behavior by providing custom + * implementations for each object trap. The implementation for each trap is + * provided by a C++ object stored on the proxy, known as its handler. + * + * A major use case for proxies is to forward each trap to another object, + * known as its target. The target can be an arbitrary C++ object. Not every + * proxy has the notion of a target, however. + * + * Proxy traps are grouped into fundamental and derived traps. Every proxy has + * to at least provide implementations for the fundamental traps, but the + * derived traps can be implemented in terms of the fundamental ones + * BaseProxyHandler provides implementations of the derived traps in terms of + * the (pure virtual) fundamental traps. + * + * To minimize code duplication, a set of abstract proxy handler classes is + * provided, from which other handlers may inherit. These abstract classes + * are organized in the following hierarchy: + * + * BaseProxyHandler + * | + * DirectProxyHandler + * | + * Wrapper + */ + +/* + * BaseProxyHandler is the most generic kind of proxy handler. It does not make + * any assumptions about the target. Consequently, it does not provide any + * default implementation for the fundamental traps. It does, however, implement + * the derived traps in terms of the fundamental ones. This allows consumers of + * this class to define any custom behavior they want. + */ +class JS_FRIEND_API(BaseProxyHandler) +{ + void *mFamily; + bool mHasPrototype; + bool mHasPolicy; + protected: + // Subclasses may set this in their constructor. + void setHasPrototype(bool aHasPrototype) { mHasPrototype = aHasPrototype; } + void setHasPolicy(bool aHasPolicy) { mHasPolicy = aHasPolicy; } + + public: + explicit BaseProxyHandler(void *family); + virtual ~BaseProxyHandler(); + + bool hasPrototype() { + return mHasPrototype; + } + + bool hasPolicy() { + return mHasPolicy; + } + + inline void *family() { + return mFamily; + } + + virtual bool isOuterWindow() { + return false; + } + + virtual bool finalizeInBackground(Value priv) { + /* + * Called on creation of a proxy to determine whether its finalize + * method can be finalized on the background thread. + */ + return true; + } + + /* Policy enforcement traps. + * + * enter() allows the policy to specify whether the caller may perform |act| + * on the proxy's |id| property. In the case when |act| is CALL, |id| is + * generally JSID_VOID. + * + * The |act| parameter to enter() specifies the action being performed. + * If |bp| is false, the trap suggests that the caller throw (though it + * may still decide to squelch the error). + */ + enum Action { + GET, + SET, + CALL + }; + virtual bool enter(JSContext *cx, HandleObject wrapper, HandleId id, Action act, + bool *bp); + + /* ES5 Harmony fundamental proxy traps. */ + virtual bool preventExtensions(JSContext *cx, HandleObject proxy) = 0; + virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, + PropertyDescriptor *desc, unsigned flags) = 0; + virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, + HandleId id, PropertyDescriptor *desc, + unsigned flags) = 0; + virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, + PropertyDescriptor *desc) = 0; + virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, + AutoIdVector &props) = 0; + virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) = 0; + virtual bool enumerate(JSContext *cx, HandleObject proxy, AutoIdVector &props) = 0; + + /* ES5 Harmony derived proxy traps. */ + virtual bool has(JSContext *cx, HandleObject proxy, HandleId id, bool *bp); + virtual bool hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool *bp); + virtual bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, + HandleId id, MutableHandleValue vp); + virtual bool set(JSContext *cx, HandleObject proxy, HandleObject receiver, + HandleId id, bool strict, MutableHandleValue vp); + virtual bool keys(JSContext *cx, HandleObject proxy, AutoIdVector &props); + virtual bool iterate(JSContext *cx, HandleObject proxy, unsigned flags, + MutableHandleValue vp); + + /* Spidermonkey extensions. */ + virtual bool isExtensible(JSObject *proxy) = 0; + virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp); + virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc, + Value *argv, MutableHandleValue rval); + virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args); + virtual bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp); + virtual bool objectClassIs(HandleObject obj, ESClassValue classValue, JSContext *cx); + virtual JSString *obj_toString(JSContext *cx, HandleObject proxy); + virtual JSString *fun_toString(JSContext *cx, HandleObject proxy, unsigned indent); + virtual bool regexp_toShared(JSContext *cx, HandleObject proxy, RegExpGuard *g); + virtual bool defaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp); + virtual void finalize(JSFreeOp *fop, JSObject *proxy); + virtual bool getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, + uint32_t index, MutableHandleValue vp, bool *present); + virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop); + + /* See comment for weakmapKeyDelegateOp in jsclass.h. */ + virtual JSObject *weakmapKeyDelegate(JSObject *proxy); +}; + +/* + * DirectProxyHandler includes a notion of a target object. All traps are + * reimplemented such that they forward their behavior to the target. This + * allows consumers of this class to forward to another object as transparently + * and efficiently as possible. + */ +class JS_PUBLIC_API(DirectProxyHandler) : public BaseProxyHandler +{ + public: + explicit DirectProxyHandler(void *family); + + /* ES5 Harmony fundamental proxy traps. */ + virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE; + virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, + PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE; + virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, + HandleId id, PropertyDescriptor *desc, + unsigned flags) MOZ_OVERRIDE; + virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, + PropertyDescriptor *desc) MOZ_OVERRIDE; + virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, + AutoIdVector &props) MOZ_OVERRIDE; + virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, + bool *bp) MOZ_OVERRIDE; + virtual bool enumerate(JSContext *cx, HandleObject proxy, + AutoIdVector &props) MOZ_OVERRIDE; + + /* ES5 Harmony derived proxy traps. */ + virtual bool has(JSContext *cx, HandleObject proxy, HandleId id, + bool *bp) MOZ_OVERRIDE; + virtual bool hasOwn(JSContext *cx, HandleObject proxy, HandleId id, + bool *bp) MOZ_OVERRIDE; + virtual bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, + HandleId id, MutableHandleValue vp) MOZ_OVERRIDE; + virtual bool set(JSContext *cx, HandleObject proxy, HandleObject receiver, + HandleId id, bool strict, MutableHandleValue vp) MOZ_OVERRIDE; + virtual bool keys(JSContext *cx, HandleObject proxy, + AutoIdVector &props) MOZ_OVERRIDE; + virtual bool iterate(JSContext *cx, HandleObject proxy, unsigned flags, + MutableHandleValue vp) MOZ_OVERRIDE; + + /* Spidermonkey extensions. */ + virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE; + virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp) MOZ_OVERRIDE; + virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc, + Value *argv, MutableHandleValue rval) MOZ_OVERRIDE; + virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, + CallArgs args) MOZ_OVERRIDE; + virtual bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, + bool *bp) MOZ_OVERRIDE; + virtual bool objectClassIs(HandleObject obj, ESClassValue classValue, + JSContext *cx) MOZ_OVERRIDE; + virtual JSString *obj_toString(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE; + virtual JSString *fun_toString(JSContext *cx, HandleObject proxy, + unsigned indent) MOZ_OVERRIDE; + virtual bool regexp_toShared(JSContext *cx, HandleObject proxy, + RegExpGuard *g) MOZ_OVERRIDE; + virtual bool defaultValue(JSContext *cx, HandleObject obj, JSType hint, + MutableHandleValue vp) MOZ_OVERRIDE; + virtual JSObject *weakmapKeyDelegate(JSObject *proxy); +}; + +/* Dispatch point for handlers that executes the appropriate C++ or scripted traps. */ +class Proxy +{ + public: + /* ES5 Harmony fundamental proxy traps. */ + static bool preventExtensions(JSContext *cx, HandleObject proxy); + static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, + PropertyDescriptor *desc, unsigned flags); + static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id, + MutableHandleValue vp); + static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, + PropertyDescriptor *desc, unsigned flags); + static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id, + MutableHandleValue vp); + static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, PropertyDescriptor *desc); + static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, HandleValue v); + static bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props); + static bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp); + static bool enumerate(JSContext *cx, HandleObject proxy, AutoIdVector &props); + + /* ES5 Harmony derived proxy traps. */ + static bool has(JSContext *cx, HandleObject proxy, HandleId id, bool *bp); + static bool hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool *bp); + static bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id, + MutableHandleValue vp); + static bool getElementIfPresent(JSContext *cx, HandleObject proxy, HandleObject receiver, + uint32_t index, MutableHandleValue vp, bool *present); + static bool set(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id, + bool strict, MutableHandleValue vp); + static bool keys(JSContext *cx, HandleObject proxy, AutoIdVector &props); + static bool iterate(JSContext *cx, HandleObject proxy, unsigned flags, MutableHandleValue vp); + + /* Spidermonkey extensions. */ + static bool isExtensible(JSObject *proxy); + static bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp); + static bool construct(JSContext *cx, HandleObject proxy, unsigned argc, Value *argv, + MutableHandleValue rval); + static bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args); + static bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp); + static bool objectClassIs(HandleObject obj, ESClassValue classValue, JSContext *cx); + static JSString *obj_toString(JSContext *cx, HandleObject proxy); + static JSString *fun_toString(JSContext *cx, HandleObject proxy, unsigned indent); + static bool regexp_toShared(JSContext *cx, HandleObject proxy, RegExpGuard *g); + static bool defaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp); + static bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop); + + static JSObject * const LazyProto; +}; + +inline bool IsObjectProxyClass(const Class *clasp) +{ + return clasp == &js::ObjectProxyClass || clasp == &js::OuterWindowProxyClass; +} + +inline bool IsFunctionProxyClass(const Class *clasp) +{ + return clasp == &js::FunctionProxyClass; +} + +inline bool IsObjectProxy(RawObject obj) +{ + return IsObjectProxyClass(GetObjectClass(obj)); +} + +inline bool IsFunctionProxy(RawObject obj) +{ + return IsFunctionProxyClass(GetObjectClass(obj)); +} + +inline bool IsProxy(RawObject obj) +{ + Class *clasp = GetObjectClass(obj); + return IsObjectProxyClass(clasp) || IsFunctionProxyClass(clasp); +} + +/* Shared between object and function proxies. */ +/* + * NOTE: JSSLOT_PROXY_PRIVATE is 0, because that way slot 0 is usable by API + * clients for both proxy and non-proxy objects. So an API client that only + * needs to store one slot's worth of data doesn't need to branch on what sort + * of object it has. + */ +const uint32_t JSSLOT_PROXY_PRIVATE = 0; +const uint32_t JSSLOT_PROXY_HANDLER = 1; +const uint32_t JSSLOT_PROXY_EXTRA = 2; +/* Function proxies only. */ +const uint32_t JSSLOT_PROXY_CALL = 4; +const uint32_t JSSLOT_PROXY_CONSTRUCT = 5; + +inline BaseProxyHandler * +GetProxyHandler(RawObject obj) +{ + JS_ASSERT(IsProxy(obj)); + return (BaseProxyHandler *) GetReservedSlot(obj, JSSLOT_PROXY_HANDLER).toPrivate(); +} + +inline const Value & +GetProxyPrivate(RawObject obj) +{ + JS_ASSERT(IsProxy(obj)); + return GetReservedSlot(obj, JSSLOT_PROXY_PRIVATE); +} + +inline JSObject * +GetProxyTargetObject(RawObject obj) +{ + JS_ASSERT(IsProxy(obj)); + return GetProxyPrivate(obj).toObjectOrNull(); +} + +inline const Value & +GetProxyExtra(RawObject obj, size_t n) +{ + JS_ASSERT(IsProxy(obj)); + return GetReservedSlot(obj, JSSLOT_PROXY_EXTRA + n); +} + +inline void +SetProxyHandler(RawObject obj, BaseProxyHandler *handler) +{ + JS_ASSERT(IsProxy(obj)); + SetReservedSlot(obj, JSSLOT_PROXY_HANDLER, PrivateValue(handler)); +} + +inline void +SetProxyExtra(RawObject obj, size_t n, const Value &extra) +{ + JS_ASSERT(IsProxy(obj)); + JS_ASSERT(n <= 1); + SetReservedSlot(obj, JSSLOT_PROXY_EXTRA + n, extra); +} + +enum ProxyCallable { + ProxyNotCallable = false, + ProxyIsCallable = true +}; + +JS_FRIEND_API(JSObject *) +NewProxyObject(JSContext *cx, BaseProxyHandler *handler, const Value &priv, + JSObject *proto, JSObject *parent, ProxyCallable callable = ProxyNotCallable); + +JSObject * +RenewProxyObject(JSContext *cx, JSObject *obj, BaseProxyHandler *handler, Value priv); + +class JS_FRIEND_API(AutoEnterPolicy) +{ + public: + typedef BaseProxyHandler::Action Action; + AutoEnterPolicy(JSContext *cx, BaseProxyHandler *handler, + HandleObject wrapper, HandleId id, Action act, bool mayThrow) +#ifdef DEBUG + : context(NULL) +#endif + { + allow = handler->hasPolicy() ? handler->enter(cx, wrapper, id, act, &rv) + : true; + recordEnter(cx, wrapper, id); + // We want to throw an exception if all of the following are true: + // * The policy disallowed access. + // * The policy set rv to false, indicating that we should throw. + // * The caller did not instruct us to ignore exceptions. + // * The policy did not throw itself. + if (!allow && !rv && mayThrow && !JS_IsExceptionPending(cx)) + reportError(cx, id); + } + + virtual ~AutoEnterPolicy() { recordLeave(); } + inline bool allowed() { return allow; } + inline bool returnValue() { JS_ASSERT(!allowed()); return rv; } + + protected: + // no-op constructor for subclass + AutoEnterPolicy() +#ifdef DEBUG + : context(NULL) +#endif + {}; + void reportError(JSContext *cx, jsid id); + bool allow; + bool rv; + +#ifdef DEBUG + JSContext *context; + mozilla::Maybe enteredProxy; + mozilla::Maybe enteredId; + // NB: We explicitly don't track the entered action here, because sometimes + // SET traps do an implicit GET during their implementation, leading to + // spurious assertions. + AutoEnterPolicy *prev; + void recordEnter(JSContext *cx, HandleObject proxy, HandleId id); + void recordLeave(); + + friend JS_FRIEND_API(void) assertEnteredPolicy(JSContext *cx, JSObject *proxy, jsid id); +#else + inline void recordEnter(JSContext *cx, JSObject *proxy, jsid id) {} + inline void recordLeave() {} +#endif + +}; + +#ifdef DEBUG +class JS_FRIEND_API(AutoWaivePolicy) : public AutoEnterPolicy { +public: + AutoWaivePolicy(JSContext *cx, HandleObject proxy, HandleId id) + { + allow = true; + recordEnter(cx, proxy, id); + } +}; +#else +class JS_FRIEND_API(AutoWaivePolicy) { + public: AutoWaivePolicy(JSContext *cx, HandleObject proxy, HandleId id) {}; +}; +#endif + +} /* namespace js */ + +extern JS_FRIEND_API(JSObject *) +js_InitProxyClass(JSContext *cx, JSHandleObject obj); + +#endif diff --git a/scripting/javascript/spidermonkey-mac/include/jsprvtd.h b/scripting/javascript/spidermonkey-mac/include/jsprvtd.h new file mode 100644 index 0000000000..203df3de58 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsprvtd.h @@ -0,0 +1,315 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsprvtd_h___ +#define jsprvtd_h___ +/* + * JS private typename definitions. + * + * This header is included only in other .h files, for convenience and for + * simplicity of type naming. The alternative for structures is to use tags, + * which are named the same as their typedef names (legal in C/C++, and less + * noisy than suffixing the typedef name with "Struct" or "Str"). Instead, + * all .h files that include this file may use the same typedef name, whether + * declaring a pointer to struct type, or defining a member of struct type. + * + * A few fundamental scalar types are defined here too. Neither the scalar + * nor the struct typedefs should change much, therefore the nearly-global + * make dependency induced by this file should not prove painful. + */ + +#include "jsapi.h" +#include "jsutil.h" + +#ifdef __cplusplus +#include "js/HashTable.h" +#include "js/Vector.h" +#endif + +/* + * Convenience constants. + */ +#define JS_BITS_PER_UINT32_LOG2 5 +#define JS_BITS_PER_UINT32 32 + +/* The alignment required of objects stored in GC arenas. */ +static const unsigned JS_GCTHING_ALIGN = 8; +static const unsigned JS_GCTHING_ZEROBITS = 3; + +/* Scalar typedefs. */ +typedef uint8_t jsbytecode; +typedef uint8_t jssrcnote; +typedef uintptr_t jsatomid; + +/* Struct typedefs. */ +typedef struct JSGCThing JSGCThing; +typedef struct JSGenerator JSGenerator; +typedef struct JSNativeEnumerator JSNativeEnumerator; +typedef struct JSTryNote JSTryNote; + +/* Friend "Advanced API" typedefs. */ +typedef struct JSAtomState JSAtomState; +typedef struct JSCodeSpec JSCodeSpec; +typedef struct JSPrinter JSPrinter; +typedef struct JSStackHeader JSStackHeader; +typedef struct JSSubString JSSubString; +typedef struct JSSpecializedNative JSSpecializedNative; + +/* + * Template declarations. + * + * jsprvtd.h can be included in both C and C++ translation units. For C++, it + * may possibly be wrapped in an extern "C" block which does not agree with + * templates. + */ +#ifdef __cplusplus + +extern "C++" { + +class JSDependentString; +class JSExtensibleString; +class JSExternalString; +class JSLinearString; +class JSRope; +class JSAtom; +class JSWrapper; + +namespace js { + +struct ArgumentsData; +struct Class; + +class RegExpGuard; +class RegExpObject; +class RegExpObjectBuilder; +class RegExpShared; +class RegExpStatics; +class MatchPairs; +class PropertyName; + +enum RegExpFlag +{ + IgnoreCaseFlag = 0x01, + GlobalFlag = 0x02, + MultilineFlag = 0x04, + StickyFlag = 0x08, + + NoFlags = 0x00, + AllFlags = 0x0f +}; + +class ExecuteArgsGuard; +class InvokeFrameGuard; +class InvokeArgsGuard; +class StringBuffer; + +class FrameRegs; +class StackFrame; +class StackSegment; +class StackSpace; +class ContextStack; +class ScriptFrameIter; + +class Proxy; +class JS_FRIEND_API(BaseProxyHandler); +class JS_FRIEND_API(Wrapper); +class JS_FRIEND_API(CrossCompartmentWrapper); + +class TempAllocPolicy; +class RuntimeAllocPolicy; + +class GlobalObject; + +template +class InlineMap; + +class LifoAlloc; + +class Shape; + +class Breakpoint; +class BreakpointSite; +class Debugger; +class WatchpointMap; + +/* + * Env is the type of what ES5 calls "lexical environments" (runtime + * activations of lexical scopes). This is currently just JSObject, and is + * implemented by Call, Block, With, and DeclEnv objects, among others--but + * environments and objects are really two different concepts. + */ +typedef JSObject Env; + +typedef JSNative Native; +typedef JSPropertyOp PropertyOp; +typedef JSStrictPropertyOp StrictPropertyOp; +typedef JSPropertyDescriptor PropertyDescriptor; + +namespace frontend { + +struct BytecodeEmitter; +struct Definition; +class FunctionBox; +class ObjectBox; +struct Token; +struct TokenPos; +class TokenStream; +class ParseMapPool; +struct ParseNode; + +template +struct Parser; + +} /* namespace frontend */ + +namespace analyze { + +struct LifetimeVariable; +class LoopAnalysis; +class ScriptAnalysis; +class SlotValue; +class SSAValue; +class SSAUseChain; + +} /* namespace analyze */ + +namespace types { + +class TypeSet; +struct TypeCallsite; +struct TypeObject; +struct TypeCompartment; + +} /* namespace types */ + +typedef JS::Handle HandleShape; +typedef JS::Handle HandleTypeObject; +typedef JS::Handle HandleAtom; +typedef JS::Handle HandlePropertyName; + +typedef JS::MutableHandle MutableHandleShape; +typedef JS::MutableHandle MutableHandleAtom; + +typedef JS::Rooted RootedShape; +typedef JS::Rooted RootedTypeObject; +typedef JS::Rooted RootedAtom; +typedef JS::Rooted RootedPropertyName; + +enum XDRMode { + XDR_ENCODE, + XDR_DECODE +}; + +template +class XDRState; + +class FreeOp; + +struct IdValuePair +{ + jsid id; + Value value; + + IdValuePair() {} + IdValuePair(jsid idArg) + : id(idArg), value(UndefinedValue()) + {} +}; + +} /* namespace js */ + +namespace JSC { + +class ExecutableAllocator; + +} /* namespace JSC */ + +namespace WTF { + +class BumpPointerAllocator; + +} /* namespace WTF */ + +} /* export "C++" */ + +#else + +typedef struct JSAtom JSAtom; + +#endif /* __cplusplus */ + +/* "Friend" types used by jscntxt.h and jsdbgapi.h. */ +typedef enum JSTrapStatus { + JSTRAP_ERROR, + JSTRAP_CONTINUE, + JSTRAP_RETURN, + JSTRAP_THROW, + JSTRAP_LIMIT +} JSTrapStatus; + +typedef JSTrapStatus +(* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, + jsval closure); + +typedef JSTrapStatus +(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, + void *closure); + +typedef JSTrapStatus +(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, + void *closure); + +typedef JSTrapStatus +(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, + void *closure); + +typedef JSBool +(* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, jsval old, + jsval *newp, void *closure); + +/* called just after script creation */ +typedef void +(* JSNewScriptHook)(JSContext *cx, + const char *filename, /* URL of script */ + unsigned lineno, /* first line */ + JSScript *script, + JSFunction *fun, + void *callerdata); + +/* called just before script destruction */ +typedef void +(* JSDestroyScriptHook)(JSFreeOp *fop, + JSScript *script, + void *callerdata); + +typedef void +(* JSSourceHandler)(const char *filename, unsigned lineno, const jschar *str, + size_t length, void **listenerTSData, void *closure); + +/* js::ObjectOps function pointer typedefs. */ + +/* + * A generic type for functions mapping an object to another object, or null + * if an error or exception was thrown on cx. + */ +typedef JSObject * +(* JSObjectOp)(JSContext *cx, JSHandleObject obj); + +/* Signature for class initialization ops. */ +typedef JSObject * +(* JSClassInitializerOp)(JSContext *cx, JSHandleObject obj); + +/* + * Hook that creates an iterator object for a given object. Returns the + * iterator object or null if an error or exception was thrown on cx. + */ +typedef JSObject * +(* JSIteratorOp)(JSContext *cx, JSHandleObject obj, JSBool keysonly); + + +#endif /* jsprvtd_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jspubtd.h b/scripting/javascript/spidermonkey-mac/include/jspubtd.h new file mode 100644 index 0000000000..c629203773 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jspubtd.h @@ -0,0 +1,392 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jspubtd_h___ +#define jspubtd_h___ + +/* + * JS public API typedefs. + */ + +#include "jsprototypes.h" +#include "jstypes.h" + + +namespace JS { + +/* + * Allow headers to reference JS::Value without #including the whole jsapi.h. + * Unfortunately, typedefs (hence jsval) cannot be declared. + */ +class Value; + +template +class Rooted; + +struct Zone; + +} /* namespace JS */ + +/* + * In release builds, jsid is defined to be an integral type. This + * prevents many bugs from being caught at compile time. E.g.: + * + * jsid id = ... + * if (id == JS_TRUE) // error + * ... + * + * size_t n = id; // error + * + * To catch more errors, jsid is given a struct type in C++ debug builds. + * Struct assignment and (in C++) operator== allow correct code to be mostly + * oblivious to the change. This feature can be explicitly disabled in debug + * builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES. + */ +#ifdef __cplusplus + +// Needed for cocos2d-js +#define JS_NO_JSVAL_JSID_STRUCT_TYPES + +# if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES) +# define JS_USE_JSID_STRUCT_TYPES +# endif + +# ifdef JS_USE_JSID_STRUCT_TYPES +struct jsid +{ + size_t asBits; + bool operator==(jsid rhs) const { return asBits == rhs.asBits; } + bool operator!=(jsid rhs) const { return asBits != rhs.asBits; } +}; +# define JSID_BITS(id) (id.asBits) +# else /* defined(JS_USE_JSID_STRUCT_TYPES) */ +typedef ptrdiff_t jsid; +# define JSID_BITS(id) (id) +# endif /* defined(JS_USE_JSID_STRUCT_TYPES) */ +#else /* defined(__cplusplus) */ +typedef ptrdiff_t jsid; +# define JSID_BITS(id) (id) +#endif + +#ifdef WIN32 +typedef wchar_t jschar; +#else +typedef uint16_t jschar; +#endif + +/* + * Run-time version enumeration. See jsversion.h for compile-time counterparts + * to these values that may be selected by the JS_VERSION macro, and tested by + * #if expressions. + */ +typedef enum JSVersion { + JSVERSION_ECMA_3 = 148, + JSVERSION_1_6 = 160, + JSVERSION_1_7 = 170, + JSVERSION_1_8 = 180, + JSVERSION_ECMA_5 = 185, + JSVERSION_DEFAULT = 0, + JSVERSION_UNKNOWN = -1, + JSVERSION_LATEST = JSVERSION_ECMA_5 +} JSVersion; + +/* Result of typeof operator enumeration. */ +typedef enum JSType { + JSTYPE_VOID, /* undefined */ + JSTYPE_OBJECT, /* object */ + JSTYPE_FUNCTION, /* function */ + JSTYPE_STRING, /* string */ + JSTYPE_NUMBER, /* number */ + JSTYPE_BOOLEAN, /* boolean */ + JSTYPE_NULL, /* null */ + JSTYPE_LIMIT +} JSType; + +/* Dense index into cached prototypes and class atoms for standard objects. */ +typedef enum JSProtoKey { +#define PROTOKEY_AND_INITIALIZER(name,code,init) JSProto_##name = code, + JS_FOR_EACH_PROTOTYPE(PROTOKEY_AND_INITIALIZER) +#undef JS_PROTO + JSProto_LIMIT +} JSProtoKey; + +/* js_CheckAccess mode enumeration. */ +typedef enum JSAccessMode { + JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */ + + /* + * enum value #1 formerly called JSACC_PARENT, + * gap preserved for ABI compatibility. + */ + + /* + * enum value #2 formerly called JSACC_IMPORT, + * gap preserved for ABI compatibility. + */ + + JSACC_WATCH = 3, /* a watchpoint on object foo for id 'bar' */ + JSACC_READ = 4, /* a "get" of foo.bar */ + JSACC_WRITE = 8, /* a "set" of foo.bar = baz */ + JSACC_LIMIT +} JSAccessMode; + +#define JSACC_TYPEMASK (JSACC_WRITE - 1) + +/* + * This enum type is used to control the behavior of a JSObject property + * iterator function that has type JSNewEnumerate. + */ +typedef enum JSIterateOp { + /* Create new iterator state over enumerable properties. */ + JSENUMERATE_INIT, + + /* Create new iterator state over all properties. */ + JSENUMERATE_INIT_ALL, + + /* Iterate once. */ + JSENUMERATE_NEXT, + + /* Destroy iterator state. */ + JSENUMERATE_DESTROY +} JSIterateOp; + +/* See JSVAL_TRACE_KIND and JSTraceCallback in jsapi.h. */ +typedef enum { + JSTRACE_OBJECT, + JSTRACE_STRING, + JSTRACE_SCRIPT, + + /* + * Trace kinds internal to the engine. The embedding can only them if it + * implements JSTraceCallback. + */ + JSTRACE_IONCODE, + JSTRACE_SHAPE, + JSTRACE_BASE_SHAPE, + JSTRACE_TYPE_OBJECT, + JSTRACE_LAST = JSTRACE_TYPE_OBJECT +} JSGCTraceKind; + +/* Struct typedefs and class forward declarations. */ +typedef struct JSClass JSClass; +typedef struct JSCompartment JSCompartment; +typedef struct JSConstDoubleSpec JSConstDoubleSpec; +typedef struct JSContext JSContext; +typedef struct JSCrossCompartmentCall JSCrossCompartmentCall; +typedef struct JSErrorReport JSErrorReport; +typedef struct JSExceptionState JSExceptionState; +typedef struct JSFunctionSpec JSFunctionSpec; +typedef struct JSIdArray JSIdArray; +typedef struct JSLocaleCallbacks JSLocaleCallbacks; +typedef struct JSObjectMap JSObjectMap; +typedef struct JSPrincipals JSPrincipals; +typedef struct JSPropertyDescriptor JSPropertyDescriptor; +typedef struct JSPropertyName JSPropertyName; +typedef struct JSPropertySpec JSPropertySpec; +typedef struct JSRuntime JSRuntime; +typedef struct JSSecurityCallbacks JSSecurityCallbacks; +typedef struct JSStructuredCloneCallbacks JSStructuredCloneCallbacks; +typedef struct JSStructuredCloneReader JSStructuredCloneReader; +typedef struct JSStructuredCloneWriter JSStructuredCloneWriter; +typedef struct JSTracer JSTracer; + +#ifdef __cplusplus +class JSFlatString; +class JSFunction; +class JSObject; +class JSScript; +class JSStableString; // long story +class JSString; +#else +typedef struct JSFlatString JSFlatString; +typedef struct JSFunction JSFunction; +typedef struct JSObject JSObject; +typedef struct JSScript JSScript; +typedef struct JSString JSString; +#endif /* !__cplusplus */ + +#ifdef JS_THREADSAFE +typedef struct PRCallOnceType JSCallOnceType; +#else +typedef JSBool JSCallOnceType; +#endif +typedef JSBool (*JSInitCallback)(void); + +#ifdef __cplusplus + +namespace js { + +class Allocator; + +class SkipRoot; + +enum ThingRootKind +{ + THING_ROOT_OBJECT, + THING_ROOT_SHAPE, + THING_ROOT_BASE_SHAPE, + THING_ROOT_TYPE_OBJECT, + THING_ROOT_STRING, + THING_ROOT_ION_CODE, + THING_ROOT_SCRIPT, + THING_ROOT_ID, + THING_ROOT_PROPERTY_ID, + THING_ROOT_VALUE, + THING_ROOT_TYPE, + THING_ROOT_BINDINGS, + THING_ROOT_LIMIT +}; + +template +struct RootKind; + +/* + * Specifically mark the ThingRootKind of externally visible types, so that + * JSAPI users may use JSRooted... types without having the class definition + * available. + */ +template +struct SpecificRootKind +{ + static ThingRootKind rootKind() { return Kind; } +}; + +template <> struct RootKind : SpecificRootKind {}; +template <> struct RootKind : SpecificRootKind {}; +template <> struct RootKind : SpecificRootKind {}; +template <> struct RootKind : SpecificRootKind {}; +template <> struct RootKind : SpecificRootKind {}; +template <> struct RootKind : SpecificRootKind {}; + +struct ContextFriendFields { + JSRuntime *const runtime; + + /* The current compartment. */ + JSCompartment *compartment; + + /* The current zone. */ + JS::Zone *zone_; + + explicit ContextFriendFields(JSRuntime *rt) + : runtime(rt), compartment(NULL), zone_(NULL) + { } + + static const ContextFriendFields *get(const JSContext *cx) { + return reinterpret_cast(cx); + } + + static ContextFriendFields *get(JSContext *cx) { + return reinterpret_cast(cx); + } + +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + /* + * Stack allocated GC roots for stack GC heap pointers, which may be + * overwritten if moved during a GC. + */ + JS::Rooted *thingGCRooters[THING_ROOT_LIMIT]; +#endif + +#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) + /* + * Stack allocated list of stack locations which hold non-relocatable + * GC heap pointers (where the target is rooted somewhere else) or integer + * values which may be confused for GC heap pointers. These are used to + * suppress false positives which occur when a rooting analysis treats the + * location as holding a relocatable pointer, but have no other effect on + * GC behavior. + */ + SkipRoot *skipGCRooters; +#endif +}; + +struct RuntimeFriendFields { + /* + * If non-zero, we were been asked to call the operation callback as soon + * as possible. + */ + volatile int32_t interrupt; + + RuntimeFriendFields() + : interrupt(0) { } + + static const RuntimeFriendFields *get(const JSRuntime *rt) { + return reinterpret_cast(rt); + } +}; + +class PerThreadData; + +struct PerThreadDataFriendFields +{ + private: + // Note: this type only exists to permit us to derive the offset of + // the perThread data within the real JSRuntime* type in a portable + // way. + struct RuntimeDummy : RuntimeFriendFields + { + struct PerThreadDummy { + void *field1; + uintptr_t field2; +#ifdef DEBUG + uint64_t field3; +#endif + } mainThread; + }; + + public: + + PerThreadDataFriendFields(); + +#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) + /* + * Stack allocated GC roots for stack GC heap pointers, which may be + * overwritten if moved during a GC. + */ + JS::Rooted *thingGCRooters[THING_ROOT_LIMIT]; +#endif + +#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) + /* + * Stack allocated list of stack locations which hold non-relocatable + * GC heap pointers (where the target is rooted somewhere else) or integer + * values which may be confused for GC heap pointers. These are used to + * suppress false positives which occur when a rooting analysis treats the + * location as holding a relocatable pointer, but have no other effect on + * GC behavior. + */ + SkipRoot *skipGCRooters; +#endif + + /* Limit pointer for checking native stack consumption. */ + uintptr_t nativeStackLimit; + + static const size_t RuntimeMainThreadOffset = offsetof(RuntimeDummy, mainThread); + + static inline PerThreadDataFriendFields *get(js::PerThreadData *pt) { + return reinterpret_cast(pt); + } + + static inline PerThreadDataFriendFields *getMainThread(JSRuntime *rt) { + // mainThread must always appear directly after |RuntimeFriendFields|. + // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| + return reinterpret_cast( + reinterpret_cast(rt) + RuntimeMainThreadOffset); + } + + static inline const PerThreadDataFriendFields *getMainThread(const JSRuntime *rt) { + // mainThread must always appear directly after |RuntimeFriendFields|. + // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| + return reinterpret_cast( + reinterpret_cast(rt) + RuntimeMainThreadOffset); + } +}; + +} /* namespace js */ + +#endif /* __cplusplus */ + +#endif /* jspubtd_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jstypes.h b/scripting/javascript/spidermonkey-mac/include/jstypes.h new file mode 100644 index 0000000000..c83e7fed26 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jstypes.h @@ -0,0 +1,282 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** File: jstypes.h +** Description: Definitions of NSPR's basic types +** +** Prototypes and macros used to make up for deficiencies in ANSI environments +** that we have found. +** +** Since we do not wrap and all the other standard headers, authors +** of portable code will not know in general that they need these definitions. +** Instead of requiring these authors to find the dependent uses in their code +** and take the following steps only in those C files, we take steps once here +** for all C files. +**/ + +#ifndef jstypes_h___ +#define jstypes_h___ + +#include "mozilla/Attributes.h" +#include "mozilla/Util.h" + +#include "js-config.h" + +/*********************************************************************** +** MACROS: JS_EXTERN_API +** JS_EXPORT_API +** DESCRIPTION: +** These are only for externally visible routines and globals. For +** internal routines, just use "extern" for type checking and that +** will not export internal cross-file or forward-declared symbols. +** Define a macro for declaring procedures return types. We use this to +** deal with windoze specific type hackery for DLL definitions. Use +** JS_EXTERN_API when the prototype for the method is declared. Use +** JS_EXPORT_API for the implementation of the method. +** +** Example: +** in dowhim.h +** JS_EXTERN_API( void ) DoWhatIMean( void ); +** in dowhim.c +** JS_EXPORT_API( void ) DoWhatIMean( void ) { return; } +** +** +***********************************************************************/ + +#define JS_EXTERN_API(type) extern MOZ_EXPORT type +#define JS_EXPORT_API(type) MOZ_EXPORT type +#define JS_EXPORT_DATA(type) MOZ_EXPORT type +#define JS_IMPORT_API(type) MOZ_IMPORT_API type +#define JS_IMPORT_DATA(type) MOZ_IMPORT_DATA type + +/* + * The linkage of JS API functions differs depending on whether the file is + * used within the JS library or not. Any source file within the JS + * interpreter should define EXPORT_JS_API whereas any client of the library + * should not. STATIC_JS_API is used to build JS as a static library. + */ +#if defined(STATIC_JS_API) +# define JS_PUBLIC_API(t) t +# define JS_PUBLIC_DATA(t) t +#elif defined(EXPORT_JS_API) || defined(STATIC_EXPORTABLE_JS_API) +# define JS_PUBLIC_API(t) MOZ_EXPORT t +# define JS_PUBLIC_DATA(t) MOZ_EXPORT t +#else +# define JS_PUBLIC_API(t) MOZ_IMPORT_API t +# define JS_PUBLIC_DATA(t) MOZ_IMPORT_DATA t +#endif + +#define JS_FRIEND_API(t) JS_PUBLIC_API(t) +#define JS_FRIEND_DATA(t) JS_PUBLIC_DATA(t) + +#if defined(_MSC_VER) && defined(_M_IX86) +#define JS_FASTCALL __fastcall +#elif defined(__GNUC__) && defined(__i386__) +#define JS_FASTCALL __attribute__((fastcall)) +#else +#define JS_FASTCALL +#define JS_NO_FASTCALL +#endif + +#ifndef JS_INLINE +#define JS_INLINE MOZ_INLINE +#endif + +#ifndef JS_ALWAYS_INLINE +#define JS_ALWAYS_INLINE MOZ_ALWAYS_INLINE +#endif + +#ifndef JS_NEVER_INLINE +#define JS_NEVER_INLINE MOZ_NEVER_INLINE +#endif + +#ifndef JS_WARN_UNUSED_RESULT +# if defined __GNUC__ +# define JS_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +# else +# define JS_WARN_UNUSED_RESULT +# endif +#endif + +/*********************************************************************** +** MACROS: JS_BEGIN_MACRO +** JS_END_MACRO +** DESCRIPTION: +** Macro body brackets so that macros with compound statement definitions +** behave syntactically more like functions when called. +***********************************************************************/ +#define JS_BEGIN_MACRO do { + +#if defined(_MSC_VER) && _MSC_VER >= 1400 +# define JS_END_MACRO \ + } __pragma(warning(push)) __pragma(warning(disable:4127)) \ + while (0) __pragma(warning(pop)) +#else +# define JS_END_MACRO } while (0) +#endif + +/*********************************************************************** +** MACROS: JS_BEGIN_EXTERN_C +** JS_END_EXTERN_C +** DESCRIPTION: +** Macro shorthands for conditional C++ extern block delimiters. +***********************************************************************/ +#define JS_BEGIN_EXTERN_C MOZ_BEGIN_EXTERN_C +#define JS_END_EXTERN_C MOZ_END_EXTERN_C + +/*********************************************************************** +** MACROS: JS_BIT +** JS_BITMASK +** DESCRIPTION: +** Bit masking macros. XXX n must be <= 31 to be portable +***********************************************************************/ +#define JS_BIT(n) ((uint32_t)1 << (n)) +#define JS_BITMASK(n) (JS_BIT(n) - 1) + +/*********************************************************************** +** MACROS: JS_HOWMANY +** JS_ROUNDUP +** JS_MIN +** JS_MAX +** DESCRIPTION: +** Commonly used macros for operations on compatible types. +***********************************************************************/ +#define JS_HOWMANY(x,y) (((x)+(y)-1)/(y)) +#define JS_ROUNDUP(x,y) (JS_HOWMANY(x,y)*(y)) + +#include "jscpucfg.h" + +/* + * Define JS_64BIT iff we are building in an environment with 64-bit + * addresses. + */ +#ifdef _MSC_VER +# if defined(_M_X64) || defined(_M_AMD64) +# define JS_64BIT +# endif +#elif defined(__GNUC__) +/* Additional GCC defines are when running on Solaris, AIX, and HPUX */ +# if defined(__x86_64__) || defined(__sparcv9) || \ + defined(__64BIT__) || defined(__LP64__) +# define JS_64BIT +# endif +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Sun Studio C/C++ */ +# if defined(__x86_64) || defined(__sparcv9) +# define JS_64BIT +# endif +#elif defined(__xlc__) || defined(__xlC__) /* IBM XL C/C++ */ +# if defined(__64BIT__) +# define JS_64BIT +# endif +#elif defined(__HP_cc) || defined(__HP_aCC) /* HP-UX cc/aCC */ +# if defined(__LP64__) +# define JS_64BIT +# endif +#else +# error "Implement me" +#endif + + +/************************************************************************ +** TYPES: JSBool +** DESCRIPTION: +** Use JSBool for variables and parameter types. Use JS_FALSE and JS_TRUE +** for clarity of target type in assignments and actual arguments. Use +** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans +** just as you would C int-valued conditions. +************************************************************************/ +typedef int JSBool; +#define JS_TRUE (int)1 +#define JS_FALSE (int)0 + +/*********************************************************************** +** MACROS: JS_LIKELY +** JS_UNLIKELY +** DESCRIPTION: +** These macros allow you to give a hint to the compiler about branch +** probability so that it can better optimize. Use them like this: +** +** if (JS_LIKELY(v == 1)) { +** ... expected code path ... +** } +** +** if (JS_UNLIKELY(v == 0)) { +** ... non-expected code path ... +** } +** +***********************************************************************/ +#ifdef __GNUC__ + +# define JS_LIKELY(x) (__builtin_expect((x), 1)) +# define JS_UNLIKELY(x) (__builtin_expect((x), 0)) + +#else + +# define JS_LIKELY(x) (x) +# define JS_UNLIKELY(x) (x) + +#endif + +/*********************************************************************** +** MACROS: JS_ARRAY_LENGTH +** JS_ARRAY_END +** DESCRIPTION: +** Macros to get the number of elements and the pointer to one past the +** last element of a C array. Use them like this: +** +** jschar buf[10], *s; +** JSString *str; +** ... +** for (s = buf; s != JS_ARRAY_END(buf); ++s) *s = ...; +** ... +** str = JS_NewStringCopyN(cx, buf, JS_ARRAY_LENGTH(buf)); +** ... +** +***********************************************************************/ + +#define JS_ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0]) +#define JS_ARRAY_END(array) ((array) + JS_ARRAY_LENGTH(array)) + +#define JS_BITS_PER_BYTE 8 +#define JS_BITS_PER_BYTE_LOG2 3 + +#define JS_BITS_PER_WORD (JS_BITS_PER_BYTE * JS_BYTES_PER_WORD) +#define JS_BITS_PER_DOUBLE (JS_BITS_PER_BYTE * JS_BYTES_PER_DOUBLE) + +/*********************************************************************** +** MACROS: JS_FUNC_TO_DATA_PTR +** JS_DATA_TO_FUNC_PTR +** DESCRIPTION: +** Macros to convert between function and data pointers assuming that +** they have the same size. Use them like this: +** +** JSPropertyOp nativeGetter; +** JSObject *scriptedGetter; +** ... +** scriptedGetter = JS_FUNC_TO_DATA_PTR(JSObject *, nativeGetter); +** ... +** nativeGetter = JS_DATA_TO_FUNC_PTR(JSPropertyOp, scriptedGetter); +** +***********************************************************************/ + +#ifdef __GNUC__ +# define JS_FUNC_TO_DATA_PTR(type, fun) (__extension__ (type) (size_t) (fun)) +# define JS_DATA_TO_FUNC_PTR(type, ptr) (__extension__ (type) (size_t) (ptr)) +#else +/* Use an extra (void *) cast for MSVC. */ +# define JS_FUNC_TO_DATA_PTR(type, fun) ((type) (void *) (fun)) +# define JS_DATA_TO_FUNC_PTR(type, ptr) ((type) (void *) (ptr)) +#endif + +#ifdef __GNUC__ +# define JS_EXTENSION __extension__ +# define JS_EXTENSION_(s) __extension__ ({ s; }) +#else +# define JS_EXTENSION +# define JS_EXTENSION_(s) s +#endif + +#endif /* jstypes_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsutil.h b/scripting/javascript/spidermonkey-mac/include/jsutil.h new file mode 100644 index 0000000000..c5c19ffbf1 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsutil.h @@ -0,0 +1,471 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * PR assertion checker. + */ + +#ifndef jsutil_h___ +#define jsutil_h___ + +#include "mozilla/Attributes.h" +#include "mozilla/GuardObjects.h" + +#include "js/Utility.h" + +#ifdef USE_ZLIB +#include "zlib.h" +#endif + +/* Forward declarations. */ +struct JSContext; + +static JS_ALWAYS_INLINE void * +js_memcpy(void *dst_, const void *src_, size_t len) +{ + char *dst = (char *) dst_; + const char *src = (const char *) src_; + JS_ASSERT_IF(dst >= src, (size_t) (dst - src) >= len); + JS_ASSERT_IF(src >= dst, (size_t) (src - dst) >= len); + + return memcpy(dst, src, len); +} + +#ifdef __cplusplus +namespace js { + +template +struct AlignmentTestStruct +{ + char c; + T t; +}; + +/* This macro determines the alignment requirements of a type. */ +#define JS_ALIGNMENT_OF(t_) \ + (sizeof(js::AlignmentTestStruct) - sizeof(t_)) + +template +class AlignedPtrAndFlag +{ + uintptr_t bits; + + public: + AlignedPtrAndFlag(T *t, bool aFlag) { + JS_ASSERT((uintptr_t(t) & 1) == 0); + bits = uintptr_t(t) | uintptr_t(aFlag); + } + + T *ptr() const { + return (T *)(bits & ~uintptr_t(1)); + } + + bool flag() const { + return (bits & 1) != 0; + } + + void setPtr(T *t) { + JS_ASSERT((uintptr_t(t) & 1) == 0); + bits = uintptr_t(t) | uintptr_t(flag()); + } + + void setFlag() { + bits |= 1; + } + + void unsetFlag() { + bits &= ~uintptr_t(1); + } + + void set(T *t, bool aFlag) { + JS_ASSERT((uintptr_t(t) & 1) == 0); + bits = uintptr_t(t) | aFlag; + } +}; + +template +static inline void +Reverse(T *beg, T *end) +{ + while (beg != end) { + if (--end == beg) + return; + T tmp = *beg; + *beg = *end; + *end = tmp; + ++beg; + } +} + +template +static inline T * +Find(T *beg, T *end, const T &v) +{ + for (T *p = beg; p != end; ++p) { + if (*p == v) + return p; + } + return end; +} + +template +static inline typename Container::ElementType * +Find(Container &c, const typename Container::ElementType &v) +{ + return Find(c.begin(), c.end(), v); +} + +template +void +ForEach(InputIterT begin, InputIterT end, CallableT f) +{ + for (; begin != end; ++begin) + f(*begin); +} + +template +static inline T +Min(T t1, T t2) +{ + return t1 < t2 ? t1 : t2; +} + +template +static inline T +Max(T t1, T t2) +{ + return t1 > t2 ? t1 : t2; +} + +/* Allows a const variable to be initialized after its declaration. */ +template +static T& +InitConst(const T &t) +{ + return const_cast(t); +} + +template +JS_ALWAYS_INLINE T & +ImplicitCast(U &u) +{ + T &t = u; + return t; +} + +template +class AutoScopedAssign +{ + public: + AutoScopedAssign(T *addr, const T &value + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : addr_(addr), old(*addr_) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + *addr_ = value; + } + + ~AutoScopedAssign() { *addr_ = old; } + + private: + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER + T *addr_; + T old; +}; + +template +JS_ALWAYS_INLINE static void +PodZero(T *t) +{ + memset(t, 0, sizeof(T)); +} + +template +JS_ALWAYS_INLINE static void +PodZero(T *t, size_t nelem) +{ + /* + * This function is often called with 'nelem' small; we use an + * inline loop instead of calling 'memset' with a non-constant + * length. The compiler should inline the memset call with constant + * size, though. + */ + for (T *end = t + nelem; t != end; ++t) + memset(t, 0, sizeof(T)); +} + +/* + * Arrays implicitly convert to pointers to their first element, which is + * dangerous when combined with the above PodZero definitions. Adding an + * overload for arrays is ambiguous, so we need another identifier. The + * ambiguous overload is left to catch mistaken uses of PodZero; if you get a + * compile error involving PodZero and array types, use PodArrayZero instead. + */ +template static void PodZero(T (&)[N]); /* undefined */ +template static void PodZero(T (&)[N], size_t); /* undefined */ + +template +JS_ALWAYS_INLINE static void +PodArrayZero(T (&t)[N]) +{ + memset(t, 0, N * sizeof(T)); +} + +template +JS_ALWAYS_INLINE static void +PodAssign(T *dst, const T *src) +{ + js_memcpy((char *) dst, (const char *) src, sizeof(T)); +} + +template +JS_ALWAYS_INLINE static void +PodCopy(T *dst, const T *src, size_t nelem) +{ + /* Cannot find portable word-sized abs(). */ + JS_ASSERT_IF(dst >= src, size_t(dst - src) >= nelem); + JS_ASSERT_IF(src >= dst, size_t(src - dst) >= nelem); + + if (nelem < 128) { + /* + * Avoid using operator= in this loop, as it may have been + * intentionally deleted by the POD type. + */ + for (const T *srcend = src + nelem; src != srcend; ++src, ++dst) + PodAssign(dst, src); + } else { + memcpy(dst, src, nelem * sizeof(T)); + } +} + +template +JS_ALWAYS_INLINE static bool +PodEqual(T *one, T *two, size_t len) +{ + if (len < 128) { + T *p1end = one + len; + for (T *p1 = one, *p2 = two; p1 != p1end; ++p1, ++p2) { + if (*p1 != *p2) + return false; + } + return true; + } + + return !memcmp(one, two, len * sizeof(T)); +} + +template +static inline bool +IsPowerOfTwo(T t) +{ + return t && !(t & (t - 1)); +} + +template +static inline U +ComputeByteAlignment(T bytes, U alignment) +{ + JS_ASSERT(IsPowerOfTwo(alignment)); + return (alignment - (bytes % alignment)) % alignment; +} + +template +static inline T +AlignBytes(T bytes, U alignment) +{ + return bytes + ComputeByteAlignment(bytes, alignment); +} + +JS_ALWAYS_INLINE static size_t +UnsignedPtrDiff(const void *bigger, const void *smaller) +{ + return size_t(bigger) - size_t(smaller); +} + +/* + * Ordinarily, a function taking a JSContext* 'cx' parameter reports errors on + * the context. In some cases, functions optionally report and indicate this by + * taking a nullable 'maybecx' parameter. In some cases, though, a function + * always needs a 'cx', but optionally reports. This option is presented by the + * MaybeReportError. + */ +enum MaybeReportError { REPORT_ERROR = true, DONT_REPORT_ERROR = false }; + +/*****************************************************************************/ + +/* A bit array is an array of bits represented by an array of words (size_t). */ + +static inline unsigned +NumWordsForBitArrayOfLength(size_t length) +{ + return (length + (JS_BITS_PER_WORD - 1)) / JS_BITS_PER_WORD; +} + +static inline unsigned +BitArrayIndexToWordIndex(size_t length, size_t bitIndex) +{ + unsigned wordIndex = bitIndex / JS_BITS_PER_WORD; + JS_ASSERT(wordIndex < length); + return wordIndex; +} + +static inline size_t +BitArrayIndexToWordMask(size_t i) +{ + return size_t(1) << (i % JS_BITS_PER_WORD); +} + +static inline bool +IsBitArrayElementSet(size_t *array, size_t length, size_t i) +{ + return array[BitArrayIndexToWordIndex(length, i)] & BitArrayIndexToWordMask(i); +} + +static inline bool +IsAnyBitArrayElementSet(size_t *array, size_t length) +{ + unsigned numWords = NumWordsForBitArrayOfLength(length); + for (unsigned i = 0; i < numWords; ++i) { + if (array[i]) + return true; + } + return false; +} + +static inline void +SetBitArrayElement(size_t *array, size_t length, size_t i) +{ + array[BitArrayIndexToWordIndex(length, i)] |= BitArrayIndexToWordMask(i); +} + +static inline void +ClearBitArrayElement(size_t *array, size_t length, size_t i) +{ + array[BitArrayIndexToWordIndex(length, i)] &= ~BitArrayIndexToWordMask(i); +} + +static inline void +ClearAllBitArrayElements(size_t *array, size_t length) +{ + for (unsigned i = 0; i < length; ++i) + array[i] = 0; +} + +#ifdef USE_ZLIB +class Compressor +{ + /* Number of bytes we should hand to zlib each compressMore() call. */ + static const size_t CHUNKSIZE = 2048; + z_stream zs; + const unsigned char *inp; + size_t inplen; + size_t outbytes; + + public: + enum Status { + MOREOUTPUT, + DONE, + CONTINUE, + OOM + }; + + Compressor(const unsigned char *inp, size_t inplen); + ~Compressor(); + bool init(); + void setOutput(unsigned char *out, size_t outlen); + size_t outWritten() const { return outbytes; } + /* Compress some of the input. Return true if it should be called again. */ + Status compressMore(); +}; + +/* + * Decompress a string. The caller must know the length of the output and + * allocate |out| to a string of that length. + */ +bool DecompressString(const unsigned char *inp, size_t inplen, + unsigned char *out, size_t outlen); +#endif + +} /* namespace js */ +#endif /* __cplusplus */ + +/* Crash diagnostics */ +#ifdef DEBUG +# define JS_CRASH_DIAGNOSTICS 1 +#endif +#ifdef JS_CRASH_DIAGNOSTICS +# define JS_POISON(p, val, size) memset((p), (val), (size)) +#else +# define JS_POISON(p, val, size) ((void) 0) +#endif + +/* Basic stats */ +#ifdef DEBUG +# define JS_BASIC_STATS 1 +#endif +#ifdef JS_BASIC_STATS +# include +typedef struct JSBasicStats { + uint32_t num; + uint32_t max; + double sum; + double sqsum; + uint32_t logscale; /* logarithmic scale: 0 (linear), 2, 10 */ + uint32_t hist[11]; +} JSBasicStats; +# define JS_INIT_STATIC_BASIC_STATS {0,0,0,0,0,{0,0,0,0,0,0,0,0,0,0,0}} +# define JS_BASIC_STATS_INIT(bs) memset((bs), 0, sizeof(JSBasicStats)) +# define JS_BASIC_STATS_ACCUM(bs,val) \ + JS_BasicStatsAccum(bs, val) +# define JS_MeanAndStdDevBS(bs,sigma) \ + JS_MeanAndStdDev((bs)->num, (bs)->sum, (bs)->sqsum, sigma) +extern void +JS_BasicStatsAccum(JSBasicStats *bs, uint32_t val); +extern double +JS_MeanAndStdDev(uint32_t num, double sum, double sqsum, double *sigma); +extern void +JS_DumpBasicStats(JSBasicStats *bs, const char *title, FILE *fp); +extern void +JS_DumpHistogram(JSBasicStats *bs, FILE *fp); +#else +# define JS_BASIC_STATS_ACCUM(bs,val) +#endif + +/* A jsbitmap_t is a long integer that can be used for bitmaps. */ +typedef size_t jsbitmap; +#define JS_TEST_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] & \ + ((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1)))) +#define JS_SET_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] |= \ + ((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1)))) +#define JS_CLEAR_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] &= \ + ~((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1)))) + +/* Wrapper for various macros to stop warnings coming from their expansions. */ +#if defined(__clang__) +# define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ + JS_BEGIN_MACRO \ + _Pragma("clang diagnostic push") \ + /* If these _Pragmas cause warnings for you, try disabling ccache. */ \ + _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ + { expr; } \ + _Pragma("clang diagnostic pop") \ + JS_END_MACRO +#elif (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +# define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ + JS_BEGIN_MACRO \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wunused-but-set-variable\"") \ + expr; \ + _Pragma("GCC diagnostic pop") \ + JS_END_MACRO +#else +# define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ + JS_BEGIN_MACRO \ + expr; \ + JS_END_MACRO +#endif + +#endif /* jsutil_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jsversion.h b/scripting/javascript/spidermonkey-mac/include/jsversion.h new file mode 100644 index 0000000000..50e2fa6beb --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jsversion.h @@ -0,0 +1,181 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jsversion_h___ +#define jsversion_h___ + +/* + * JS configuration macros. + */ +#ifndef JS_VERSION +#define JS_VERSION 185 +#endif + +/* + * Compile-time JS version configuration. The JS version numbers lie on the + * number line like so: + * + * 1.0 1.1 1.2 1.3 1.4 ECMAv3 1.5 1.6 1.7 1.8 ECMAv5 + * ^ ^ + * | | + * basis for ECMAv1 close to ECMAv2 + * + * where ECMAv3 stands for ECMA-262 Edition 3, and ECMAv5 stands for Edition 5. + * See the runtime version enum JSVersion in jspubtd.h. Code in the engine can + * therefore count on version <= JSVERSION_1_4 to mean "before the Third + * Edition of ECMA-262" and version > JSVERSION_1_4 to mean "at or after the + * Third Edition". + * + * In the (likely?) event that SpiderMonkey grows to implement JavaScript 2.0, + * the version number to use would be near 200, or greater. + * + * The JS_VERSION_ECMA_3 version is the minimal configuration conforming to + * the ECMA-262 Edition 3 specification. Use it for minimal embeddings, where + * you're sure you don't need any of the extensions disabled in this version. + * In order to facilitate testing, JS_HAS_OBJ_PROTO_PROP is defined as part of + * the JS_VERSION_ECMA_3_TEST version. + * + * To keep things sane in the modern age, where we need exceptions in order to + * implement, e.g., iterators and generators, we are dropping support for all + * versions <= 1.4. + */ +#define JS_VERSION_ECMA_3 148 +#define JS_VERSION_ECMA_3_TEST 149 + +#if JS_VERSION == JS_VERSION_ECMA_3 || \ + JS_VERSION == JS_VERSION_ECMA_3_TEST + +#define JS_HAS_STR_HTML_HELPERS 0 /* has str.anchor, str.bold, etc. */ +#if JS_VERSION == JS_VERSION_ECMA_3_TEST +#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ +#else +#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */ +#endif +#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */ +#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */ +#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */ +#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */ +#define JS_HAS_CONST 0 /* has JS2 const as alternative var */ +#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statement */ +#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler */ +#define JS_HAS_FOR_EACH_IN 0 /* has for each (lhs in iterable) */ +#define JS_HAS_GENERATORS 0 /* has yield in generator function */ +#define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */ +#define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = ... */ +#define JS_HAS_GENERATOR_EXPRS 0 /* has (expr for (lhs in iterable)) */ +#define JS_HAS_EXPR_CLOSURES 0 /* has function (formals) listexpr */ + +#elif JS_VERSION < 150 + +#error "unsupported JS_VERSION" + +#elif JS_VERSION == 150 + +#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */ +#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ +#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ +#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ +#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ +#define JS_HAS_CONST 1 /* has JS2 const as alternative var */ +#define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ +#define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ +#define JS_HAS_FOR_EACH_IN 0 /* has for each (lhs in iterable) */ +#define JS_HAS_GENERATORS 0 /* has yield in generator function */ +#define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */ +#define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = ... */ +#define JS_HAS_GENERATOR_EXPRS 0 /* has (expr for (lhs in iterable)) */ +#define JS_HAS_EXPR_CLOSURES 0 /* has function (formals) listexpr */ + +#elif JS_VERSION == 160 + +#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */ +#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ +#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ +#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ +#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ +#define JS_HAS_CONST 1 /* has JS2 const as alternative var */ +#define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ +#define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ +#define JS_HAS_FOR_EACH_IN 1 /* has for each (lhs in iterable) */ +#define JS_HAS_GENERATORS 0 /* has yield in generator function */ +#define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */ +#define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = ... */ +#define JS_HAS_GENERATOR_EXPRS 0 /* has (expr for (lhs in iterable)) */ +#define JS_HAS_EXPR_CLOSURES 0 /* has function (formals) listexpr */ + +#elif JS_VERSION == 170 + +#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */ +#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ +#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ +#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ +#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ +#define JS_HAS_CONST 1 /* has JS2 const as alternative var */ +#define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ +#define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ +#define JS_HAS_FOR_EACH_IN 1 /* has for each (lhs in iterable) */ +#define JS_HAS_GENERATORS 1 /* has yield in generator function */ +#define JS_HAS_BLOCK_SCOPE 1 /* has block scope via let/arraycomp */ +#define JS_HAS_DESTRUCTURING 1 /* has [a,b] = ... or {p:a,q:b} = ... */ +#define JS_HAS_GENERATOR_EXPRS 0 /* has (expr for (lhs in iterable)) */ +#define JS_HAS_EXPR_CLOSURES 0 /* has function (formals) listexpr */ + +#elif 180 <= JS_VERSION && JS_VERSION <= 185 + +#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */ +#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ +#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ +#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ +#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ +#define JS_HAS_CONST 1 /* has JS2 const as alternative var */ +#define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ +#define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ +#define JS_HAS_FOR_EACH_IN 1 /* has for each (lhs in iterable) */ +#define JS_HAS_GENERATORS 1 /* has yield in generator function */ +#define JS_HAS_BLOCK_SCOPE 1 /* has block scope via let/arraycomp */ +#define JS_HAS_DESTRUCTURING 2 /* has [a,b] = ... or {p:a,q:b} = ... */ +#define JS_HAS_GENERATOR_EXPRS 1 /* has (expr for (lhs in iterable)) */ +#define JS_HAS_EXPR_CLOSURES 1 /* has function (formals) listexpr */ + +#else + +#error "unknown JS_VERSION" + +#endif + +/* Support for JS_NewGlobalObject. */ +#define JS_HAS_NEW_GLOBAL_OBJECT 1 + +/* Support for JS_MakeSystemObject. */ +#define JS_HAS_MAKE_SYSTEM_OBJECT 1 + +/* Feature-test macro for evolving destructuring support. */ +#define JS_HAS_DESTRUCTURING_SHORTHAND (JS_HAS_DESTRUCTURING == 2) + +/* + * Feature for Object.prototype.__{define,lookup}{G,S}etter__ legacy support; + * support likely to be made opt-in at some future time. + */ +#define OLD_GETTER_SETTER_METHODS 1 + +/* A kill-switch for bug 586842. Embedders shouldn't touch this! */ +#define USE_NEW_OBJECT_REPRESENTATION 0 + +#if USE_NEW_OBJECT_REPRESENTATION +# define NEW_OBJECT_REPRESENTATION_ONLY() ((void)0) +#else +# define NEW_OBJECT_REPRESENTATION_ONLY() \ + MOZ_NOT_REACHED("don't call this! to be used in the new object representation") +#endif + +/* ECMAScript Internationalization API isn't fully implemented yet. */ +#define ENABLE_INTL_API 0 + +#endif /* jsversion_h___ */ diff --git a/scripting/javascript/spidermonkey-mac/include/jswrapper.h b/scripting/javascript/spidermonkey-mac/include/jswrapper.h new file mode 100644 index 0000000000..6bc8b23213 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/jswrapper.h @@ -0,0 +1,300 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=4 sw=4 et tw=99: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jswrapper_h___ +#define jswrapper_h___ + +#include "mozilla/Attributes.h" + +#include "jsapi.h" +#include "jsproxy.h" + +namespace js { + +class DummyFrameGuard; + +/* + * A wrapper is a proxy with a target object to which it generally forwards + * operations, but may restrict access to certain operations or instrument + * the trap operations in various ways. A wrapper is distinct from a Direct Proxy + * Handler in the sense that it can be "unwrapped" in C++, exposing the underlying + * object (Direct Proxy Handlers have an underlying target object, but don't + * expect to expose this object via any kind of unwrapping operation). Callers + * should be careful to avoid unwrapping security wrappers in the wrong context. + */ +class JS_FRIEND_API(Wrapper) : public DirectProxyHandler +{ + unsigned mFlags; + bool mSafeToUnwrap; + + public: + using BaseProxyHandler::Action; + + enum Flags { + CROSS_COMPARTMENT = 1 << 0, + LAST_USED_FLAG = CROSS_COMPARTMENT + }; + + /* + * Wrappers can explicitly specify that they are unsafe to unwrap from a + * security perspective (as is the case for SecurityWrappers). If a wrapper + * is not safe to unwrap, operations requiring full access to the underlying + * object (via UnwrapObjectChecked) will throw. Otherwise, they will succeed. + */ + void setSafeToUnwrap(bool safe) { mSafeToUnwrap = safe; } + virtual bool isSafeToUnwrap() { return mSafeToUnwrap; } + + static JSObject *New(JSContext *cx, JSObject *obj, JSObject *proto, + JSObject *parent, Wrapper *handler); + + static JSObject *Renew(JSContext *cx, JSObject *existing, JSObject *obj, Wrapper *handler); + + static Wrapper *wrapperHandler(RawObject wrapper); + + static JSObject *wrappedObject(RawObject wrapper); + + unsigned flags() const { + return mFlags; + } + + explicit Wrapper(unsigned flags, bool hasPrototype = false); + + virtual ~Wrapper(); + + /* ES5 Harmony fundamental wrapper traps. */ + virtual bool defaultValue(JSContext *cx, HandleObject wrapper, JSType hint, + MutableHandleValue vp) MOZ_OVERRIDE; + + static Wrapper singleton; + static Wrapper singletonWithPrototype; + + static void *getWrapperFamily(); +}; + +/* Base class for all cross compartment wrapper handlers. */ +class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper +{ + public: + CrossCompartmentWrapper(unsigned flags, bool hasPrototype = false); + + virtual ~CrossCompartmentWrapper(); + + virtual bool finalizeInBackground(Value priv) MOZ_OVERRIDE; + + /* ES5 Harmony fundamental wrapper traps. */ + virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE; + virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, + PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE; + virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, + PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE; + virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id, + PropertyDescriptor *desc) MOZ_OVERRIDE; + virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper, + AutoIdVector &props) MOZ_OVERRIDE; + virtual bool delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE; + virtual bool enumerate(JSContext *cx, HandleObject wrapper, AutoIdVector &props) MOZ_OVERRIDE; + + /* ES5 Harmony derived wrapper traps. */ + virtual bool has(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE; + virtual bool hasOwn(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE; + virtual bool get(JSContext *cx, HandleObject wrapper, HandleObject receiver, + HandleId id, MutableHandleValue vp) MOZ_OVERRIDE; + virtual bool set(JSContext *cx, HandleObject wrapper, HandleObject receiver, + HandleId id, bool strict, MutableHandleValue vp) MOZ_OVERRIDE; + virtual bool keys(JSContext *cx, HandleObject wrapper, AutoIdVector &props) MOZ_OVERRIDE; + virtual bool iterate(JSContext *cx, HandleObject wrapper, unsigned flags, + MutableHandleValue vp) MOZ_OVERRIDE; + + /* Spidermonkey extensions. */ + virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE; + virtual bool call(JSContext *cx, HandleObject wrapper, unsigned argc, Value *vp) MOZ_OVERRIDE; + virtual bool construct(JSContext *cx, HandleObject wrapper, unsigned argc, Value *argv, + MutableHandleValue rval) MOZ_OVERRIDE; + virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, + CallArgs args) MOZ_OVERRIDE; + virtual bool hasInstance(JSContext *cx, HandleObject wrapper, MutableHandleValue v, + bool *bp) MOZ_OVERRIDE; + virtual JSString *obj_toString(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE; + virtual JSString *fun_toString(JSContext *cx, HandleObject wrapper, + unsigned indent) MOZ_OVERRIDE; + virtual bool regexp_toShared(JSContext *cx, HandleObject proxy, RegExpGuard *g) MOZ_OVERRIDE; + virtual bool defaultValue(JSContext *cx, HandleObject wrapper, JSType hint, + MutableHandleValue vp) MOZ_OVERRIDE; + virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop); + + static CrossCompartmentWrapper singleton; + static CrossCompartmentWrapper singletonWithPrototype; +}; + +/* + * Base class for security wrappers. A security wrapper is potentially hiding + * all or part of some wrapped object thus SecurityWrapper defaults to denying + * access to the wrappee. This is the opposite of Wrapper which tries to be + * completely transparent. + * + * NB: Currently, only a few ProxyHandler operations are overridden to deny + * access, relying on derived SecurityWrapper to block access when necessary. + */ +template +class JS_FRIEND_API(SecurityWrapper) : public Base +{ + public: + SecurityWrapper(unsigned flags); + + virtual bool isExtensible(JSObject *wrapper) MOZ_OVERRIDE; + virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE; + virtual bool enter(JSContext *cx, HandleObject wrapper, HandleId id, Wrapper::Action act, + bool *bp) MOZ_OVERRIDE; + virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, + CallArgs args) MOZ_OVERRIDE; + virtual bool objectClassIs(HandleObject obj, ESClassValue classValue, + JSContext *cx) MOZ_OVERRIDE; + virtual bool regexp_toShared(JSContext *cx, HandleObject proxy, RegExpGuard *g) MOZ_OVERRIDE; + virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id, + PropertyDescriptor *desc) MOZ_OVERRIDE; + + /* + * Allow our subclasses to select the superclass behavior they want without + * needing to specify an exact superclass. + */ + typedef Base Permissive; + typedef SecurityWrapper Restrictive; +}; + +typedef SecurityWrapper SameCompartmentSecurityWrapper; +typedef SecurityWrapper CrossCompartmentSecurityWrapper; + +class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler +{ + public: + static int sDeadObjectFamily; + + explicit DeadObjectProxy(); + + /* ES5 Harmony fundamental wrapper traps. */ + virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE; + virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, + PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE; + virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, + PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE; + virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id, + PropertyDescriptor *desc) MOZ_OVERRIDE; + virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper, + AutoIdVector &props) MOZ_OVERRIDE; + virtual bool delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE; + virtual bool enumerate(JSContext *cx, HandleObject wrapper, AutoIdVector &props) MOZ_OVERRIDE; + + /* Spidermonkey extensions. */ + virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE; + virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp); + virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc, + Value *argv, MutableHandleValue rval); + virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, + CallArgs args) MOZ_OVERRIDE; + virtual bool hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool *bp); + virtual bool objectClassIs(HandleObject obj, ESClassValue classValue, JSContext *cx); + virtual JSString *obj_toString(JSContext *cx, HandleObject proxy); + virtual JSString *fun_toString(JSContext *cx, HandleObject proxy, unsigned indent); + virtual bool regexp_toShared(JSContext *cx, HandleObject proxy, RegExpGuard *g); + virtual bool defaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp); + virtual bool getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, + uint32_t index, MutableHandleValue vp, bool *present); + virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop); + + static DeadObjectProxy singleton; +}; + +extern JSObject * +TransparentObjectWrapper(JSContext *cx, JSObject *existing, JSObject *obj, + JSObject *wrappedProto, JSObject *parent, + unsigned flags); + +// Proxy family for wrappers. Public so that IsWrapper() can be fully inlined by +// jsfriendapi users. +extern JS_FRIEND_DATA(int) sWrapperFamily; + +inline bool +IsWrapper(RawObject obj) +{ + return IsProxy(obj) && GetProxyHandler(obj)->family() == &sWrapperFamily; +} + +// Given a JSObject, returns that object stripped of wrappers. If +// stopAtOuter is true, then this returns the outer window if it was +// previously wrapped. Otherwise, this returns the first object for +// which JSObject::isWrapper returns false. +JS_FRIEND_API(JSObject *) +UnwrapObject(JSObject *obj, bool stopAtOuter = true, unsigned *flagsp = NULL); + +// Given a JSObject, returns that object stripped of wrappers. At each stage, +// the security wrapper has the opportunity to veto the unwrap. Since checked +// code should never be unwrapping outer window wrappers, we always stop at +// outer windows. +JS_FRIEND_API(JSObject *) +UnwrapObjectChecked(RawObject obj, bool stopAtOuter = true); + +// Unwrap only the outermost security wrapper, with the same semantics as +// above. This is the checked version of Wrapper::wrappedObject. +JS_FRIEND_API(JSObject *) +UnwrapOneChecked(RawObject obj, bool stopAtOuter = true); + +JS_FRIEND_API(bool) +IsCrossCompartmentWrapper(RawObject obj); + +bool +IsDeadProxyObject(RawObject obj); + +JSObject * +NewDeadProxyObject(JSContext *cx, JSObject *parent); + +void +NukeCrossCompartmentWrapper(JSContext *cx, JSObject *wrapper); + +bool +RemapWrapper(JSContext *cx, JSObject *wobj, JSObject *newTarget); + +JS_FRIEND_API(bool) +RemapAllWrappersForObject(JSContext *cx, JSObject *oldTarget, + JSObject *newTarget); + +// API to recompute all cross-compartment wrappers whose source and target +// match the given filters. +JS_FRIEND_API(bool) +RecomputeWrappers(JSContext *cx, const CompartmentFilter &sourceFilter, + const CompartmentFilter &targetFilter); + +/* + * This auto class should be used around any code, such as brain transplants, + * that may touch dead zones. Brain transplants can cause problems + * because they operate on all compartments, whether live or dead. A brain + * transplant can cause a formerly dead object to be "reanimated" by causing a + * read or write barrier to be invoked on it during the transplant. In this way, + * a zone becomes a zombie, kept alive by repeatedly consuming + * (transplanted) brains. + * + * To work around this issue, we observe when mark bits are set on objects in + * dead zones. If this happens during a brain transplant, we do a full, + * non-incremental GC at the end of the brain transplant. This will clean up any + * objects that were improperly marked. + */ +struct JS_FRIEND_API(AutoMaybeTouchDeadZones) +{ + // The version that takes an object just uses it for its runtime. + AutoMaybeTouchDeadZones(JSContext *cx); + AutoMaybeTouchDeadZones(JSObject *obj); + ~AutoMaybeTouchDeadZones(); + + private: + JSRuntime *runtime; + unsigned markCount; + bool inIncremental; + bool manipulatingDeadZones; +}; + +} /* namespace js */ + +#endif diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Assertions.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Assertions.h new file mode 100644 index 0000000000..8942ddd5b1 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Assertions.h @@ -0,0 +1,386 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Implementations of runtime and static assertion macros for C and C++. */ + +#ifndef mozilla_Assertions_h_ +#define mozilla_Assertions_h_ + +#include "mozilla/Attributes.h" +#include "mozilla/Compiler.h" + +#include +#include +#include +#ifdef WIN32 + /* + * TerminateProcess and GetCurrentProcess are defined in , which + * further depends on . We hardcode these few definitions manually + * because those headers clutter the global namespace with a significant + * number of undesired macros and symbols. + */ +# ifdef __cplusplus + extern "C" { +# endif + __declspec(dllimport) int __stdcall + TerminateProcess(void* hProcess, unsigned int uExitCode); + __declspec(dllimport) void* __stdcall GetCurrentProcess(void); +# ifdef __cplusplus + } +# endif +#else +# include +#endif +#ifdef ANDROID +# include +#endif + +/* + * MOZ_STATIC_ASSERT may be used to assert a condition *at compile time*. This + * can be useful when you make certain assumptions about what must hold for + * optimal, or even correct, behavior. For example, you might assert that the + * size of a struct is a multiple of the target architecture's word size: + * + * struct S { ... }; + * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, + * "S should be a multiple of word size for efficiency"); + * + * This macro can be used in any location where both an extern declaration and a + * typedef could be used. + * + * Be aware of the gcc 4.2 concerns noted further down when writing patches that + * use this macro, particularly if a patch only bounces on OS X. + */ +#ifdef __cplusplus +# if defined(__clang__) +# ifndef __has_extension +# define __has_extension __has_feature /* compatibility, for older versions of clang */ +# endif +# if __has_extension(cxx_static_assert) +# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) +# endif +# elif defined(__GNUC__) +# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) +# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) +# endif +# elif defined(_MSC_VER) +# if _MSC_VER >= 1600 /* MSVC 10 */ +# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) +# endif +# elif defined(__HP_aCC) +# if __HP_aCC >= 62500 && defined(_HP_CXX0x_SOURCE) +# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) +# endif +# endif +#endif +#ifndef MOZ_STATIC_ASSERT + /* + * Some of the definitions below create an otherwise-unused typedef. This + * triggers compiler warnings with some versions of gcc, so mark the typedefs + * as permissibly-unused to disable the warnings. + */ +# if defined(__GNUC__) +# define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) +# else +# define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE /* nothing */ +# endif +# define MOZ_STATIC_ASSERT_GLUE1(x, y) x##y +# define MOZ_STATIC_ASSERT_GLUE(x, y) MOZ_STATIC_ASSERT_GLUE1(x, y) +# if defined(__SUNPRO_CC) + /* + * The Sun Studio C++ compiler is buggy when declaring, inside a function, + * another extern'd function with an array argument whose length contains a + * sizeof, triggering the error message "sizeof expression not accepted as + * size of array parameter". This bug (6688515, not public yet) would hit + * defining moz_static_assert as a function, so we always define an extern + * array for Sun Studio. + * + * We include the line number in the symbol name in a best-effort attempt + * to avoid conflicts (see below). + */ +# define MOZ_STATIC_ASSERT(cond, reason) \ + extern char MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)[(cond) ? 1 : -1] +# elif defined(__COUNTER__) + /* + * If there was no preferred alternative, use a compiler-agnostic version. + * + * Note that the non-__COUNTER__ version has a bug in C++: it can't be used + * in both |extern "C"| and normal C++ in the same translation unit. (Alas + * |extern "C"| isn't allowed in a function.) The only affected compiler + * we really care about is gcc 4.2. For that compiler and others like it, + * we include the line number in the function name to do the best we can to + * avoid conflicts. These should be rare: a conflict would require use of + * MOZ_STATIC_ASSERT on the same line in separate files in the same + * translation unit, *and* the uses would have to be in code with + * different linkage, *and* the first observed use must be in C++-linkage + * code. + */ +# define MOZ_STATIC_ASSERT(cond, reason) \ + typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE +# else +# define MOZ_STATIC_ASSERT(cond, reason) \ + extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE +# endif +#endif + +#define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * MOZ_CRASH crashes the program, plain and simple, in a Breakpad-compatible + * way, in both debug and release builds. + * + * MOZ_CRASH is a good solution for "handling" failure cases when you're + * unwilling or unable to handle them more cleanly -- for OOM, for likely memory + * corruption, and so on. It's also a good solution if you need safe behavior + * in release builds as well as debug builds. But if the failure is one that + * should be debugged and fixed, MOZ_ASSERT is generally preferable. + */ +#if defined(_MSC_VER) + /* + * On MSVC use the __debugbreak compiler intrinsic, which produces an inline + * (not nested in a system function) breakpoint. This distinctively invokes + * Breakpad without requiring system library symbols on all stack-processing + * machines, as a nested breakpoint would require. We use TerminateProcess + * with the exit code aborting would generate because we don't want to invoke + * atexit handlers, destructors, library unload handlers, and so on when our + * process might be in a compromised state. We don't use abort() because + * it'd cause Windows to annoyingly pop up the process error dialog multiple + * times. See bug 345118 and bug 426163. + * + * (Technically these are Windows requirements, not MSVC requirements. But + * practically you need MSVC for debugging, and we only ship builds created + * by MSVC, so doing it this way reduces complexity.) + */ +# ifdef __cplusplus +# define MOZ_CRASH() \ + do { \ + __debugbreak(); \ + *((volatile int*) NULL) = 123; \ + ::TerminateProcess(::GetCurrentProcess(), 3); \ + } while (0) +# else +# define MOZ_CRASH() \ + do { \ + __debugbreak(); \ + *((volatile int*) NULL) = 123; \ + TerminateProcess(GetCurrentProcess(), 3); \ + } while (0) +# endif +#else +# ifdef __cplusplus +# define MOZ_CRASH() \ + do { \ + *((volatile int*) NULL) = 123; \ + ::abort(); \ + } while (0) +# else +# define MOZ_CRASH() \ + do { \ + *((volatile int*) NULL) = 123; \ + abort(); \ + } while (0) +# endif +#endif + +/* + * Prints |s| as an assertion failure (using file and ln as the location of the + * assertion) to the standard debug-output channel. + * + * Usually you should use MOZ_ASSERT instead of this method. This method is + * primarily for internal use in this header, and only secondarily for use in + * implementing release-build assertions. + */ +static MOZ_ALWAYS_INLINE void +MOZ_ReportAssertionFailure(const char* s, const char* file, int ln) +{ +#ifdef ANDROID + __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert", + "Assertion failure: %s, at %s:%d\n", s, file, ln); +#else + fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln); + fflush(stderr); +#endif +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* + * MOZ_ASSERT(expr [, explanation-string]) asserts that |expr| must be truthy in + * debug builds. If it is, execution continues. Otherwise, an error message + * including the expression and the explanation-string (if provided) is printed, + * an attempt is made to invoke any existing debugger, and execution halts. + * MOZ_ASSERT is fatal: no recovery is possible. Do not assert a condition + * which can correctly be falsy. + * + * The optional explanation-string, if provided, must be a string literal + * explaining the assertion. It is intended for use with assertions whose + * correctness or rationale is non-obvious, and for assertions where the "real" + * condition being tested is best described prosaically. Don't provide an + * explanation if it's not actually helpful. + * + * // No explanation needed: pointer arguments often must not be NULL. + * MOZ_ASSERT(arg); + * + * // An explanation can be helpful to explain exactly how we know an + * // assertion is valid. + * MOZ_ASSERT(state == WAITING_FOR_RESPONSE, + * "given that and , we must have..."); + * + * // Or it might disambiguate multiple identical (save for their location) + * // assertions of the same expression. + * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), + * "we already set [[PrimitiveThis]] for this Boolean object"); + * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), + * "we already set [[PrimitiveThis]] for this String object"); + * + * MOZ_ASSERT has no effect in non-debug builds. It is designed to catch bugs + * *only* during debugging, not "in the field". + */ +#ifdef DEBUG + /* First the single-argument form. */ +# define MOZ_ASSERT_HELPER1(expr) \ + do { \ + if (!(expr)) { \ + MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \ + MOZ_CRASH(); \ + } \ + } while (0) + /* Now the two-argument form. */ +# define MOZ_ASSERT_HELPER2(expr, explain) \ + do { \ + if (!(expr)) { \ + MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \ + MOZ_CRASH(); \ + } \ + } while (0) + /* And now, helper macrology up the wazoo. */ + /* + * Count the number of arguments passed to MOZ_ASSERT, very carefully + * tiptoeing around an MSVC bug where it improperly expands __VA_ARGS__ as a + * single token in argument lists. See these URLs for details: + * + * http://connect.microsoft.com/VisualStudio/feedback/details/380090/variadic-macro-replacement + * http://cplusplus.co.il/2010/07/17/variadic-macro-to-count-number-of-arguments/#comment-644 + */ +# define MOZ_COUNT_ASSERT_ARGS_IMPL2(_1, _2, count, ...) \ + count +# define MOZ_COUNT_ASSERT_ARGS_IMPL(args) \ + MOZ_COUNT_ASSERT_ARGS_IMPL2 args +# define MOZ_COUNT_ASSERT_ARGS(...) \ + MOZ_COUNT_ASSERT_ARGS_IMPL((__VA_ARGS__, 2, 1, 0)) + /* Pick the right helper macro to invoke. */ +# define MOZ_ASSERT_CHOOSE_HELPER2(count) MOZ_ASSERT_HELPER##count +# define MOZ_ASSERT_CHOOSE_HELPER1(count) MOZ_ASSERT_CHOOSE_HELPER2(count) +# define MOZ_ASSERT_CHOOSE_HELPER(count) MOZ_ASSERT_CHOOSE_HELPER1(count) + /* The actual macro. */ +# define MOZ_ASSERT_GLUE(x, y) x y +# define MOZ_ASSERT(...) \ + MOZ_ASSERT_GLUE(MOZ_ASSERT_CHOOSE_HELPER(MOZ_COUNT_ASSERT_ARGS(__VA_ARGS__)), \ + (__VA_ARGS__)) +#else +# define MOZ_ASSERT(...) do { } while(0) +#endif /* DEBUG */ + +/* + * MOZ_ASSERT_IF(cond1, cond2) is equivalent to MOZ_ASSERT(cond2) if cond1 is + * true. + * + * MOZ_ASSERT_IF(isPrime(num), num == 2 || isOdd(num)); + * + * As with MOZ_ASSERT, MOZ_ASSERT_IF has effect only in debug builds. It is + * designed to catch bugs during debugging, not "in the field". + */ +#ifdef DEBUG +# define MOZ_ASSERT_IF(cond, expr) \ + do { \ + if (cond) \ + MOZ_ASSERT(expr); \ + } while (0) +#else +# define MOZ_ASSERT_IF(cond, expr) do { } while (0) +#endif + +/* + * MOZ_NOT_REACHED_MARKER() expands to an expression which states that it is + * undefined behavior for execution to reach this point. No guarantees are made + * about what will happen if this is reached at runtime. Most code should + * probably use the higher level MOZ_NOT_REACHED, which uses this when + * appropriate. + */ +#if defined(__clang__) +# define MOZ_NOT_REACHED_MARKER() __builtin_unreachable() +#elif defined(__GNUC__) + /* + * __builtin_unreachable() was implemented in gcc 4.5. If we don't have + * that, call a noreturn function; abort() will do nicely. Qualify the call + * in C++ in case there's another abort() visible in local scope. + */ +# if MOZ_GCC_VERSION_AT_LEAST(4, 5, 0) +# define MOZ_NOT_REACHED_MARKER() __builtin_unreachable() +# else +# ifdef __cplusplus +# define MOZ_NOT_REACHED_MARKER() ::abort() +# else +# define MOZ_NOT_REACHED_MARKER() abort() +# endif +# endif +#elif defined(_MSC_VER) +# define MOZ_NOT_REACHED_MARKER() __assume(0) +#else +# ifdef __cplusplus +# define MOZ_NOT_REACHED_MARKER() ::abort() +# else +# define MOZ_NOT_REACHED_MARKER() abort() +# endif +#endif + +/* + * MOZ_NOT_REACHED(reason) indicates that the given point can't be reached + * during execution: simply reaching that point in execution is a bug. It takes + * as an argument an error message indicating the reason why that point should + * not have been reachable. + * + * // ...in a language parser... + * void handle(BooleanLiteralNode node) + * { + * if (node.isTrue()) + * handleTrueLiteral(); + * else if (node.isFalse()) + * handleFalseLiteral(); + * else + * MOZ_NOT_REACHED("boolean literal that's not true or false?"); + * } + */ +#if defined(DEBUG) +# define MOZ_NOT_REACHED(reason) \ + do { \ + MOZ_ASSERT(false, reason); \ + MOZ_NOT_REACHED_MARKER(); \ + } while (0) +#else +# define MOZ_NOT_REACHED(reason) MOZ_NOT_REACHED_MARKER() +#endif + +/* + * MOZ_ALWAYS_TRUE(expr) and MOZ_ALWAYS_FALSE(expr) always evaluate the provided + * expression, in debug builds and in release builds both. Then, in debug + * builds only, the value of the expression is asserted either true or false + * using MOZ_ASSERT. + */ +#ifdef DEBUG +# define MOZ_ALWAYS_TRUE(expr) MOZ_ASSERT((expr)) +# define MOZ_ALWAYS_FALSE(expr) MOZ_ASSERT(!(expr)) +#else +# define MOZ_ALWAYS_TRUE(expr) ((void)(expr)) +# define MOZ_ALWAYS_FALSE(expr) ((void)(expr)) +#endif + +#endif /* mozilla_Assertions_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Attributes.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Attributes.h new file mode 100644 index 0000000000..2f2d12e8e5 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Attributes.h @@ -0,0 +1,382 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Implementations of various class and method modifier attributes. */ + +#ifndef mozilla_Attributes_h_ +#define mozilla_Attributes_h_ + +#include "mozilla/Compiler.h" + +/* + * MOZ_INLINE is a macro which expands to tell the compiler that the method + * decorated with it should be inlined. This macro is usable from C and C++ + * code, even though C89 does not support the |inline| keyword. The compiler + * may ignore this directive if it chooses. + */ +#if defined(__cplusplus) +# define MOZ_INLINE inline +#elif defined(_MSC_VER) +# define MOZ_INLINE __inline +#elif defined(__GNUC__) +# define MOZ_INLINE __inline__ +#else +# define MOZ_INLINE inline +#endif + +/* + * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the + * method decorated with it must be inlined, even if the compiler thinks + * otherwise. This is only a (much) stronger version of the MOZ_INLINE hint: + * compilers are not guaranteed to respect it (although they're much more likely + * to do so). + */ +#if defined(_MSC_VER) +# define MOZ_ALWAYS_INLINE __forceinline +#elif defined(__GNUC__) +# define MOZ_ALWAYS_INLINE __attribute__((always_inline)) MOZ_INLINE +#else +# define MOZ_ALWAYS_INLINE MOZ_INLINE +#endif + +/* + * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality + * without warnings (functionality used by the macros below). These modes are + * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more + * standardly, by checking whether __cplusplus has a C++11 or greater value. + * Current versions of g++ do not correctly set __cplusplus, so we check both + * for forward compatibility. + */ +#if defined(__clang__) + /* + * Per Clang documentation, "Note that marketing version numbers should not + * be used to check for language features, as different vendors use different + * numbering schemes. Instead, use the feature checking macros." + */ +# ifndef __has_extension +# define __has_extension __has_feature /* compatibility, for older versions of clang */ +# endif +# if __has_extension(cxx_constexpr) +# define MOZ_HAVE_CXX11_CONSTEXPR +# endif +# if __has_extension(cxx_deleted_functions) +# define MOZ_HAVE_CXX11_DELETE +# endif +# if __has_extension(cxx_override_control) +# define MOZ_HAVE_CXX11_OVERRIDE +# define MOZ_HAVE_CXX11_FINAL final +# endif +# if __has_attribute(noinline) +# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) +# endif +# if __has_attribute(noreturn) +# define MOZ_HAVE_NORETURN __attribute__((noreturn)) +# endif +#elif defined(__GNUC__) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) +# define MOZ_HAVE_CXX11_OVERRIDE +# define MOZ_HAVE_CXX11_FINAL final +# endif +# if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) +# define MOZ_HAVE_CXX11_CONSTEXPR +# endif +# define MOZ_HAVE_CXX11_DELETE +# else + /* __final is a non-C++11 GCC synonym for 'final', per GCC r176655. */ +# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) +# define MOZ_HAVE_CXX11_FINAL __final +# endif +# endif +# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) +# define MOZ_HAVE_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +# if _MSC_VER >= 1700 +# define MOZ_HAVE_CXX11_FINAL final +# else + /* MSVC <= 10 used to spell "final" as "sealed". */ +# define MOZ_HAVE_CXX11_FINAL sealed +# endif +# define MOZ_HAVE_CXX11_OVERRIDE +# define MOZ_HAVE_NEVER_INLINE __declspec(noinline) +# define MOZ_HAVE_NORETURN __declspec(noreturn) +#endif + +/* + * The MOZ_CONSTEXPR specifier declares that a C++11 compiler can evaluate a + * function at compile time. A constexpr function cannot examine any values + * except its arguments and can have no side effects except its return value. + */ +#ifdef MOZ_HAVE_CXX11_CONSTEXPR +# define MOZ_CONSTEXPR constexpr +#else +# define MOZ_CONSTEXPR /* no support */ +#endif + +/* + * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the + * method decorated with it must never be inlined, even if the compiler would + * otherwise choose to inline the method. Compilers aren't absolutely + * guaranteed to support this, but most do. + */ +#if defined(MOZ_HAVE_NEVER_INLINE) +# define MOZ_NEVER_INLINE MOZ_HAVE_NEVER_INLINE +#else +# define MOZ_NEVER_INLINE /* no support */ +#endif + +/* + * MOZ_NORETURN, specified at the start of a function declaration, indicates + * that the given function does not return. (The function definition does not + * need to be annotated.) + * + * MOZ_NORETURN void abort(const char* msg); + * + * This modifier permits the compiler to optimize code assuming a call to such a + * function will never return. It also enables the compiler to avoid spurious + * warnings about not initializing variables, or about any other seemingly-dodgy + * operations performed after the function returns. + * + * This modifier does not affect the corresponding function's linking behavior. + */ +#if defined(MOZ_HAVE_NORETURN) +# define MOZ_NORETURN MOZ_HAVE_NORETURN +#else +# define MOZ_NORETURN /* no support */ +#endif + +/* + * MOZ_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time + * instrumentation shipped with Clang) to not instrument the annotated function. + * Furthermore, it will prevent the compiler from inlining the function because + * inlining currently breaks the blacklisting mechanism of AddressSanitizer. + */ +#if defined(MOZ_ASAN) +# define MOZ_ASAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_address_safety_analysis)) +# else +# define MOZ_ASAN_BLACKLIST +#endif + + +#ifdef __cplusplus + +/* + * MOZ_DELETE, specified immediately prior to the ';' terminating an undefined- + * method declaration, attempts to delete that method from the corresponding + * class. An attempt to use the method will always produce an error *at compile + * time* (instead of sometimes as late as link time) when this macro can be + * implemented. For example, you can use MOZ_DELETE to produce classes with no + * implicit copy constructor or assignment operator: + * + * struct NonCopyable + * { + * private: + * NonCopyable(const NonCopyable& other) MOZ_DELETE; + * void operator=(const NonCopyable& other) MOZ_DELETE; + * }; + * + * If MOZ_DELETE can't be implemented for the current compiler, use of the + * annotated method will still cause an error, but the error might occur at link + * time in some cases rather than at compile time. + * + * MOZ_DELETE relies on C++11 functionality not universally implemented. As a + * backstop, method declarations using MOZ_DELETE should be private. + */ +#if defined(MOZ_HAVE_CXX11_DELETE) +# define MOZ_DELETE = delete +#else +# define MOZ_DELETE /* no support */ +#endif + +/* + * MOZ_OVERRIDE explicitly indicates that a virtual member function in a class + * overrides a member function of a base class, rather than potentially being a + * new member function. MOZ_OVERRIDE should be placed immediately before the + * ';' terminating the member function's declaration, or before '= 0;' if the + * member function is pure. If the member function is defined in the class + * definition, it should appear before the opening brace of the function body. + * + * class Base + * { + * public: + * virtual void f() = 0; + * }; + * class Derived1 : public Base + * { + * public: + * virtual void f() MOZ_OVERRIDE; + * }; + * class Derived2 : public Base + * { + * public: + * virtual void f() MOZ_OVERRIDE = 0; + * }; + * class Derived3 : public Base + * { + * public: + * virtual void f() MOZ_OVERRIDE { } + * }; + * + * In compilers supporting C++11 override controls, MOZ_OVERRIDE *requires* that + * the function marked with it override a member function of a base class: it + * is a compile error if it does not. Otherwise MOZ_OVERRIDE does not affect + * semantics and merely documents the override relationship to the reader (but + * of course must still be used correctly to not break C++11 compilers). + */ +#if defined(MOZ_HAVE_CXX11_OVERRIDE) +# define MOZ_OVERRIDE override +#else +# define MOZ_OVERRIDE /* no support */ +#endif + +/* + * MOZ_FINAL indicates that some functionality cannot be overridden through + * inheritance. It can be used to annotate either classes/structs or virtual + * member functions. + * + * To annotate a class/struct with MOZ_FINAL, place MOZ_FINAL immediately after + * the name of the class, before the list of classes from which it derives (if + * any) and before its opening brace. MOZ_FINAL must not be used to annotate + * unnamed classes or structs. (With some compilers, and with C++11 proper, the + * underlying expansion is ambiguous with specifying a class name.) + * + * class Base MOZ_FINAL + * { + * public: + * Base(); + * ~Base(); + * virtual void f() { } + * }; + * // This will be an error in some compilers: + * class Derived : public Base + * { + * public: + * ~Derived() { } + * }; + * + * One particularly common reason to specify MOZ_FINAL upon a class is to tell + * the compiler that it's not dangerous for it to have a non-virtual destructor + * yet have one or more virtual functions, silencing the warning it might emit + * in this case. Suppose Base above weren't annotated with MOZ_FINAL. Because + * ~Base() is non-virtual, an attempt to delete a Derived* through a Base* + * wouldn't call ~Derived(), so any cleanup ~Derived() might do wouldn't happen. + * (Formally C++ says behavior is undefined, but compilers will likely just call + * ~Base() and not ~Derived().) Specifying MOZ_FINAL tells the compiler that + * it's safe for the destructor to be non-virtual. + * + * In compilers implementing final controls, it is an error to inherit from a + * class annotated with MOZ_FINAL. In other compilers it serves only as + * documentation. + * + * To annotate a virtual member function with MOZ_FINAL, place MOZ_FINAL + * immediately before the ';' terminating the member function's declaration, or + * before '= 0;' if the member function is pure. If the member function is + * defined in the class definition, it should appear before the opening brace of + * the function body. (This placement is identical to that for MOZ_OVERRIDE. + * If both are used, they should appear in the order 'MOZ_FINAL MOZ_OVERRIDE' + * for consistency.) + * + * class Base + * { + * public: + * virtual void f() MOZ_FINAL; + * }; + * class Derived + * { + * public: + * // This will be an error in some compilers: + * virtual void f(); + * }; + * + * In compilers implementing final controls, it is an error for a derived class + * to override a method annotated with MOZ_FINAL. In other compilers it serves + * only as documentation. + */ +#if defined(MOZ_HAVE_CXX11_FINAL) +# define MOZ_FINAL MOZ_HAVE_CXX11_FINAL +#else +# define MOZ_FINAL /* no support */ +#endif + +/** + * MOZ_WARN_UNUSED_RESULT tells the compiler to emit a warning if a function's + * return value is not used by the caller. + * + * Place this attribute at the very beginning of a function definition. For + * example, write + * + * MOZ_WARN_UNUSED_RESULT int foo(); + * + * or + * + * MOZ_WARN_UNUSED_RESULT int foo() { return 42; } + */ +#if defined(__GNUC__) || defined(__clang__) +# define MOZ_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) +#else +# define MOZ_WARN_UNUSED_RESULT +#endif + +/* + * The following macros are attributes that support the static analysis plugin + * included with Mozilla, and will be implemented (when such support is enabled) + * as C++11 attributes. Since such attributes are legal pretty much everywhere + * and have subtly different semantics depending on their placement, the + * following is a guide on where to place the attributes. + * + * Attributes that apply to a struct or class precede the name of the class: + * (Note that this is different from the placement of MOZ_FINAL for classes!) + * + * class MOZ_CLASS_ATTRIBUTE SomeClass {}; + * + * Attributes that apply to functions follow the parentheses and const + * qualifiers but precede MOZ_FINAL, MOZ_OVERRIDE and the function body: + * + * void DeclaredFunction() MOZ_FUNCTION_ATTRIBUTE; + * void SomeFunction() MOZ_FUNCTION_ATTRIBUTE {} + * void PureFunction() const MOZ_FUNCTION_ATTRIBUTE = 0; + * void OverriddenFunction() MOZ_FUNCTION_ATTIRBUTE MOZ_OVERRIDE; + * + * Attributes that apply to variables or parameters follow the variable's name: + * + * int variable MOZ_VARIABLE_ATTRIBUTE; + * + * Attributes that apply to types follow the type name: + * + * typedef int MOZ_TYPE_ATTRIBUTE MagicInt; + * int MOZ_TYPE_ATTRIBUTE someVariable; + * int * MOZ_TYPE_ATTRIBUTE magicPtrInt; + * int MOZ_TYPE_ATTRIBUTE * ptrToMagicInt; + * + * Attributes that apply to statements precede the statement: + * + * MOZ_IF_ATTRIBUTE if (x == 0) + * MOZ_DO_ATTRIBUTE do { } while(0); + * + * Attributes that apply to labels precede the label: + * + * MOZ_LABEL_ATTRIBUTE target: + * goto target; + * MOZ_CASE_ATTRIBUTE case 5: + * MOZ_DEFAULT_ATTRIBUTE default: + * + * The static analyses that are performed by the plugin are as follows: + * + * MOZ_MUST_OVERRIDE: Applies to all C++ member functions. All immediate + * subclasses must provide an exact override of this method; if a subclass + * does not override this method, the compiler will emit an error. This + * attribute is not limited to virtual methods, so if it is applied to a + * nonvirtual method and the subclass does not provide an equivalent + * definition, the compiler will emit an error. + */ +#ifdef MOZ_CLANG_PLUGIN +# define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) +#else +# define MOZ_MUST_OVERRIDE /* nothing */ +#endif /* MOZ_CLANG_PLUGIN */ + +#endif /* __cplusplus */ + +#endif /* mozilla_Attributes_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/BloomFilter.h b/scripting/javascript/spidermonkey-mac/include/mozilla/BloomFilter.h new file mode 100644 index 0000000000..8680ef2907 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/BloomFilter.h @@ -0,0 +1,234 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * A counting Bloom filter implementation. This allows consumers to + * do fast probabilistic "is item X in set Y?" testing which will + * never answer "no" when the correct answer is "yes" (but might + * incorrectly answer "yes" when the correct answer is "no"). + */ + +#ifndef mozilla_BloomFilter_h_ +#define mozilla_BloomFilter_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/Likely.h" +#include "mozilla/StandardInteger.h" +#include "mozilla/Util.h" + +#include + +namespace mozilla { + +/* + * This class implements a counting Bloom filter as described at + * , with + * 8-bit counters. This allows quick probabilistic answers to the + * question "is object X in set Y?" where the contents of Y might not + * be time-invariant. The probabilistic nature of the test means that + * sometimes the answer will be "yes" when it should be "no". If the + * answer is "no", then X is guaranteed not to be in Y. + * + * The filter is parametrized on KeySize, which is the size of the key + * generated by each of hash functions used by the filter, in bits, + * and the type of object T being added and removed. T must implement + * a |uint32_t hash() const| method which returns a uint32_t hash key + * that will be used to generate the two separate hash functions for + * the Bloom filter. This hash key MUST be well-distributed for good + * results! KeySize is not allowed to be larger than 16. + * + * The filter uses exactly 2**KeySize bytes of memory. From now on we + * will refer to the memory used by the filter as M. + * + * The expected rate of incorrect "yes" answers depends on M and on + * the number N of objects in set Y. As long as N is small compared + * to M, the rate of such answers is expected to be approximately + * 4*(N/M)**2 for this filter. In practice, if Y has a few hundred + * elements then using a KeySize of 12 gives a reasonably low + * incorrect answer rate. A KeySize of 12 has the additional benefit + * of using exactly one page for the filter in typical hardware + * configurations. + */ + +template +class BloomFilter +{ + /* + * A counting Bloom filter with 8-bit counters. For now we assume + * that having two hash functions is enough, but we may revisit that + * decision later. + * + * The filter uses an array with 2**KeySize entries. + * + * Assuming a well-distributed hash function, a Bloom filter with + * array size M containing N elements and + * using k hash function has expected false positive rate exactly + * + * $ (1 - (1 - 1/M)^{kN})^k $ + * + * because each array slot has a + * + * $ (1 - 1/M)^{kN} $ + * + * chance of being 0, and the expected false positive rate is the + * probability that all of the k hash functions will hit a nonzero + * slot. + * + * For reasonable assumptions (M large, kN large, which should both + * hold if we're worried about false positives) about M and kN this + * becomes approximately + * + * $$ (1 - \exp(-kN/M))^k $$ + * + * For our special case of k == 2, that's $(1 - \exp(-2N/M))^2$, + * or in other words + * + * $$ N/M = -0.5 * \ln(1 - \sqrt(r)) $$ + * + * where r is the false positive rate. This can be used to compute + * the desired KeySize for a given load N and false positive rate r. + * + * If N/M is assumed small, then the false positive rate can + * further be approximated as 4*N^2/M^2. So increasing KeySize by + * 1, which doubles M, reduces the false positive rate by about a + * factor of 4, and a false positive rate of 1% corresponds to + * about M/N == 20. + * + * What this means in practice is that for a few hundred keys using a + * KeySize of 12 gives false positive rates on the order of 0.25-4%. + * + * Similarly, using a KeySize of 10 would lead to a 4% false + * positive rate for N == 100 and to quite bad false positive + * rates for larger N. + */ + public: + BloomFilter() { + MOZ_STATIC_ASSERT(KeySize <= keyShift, "KeySize too big"); + + // Should we have a custom operator new using calloc instead and + // require that we're allocated via the operator? + clear(); + } + + /* + * Clear the filter. This should be done before reusing it, because + * just removing all items doesn't clear counters that hit the upper + * bound. + */ + void clear(); + + /* + * Add an item to the filter. + */ + void add(const T* t); + + /* + * Remove an item from the filter. + */ + void remove(const T* t); + + /* + * Check whether the filter might contain an item. This can + * sometimes return true even if the item is not in the filter, + * but will never return false for items that are actually in the + * filter. + */ + bool mightContain(const T* t) const; + + /* + * Methods for add/remove/contain when we already have a hash computed + */ + void add(uint32_t hash); + void remove(uint32_t hash); + bool mightContain(uint32_t hash) const; + + private: + static const size_t arraySize = (1 << KeySize); + static const uint32_t keyMask = (1 << KeySize) - 1; + static const uint32_t keyShift = 16; + + static uint32_t hash1(uint32_t hash) { return hash & keyMask; } + static uint32_t hash2(uint32_t hash) { return (hash >> keyShift) & keyMask; } + + uint8_t& firstSlot(uint32_t hash) { return counters[hash1(hash)]; } + uint8_t& secondSlot(uint32_t hash) { return counters[hash2(hash)]; } + const uint8_t& firstSlot(uint32_t hash) const { return counters[hash1(hash)]; } + const uint8_t& secondSlot(uint32_t hash) const { return counters[hash2(hash)]; } + + static bool full(const uint8_t& slot) { return slot == UINT8_MAX; } + + uint8_t counters[arraySize]; +}; + +template +inline void +BloomFilter::clear() +{ + memset(counters, 0, arraySize); +} + +template +inline void +BloomFilter::add(uint32_t hash) +{ + uint8_t& slot1 = firstSlot(hash); + if (MOZ_LIKELY(!full(slot1))) + ++slot1; + + uint8_t& slot2 = secondSlot(hash); + if (MOZ_LIKELY(!full(slot2))) + ++slot2; +} + +template +MOZ_ALWAYS_INLINE void +BloomFilter::add(const T* t) +{ + uint32_t hash = t->hash(); + return add(hash); +} + +template +inline void +BloomFilter::remove(uint32_t hash) +{ + // If the slots are full, we don't know whether we bumped them to be + // there when we added or not, so just leave them full. + uint8_t& slot1 = firstSlot(hash); + if (MOZ_LIKELY(!full(slot1))) + --slot1; + + uint8_t& slot2 = secondSlot(hash); + if (MOZ_LIKELY(!full(slot2))) + --slot2; +} + +template +MOZ_ALWAYS_INLINE void +BloomFilter::remove(const T* t) +{ + uint32_t hash = t->hash(); + remove(hash); +} + +template +MOZ_ALWAYS_INLINE bool +BloomFilter::mightContain(uint32_t hash) const +{ + // Check that all the slots for this hash contain something + return firstSlot(hash) && secondSlot(hash); +} + +template +MOZ_ALWAYS_INLINE bool +BloomFilter::mightContain(const T* t) const +{ + uint32_t hash = t->hash(); + return mightContain(hash); +} + +} // namespace mozilla + +#endif /* mozilla_BloomFilter_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Char16.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Char16.h new file mode 100644 index 0000000000..c6f9f87d44 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Char16.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Implements a UTF-16 character type. */ + +#ifndef mozilla_Char16_h_ +#define mozilla_Char16_h_ + +#include "mozilla/Assertions.h" + +/* + * C11 and C++11 introduce a char16_t type and support for UTF-16 string and + * character literals. C++11's char16_t is a distinct builtin type. C11's + * char16_t is a typedef for uint_least16_t. Technically, char16_t is a 16-bit + * code unit of a Unicode code point, not a "character". + * + * For now, Char16.h only supports C++ because we don't want mix different C + * and C++ definitions of char16_t in the same code base. + */ + +#ifdef _MSC_VER + /* + * C++11 says char16_t is a distinct builtin type, but Windows's yvals.h + * typedefs char16_t as an unsigned short. We would like to alias char16_t + * to Windows's 16-bit wchar_t so we can declare UTF-16 literals as constant + * expressions (and pass char16_t pointers to Windows APIs). We #define our + * char16_t as a macro to override yval.h's typedef of the same name. + */ +# define MOZ_UTF16_HELPER(s) L##s +# include +# define char16_t wchar_t +#elif defined(__cplusplus) && \ + (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) + /* C++11 has a builtin char16_t type. */ +# define MOZ_UTF16_HELPER(s) u##s +#else +# error "Char16.h requires C++11 (or something like it) for UTF-16 support." +#endif + +/* + * Macro arguments used in concatenation or stringification won't be expanded. + * Therefore, in order for |MOZ_UTF16(FOO)| to work as expected (which is to + * expand |FOO| before doing whatever |MOZ_UTF16| needs to do to it) a helper + * macro, |MOZ_UTF16_HELPER| needs to be inserted in between to allow the macro + * argument to expand. See "3.10.6 Separate Expansion of Macro Arguments" of the + * CPP manual for a more accurate and precise explanation. + */ +#define MOZ_UTF16(s) MOZ_UTF16_HELPER(s) + +MOZ_STATIC_ASSERT(sizeof(char16_t) == 2, "Is char16_t type 16 bits?"); +MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?"); +MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?"); + +#endif /* mozilla_Char16_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/CheckedInt.h b/scripting/javascript/spidermonkey-mac/include/mozilla/CheckedInt.h new file mode 100644 index 0000000000..1f35b9ec28 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/CheckedInt.h @@ -0,0 +1,806 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Provides checked integers, detecting integer overflow and divide-by-0. */ + +#ifndef mozilla_CheckedInt_h_ +#define mozilla_CheckedInt_h_ + +// Enable relying of Mozilla's MFBT for possibly-available C++11 features +#define MOZ_CHECKEDINT_USE_MFBT + +#ifdef MOZ_CHECKEDINT_USE_MFBT +# include "mozilla/Assertions.h" +# include "mozilla/StandardInteger.h" +#else +# include +# include +# define MOZ_STATIC_ASSERT(cond, reason) assert((cond) && reason) +# define MOZ_ASSERT(cond, reason) assert((cond) && reason) +# define MOZ_DELETE +#endif + +#include +#include + +namespace mozilla { + +template class CheckedInt; + +namespace detail { + +/* + * Step 1: manually record supported types + * + * What's nontrivial here is that there are different families of integer + * types: basic integer types and stdint types. It is merrily undefined which + * types from one family may be just typedefs for a type from another family. + * + * For example, on GCC 4.6, aside from the basic integer types, the only other + * type that isn't just a typedef for some of them, is int8_t. + */ + +struct UnsupportedType {}; + +template +struct IsSupportedPass2 +{ + static const bool value = false; +}; + +template +struct IsSupported +{ + static const bool value = IsSupportedPass2::value; +}; + +template<> +struct IsSupported +{ static const bool value = true; }; + +template<> +struct IsSupported +{ static const bool value = true; }; + +template<> +struct IsSupported +{ static const bool value = true; }; + +template<> +struct IsSupported +{ static const bool value = true; }; + +template<> +struct IsSupported +{ static const bool value = true; }; + +template<> +struct IsSupported +{ static const bool value = true; }; + +template<> +struct IsSupported +{ static const bool value = true; }; + +template<> +struct IsSupported +{ static const bool value = true; }; + + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + +template<> +struct IsSupportedPass2 +{ static const bool value = true; }; + + +/* + * Step 2: some integer-traits kind of stuff. + */ + +template +struct StdintTypeForSizeAndSignedness +{}; + +template<> +struct StdintTypeForSizeAndSignedness<1, true> +{ typedef int8_t Type; }; + +template<> +struct StdintTypeForSizeAndSignedness<1, false> +{ typedef uint8_t Type; }; + +template<> +struct StdintTypeForSizeAndSignedness<2, true> +{ typedef int16_t Type; }; + +template<> +struct StdintTypeForSizeAndSignedness<2, false> +{ typedef uint16_t Type; }; + +template<> +struct StdintTypeForSizeAndSignedness<4, true> +{ typedef int32_t Type; }; + +template<> +struct StdintTypeForSizeAndSignedness<4, false> +{ typedef uint32_t Type; }; + +template<> +struct StdintTypeForSizeAndSignedness<8, true> +{ typedef int64_t Type; }; + +template<> +struct StdintTypeForSizeAndSignedness<8, false> +{ typedef uint64_t Type; }; + +template +struct UnsignedType +{ + typedef typename StdintTypeForSizeAndSignedness::Type Type; +}; + +template +struct IsSigned +{ + static const bool value = IntegerType(-1) <= IntegerType(0); +}; + +template +struct TwiceBiggerType +{ + typedef typename StdintTypeForSizeAndSignedness< + sizeof(IntegerType) * 2, + IsSigned::value + >::Type Type; +}; + +template +struct TwiceBiggerType +{ + typedef UnsupportedType Type; +}; + +template +struct PositionOfSignBit +{ + static const size_t value = CHAR_BIT * sizeof(IntegerType) - 1; +}; + +template +struct MinValue +{ + private: + typedef typename UnsignedType::Type UnsignedIntegerType; + static const size_t PosOfSignBit = PositionOfSignBit::value; + + public: + // Bitwise ops may return a larger type, that's why we cast explicitly. + // In C++, left bit shifts on signed values is undefined by the standard + // unless the shifted value is representable. + // Notice that signed-to-unsigned conversions are always well-defined in + // the standard as the value congruent to 2**n, as expected. By contrast, + // unsigned-to-signed is only well-defined if the value is representable. + static const IntegerType value = + IsSigned::value + ? IntegerType(UnsignedIntegerType(1) << PosOfSignBit) + : IntegerType(0); +}; + +template +struct MaxValue +{ + // Tricksy, but covered by the unit test. + // Relies heavily on the type of MinValue::value + // being IntegerType. + static const IntegerType value = ~MinValue::value; +}; + +/* + * Step 3: Implement the actual validity checks. + * + * Ideas taken from IntegerLib, code different. + */ + +template +inline bool +HasSignBit(T x) +{ + // In C++, right bit shifts on negative values is undefined by the standard. + // Notice that signed-to-unsigned conversions are always well-defined in the + // standard, as the value congruent modulo 2**n as expected. By contrast, + // unsigned-to-signed is only well-defined if the value is representable. + return bool(typename UnsignedType::Type(x) + >> PositionOfSignBit::value); +} + +// Bitwise ops may return a larger type, so it's good to use this inline +// helper guaranteeing that the result is really of type T. +template +inline T +BinaryComplement(T x) +{ + return ~x; +} + +template::value, + bool IsUSigned = IsSigned::value> +struct DoesRangeContainRange +{ +}; + +template +struct DoesRangeContainRange +{ + static const bool value = sizeof(T) >= sizeof(U); +}; + +template +struct DoesRangeContainRange +{ + static const bool value = sizeof(T) > sizeof(U); +}; + +template +struct DoesRangeContainRange +{ + static const bool value = false; +}; + +template::value, + bool IsUSigned = IsSigned::value, + bool DoesTRangeContainURange = DoesRangeContainRange::value> +struct IsInRangeImpl {}; + +template +struct IsInRangeImpl +{ + static bool run(U) + { + return true; + } +}; + +template +struct IsInRangeImpl +{ + static bool run(U x) + { + return x <= MaxValue::value && x >= MinValue::value; + } +}; + +template +struct IsInRangeImpl +{ + static bool run(U x) + { + return x <= MaxValue::value; + } +}; + +template +struct IsInRangeImpl +{ + static bool run(U x) + { + return sizeof(T) > sizeof(U) || x <= U(MaxValue::value); + } +}; + +template +struct IsInRangeImpl +{ + static bool run(U x) + { + return sizeof(T) >= sizeof(U) + ? x >= 0 + : x >= 0 && x <= U(MaxValue::value); + } +}; + +template +inline bool +IsInRange(U x) +{ + return IsInRangeImpl::run(x); +} + +template +inline bool +IsAddValid(T x, T y) +{ + // Addition is valid if the sign of x+y is equal to either that of x or that + // of y. Since the value of x+y is undefined if we have a signed type, we + // compute it using the unsigned type of the same size. + // Beware! These bitwise operations can return a larger integer type, + // if T was a small type like int8_t, so we explicitly cast to T. + + typename UnsignedType::Type ux = x; + typename UnsignedType::Type uy = y; + typename UnsignedType::Type result = ux + uy; + return IsSigned::value + ? HasSignBit(BinaryComplement(T((result ^ x) & (result ^ y)))) + : BinaryComplement(x) >= y; +} + +template +inline bool +IsSubValid(T x, T y) +{ + // Subtraction is valid if either x and y have same sign, or x-y and x have + // same sign. Since the value of x-y is undefined if we have a signed type, + // we compute it using the unsigned type of the same size. + typename UnsignedType::Type ux = x; + typename UnsignedType::Type uy = y; + typename UnsignedType::Type result = ux - uy; + + return IsSigned::value + ? HasSignBit(BinaryComplement(T((result ^ x) & (x ^ y)))) + : x >= y; +} + +template::value, + bool TwiceBiggerTypeIsSupported = + IsSupported::Type>::value> +struct IsMulValidImpl {}; + +template +struct IsMulValidImpl +{ + static bool run(T x, T y) + { + typedef typename TwiceBiggerType::Type TwiceBiggerType; + TwiceBiggerType product = TwiceBiggerType(x) * TwiceBiggerType(y); + return IsInRange(product); + } +}; + +template +struct IsMulValidImpl +{ + static bool run(T x, T y) + { + const T max = MaxValue::value; + const T min = MinValue::value; + + if (x == 0 || y == 0) + return true; + + if (x > 0) { + return y > 0 + ? x <= max / y + : y >= min / x; + } + + // If we reach this point, we know that x < 0. + return y > 0 + ? x >= min / y + : y >= max / x; + } +}; + +template +struct IsMulValidImpl +{ + static bool run(T x, T y) + { + return y == 0 || x <= MaxValue::value / y; + } +}; + +template +inline bool +IsMulValid(T x, T y) +{ + return IsMulValidImpl::run(x, y); +} + +template +inline bool +IsDivValid(T x, T y) +{ + // Keep in mind that in the signed case, min/-1 is invalid because abs(min)>max. + return y != 0 && + !(IsSigned::value && x == MinValue::value && y == T(-1)); +} + +template::value> +struct NegateImpl; + +template +struct NegateImpl +{ + static CheckedInt negate(const CheckedInt& val) + { + // Handle negation separately for signed/unsigned, for simpler code and to + // avoid an MSVC warning negating an unsigned value. + return CheckedInt(0, val.isValid() && val.mValue == 0); + } +}; + +template +struct NegateImpl +{ + static CheckedInt negate(const CheckedInt& val) + { + // Watch out for the min-value, which (with twos-complement) can't be + // negated as -min-value is then (max-value + 1). + if (!val.isValid() || val.mValue == MinValue::value) + return CheckedInt(val.mValue, false); + return CheckedInt(-val.mValue, true); + } +}; + +} // namespace detail + + +/* + * Step 4: Now define the CheckedInt class. + */ + +/** + * @class CheckedInt + * @brief Integer wrapper class checking for integer overflow and other errors + * @param T the integer type to wrap. Can be any type among the following: + * - any basic integer type such as |int| + * - any stdint type such as |int8_t| + * + * This class implements guarded integer arithmetic. Do a computation, check + * that isValid() returns true, you then have a guarantee that no problem, such + * as integer overflow, happened during this computation, and you can call + * value() to get the plain integer value. + * + * The arithmetic operators in this class are guaranteed not to raise a signal + * (e.g. in case of a division by zero). + * + * For example, suppose that you want to implement a function that computes + * (x+y)/z, that doesn't crash if z==0, and that reports on error (divide by + * zero or integer overflow). You could code it as follows: + @code + bool computeXPlusYOverZ(int x, int y, int z, int *result) + { + CheckedInt checkedResult = (CheckedInt(x) + y) / z; + if (checkedResult.isValid()) { + *result = checkedResult.value(); + return true; + } else { + return false; + } + } + @endcode + * + * Implicit conversion from plain integers to checked integers is allowed. The + * plain integer is checked to be in range before being casted to the + * destination type. This means that the following lines all compile, and the + * resulting CheckedInts are correctly detected as valid or invalid: + * @code + // 1 is of type int, is found to be in range for uint8_t, x is valid + CheckedInt x(1); + // -1 is of type int, is found not to be in range for uint8_t, x is invalid + CheckedInt x(-1); + // -1 is of type int, is found to be in range for int8_t, x is valid + CheckedInt x(-1); + // 1000 is of type int16_t, is found not to be in range for int8_t, + // x is invalid + CheckedInt x(int16_t(1000)); + // 3123456789 is of type uint32_t, is found not to be in range for int32_t, + // x is invalid + CheckedInt x(uint32_t(3123456789)); + * @endcode + * Implicit conversion from + * checked integers to plain integers is not allowed. As shown in the + * above example, to get the value of a checked integer as a normal integer, + * call value(). + * + * Arithmetic operations between checked and plain integers is allowed; the + * result type is the type of the checked integer. + * + * Checked integers of different types cannot be used in the same arithmetic + * expression. + * + * There are convenience typedefs for all stdint types, of the following form + * (these are just 2 examples): + @code + typedef CheckedInt CheckedInt32; + typedef CheckedInt CheckedUint16; + @endcode + */ +template +class CheckedInt +{ + protected: + T mValue; + bool mIsValid; + + template + CheckedInt(U value, bool isValid) : mValue(value), mIsValid(isValid) + { + MOZ_STATIC_ASSERT(detail::IsSupported::value, + "This type is not supported by CheckedInt"); + } + + friend class detail::NegateImpl; + + public: + /** + * Constructs a checked integer with given @a value. The checked integer is + * initialized as valid or invalid depending on whether the @a value + * is in range. + * + * This constructor is not explicit. Instead, the type of its argument is a + * separate template parameter, ensuring that no conversion is performed + * before this constructor is actually called. As explained in the above + * documentation for class CheckedInt, this constructor checks that its + * argument is valid. + */ + template + CheckedInt(U value) + : mValue(T(value)), + mIsValid(detail::IsInRange(value)) + { + MOZ_STATIC_ASSERT(detail::IsSupported::value, + "This type is not supported by CheckedInt"); + } + + /** Constructs a valid checked integer with initial value 0 */ + CheckedInt() : mValue(0), mIsValid(true) + { + MOZ_STATIC_ASSERT(detail::IsSupported::value, + "This type is not supported by CheckedInt"); + } + + /** @returns the actual value */ + T value() const + { + MOZ_ASSERT(mIsValid, "Invalid checked integer (division by zero or integer overflow)"); + return mValue; + } + + /** + * @returns true if the checked integer is valid, i.e. is not the result + * of an invalid operation or of an operation involving an invalid checked + * integer + */ + bool isValid() const + { + return mIsValid; + } + + template + friend CheckedInt operator +(const CheckedInt& lhs, + const CheckedInt& rhs); + template + CheckedInt& operator +=(U rhs); + template + friend CheckedInt operator -(const CheckedInt& lhs, + const CheckedInt &rhs); + template + CheckedInt& operator -=(U rhs); + template + friend CheckedInt operator *(const CheckedInt& lhs, + const CheckedInt &rhs); + template + CheckedInt& operator *=(U rhs); + template + friend CheckedInt operator /(const CheckedInt& lhs, + const CheckedInt &rhs); + template + CheckedInt& operator /=(U rhs); + + CheckedInt operator -() const + { + return detail::NegateImpl::negate(*this); + } + + /** + * @returns true if the left and right hand sides are valid + * and have the same value. + * + * Note that these semantics are the reason why we don't offer + * a operator!=. Indeed, we'd want to have a!=b be equivalent to !(a==b) + * but that would mean that whenever a or b is invalid, a!=b + * is always true, which would be very confusing. + * + * For similar reasons, operators <, >, <=, >= would be very tricky to + * specify, so we just avoid offering them. + * + * Notice that these == semantics are made more reasonable by these facts: + * 1. a==b implies equality at the raw data level + * (the converse is false, as a==b is never true among invalids) + * 2. This is similar to the behavior of IEEE floats, where a==b + * means that a and b have the same value *and* neither is NaN. + */ + bool operator ==(const CheckedInt& other) const + { + return mIsValid && other.mIsValid && mValue == other.mValue; + } + + /** prefix ++ */ + CheckedInt& operator++() + { + *this += 1; + return *this; + } + + /** postfix ++ */ + CheckedInt operator++(int) + { + CheckedInt tmp = *this; + *this += 1; + return tmp; + } + + /** prefix -- */ + CheckedInt& operator--() + { + *this -= 1; + return *this; + } + + /** postfix -- */ + CheckedInt operator--(int) + { + CheckedInt tmp = *this; + *this -= 1; + return tmp; + } + + private: + /** + * The !=, <, <=, >, >= operators are disabled: + * see the comment on operator==. + */ + template + bool operator !=(U other) const MOZ_DELETE; + template + bool operator <(U other) const MOZ_DELETE; + template + bool operator <=(U other) const MOZ_DELETE; + template + bool operator >(U other) const MOZ_DELETE; + template + bool operator >=(U other) const MOZ_DELETE; +}; + +#define MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(NAME, OP) \ +template \ +inline CheckedInt operator OP(const CheckedInt &lhs, \ + const CheckedInt &rhs) \ +{ \ + if (!detail::Is##NAME##Valid(lhs.mValue, rhs.mValue)) \ + return CheckedInt(0, false); \ + \ + return CheckedInt(lhs.mValue OP rhs.mValue, \ + lhs.mIsValid && rhs.mIsValid); \ +} + +MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Add, +) +MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Sub, -) +MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mul, *) +MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Div, /) + +#undef MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR + +// Implement castToCheckedInt(x), making sure that +// - it allows x to be either a CheckedInt or any integer type +// that can be casted to T +// - if x is already a CheckedInt, we just return a reference to it, +// instead of copying it (optimization) + +namespace detail { + +template +struct CastToCheckedIntImpl +{ + typedef CheckedInt ReturnType; + static CheckedInt run(U u) { return u; } +}; + +template +struct CastToCheckedIntImpl > +{ + typedef const CheckedInt& ReturnType; + static const CheckedInt& run(const CheckedInt& u) { return u; } +}; + +} // namespace detail + +template +inline typename detail::CastToCheckedIntImpl::ReturnType +castToCheckedInt(U u) +{ + return detail::CastToCheckedIntImpl::run(u); +} + +#define MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(OP, COMPOUND_OP) \ +template \ +template \ +CheckedInt& CheckedInt::operator COMPOUND_OP(U rhs) \ +{ \ + *this = *this OP castToCheckedInt(rhs); \ + return *this; \ +} \ +template \ +inline CheckedInt operator OP(const CheckedInt &lhs, U rhs) \ +{ \ + return lhs OP castToCheckedInt(rhs); \ +} \ +template \ +inline CheckedInt operator OP(U lhs, const CheckedInt &rhs) \ +{ \ + return castToCheckedInt(lhs) OP rhs; \ +} + +MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(+, +=) +MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(*, *=) +MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(-, -=) +MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(/, /=) + +#undef MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS + +template +inline bool +operator ==(const CheckedInt &lhs, U rhs) +{ + return lhs == castToCheckedInt(rhs); +} + +template +inline bool +operator ==(U lhs, const CheckedInt &rhs) +{ + return castToCheckedInt(lhs) == rhs; +} + +// Convenience typedefs. +typedef CheckedInt CheckedInt8; +typedef CheckedInt CheckedUint8; +typedef CheckedInt CheckedInt16; +typedef CheckedInt CheckedUint16; +typedef CheckedInt CheckedInt32; +typedef CheckedInt CheckedUint32; +typedef CheckedInt CheckedInt64; +typedef CheckedInt CheckedUint64; + +} // namespace mozilla + +#endif /* mozilla_CheckedInt_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Compiler.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Compiler.h new file mode 100644 index 0000000000..e4f26f42fa --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Compiler.h @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Various compiler checks. */ + +#ifndef mozilla_Compiler_h_ +#define mozilla_Compiler_h_ + +#if !defined(__clang__) && defined(__GNUC__) + /* + * This macro should simplify gcc version checking. For example, to check + * for gcc 4.5.1 or later, check `#ifdef MOZ_GCC_VERSION_AT_LEAST(4, 5, 1)`. + */ +# define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel) \ + ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \ + >= ((major) * 10000 + (minor) * 100 + (patchlevel))) +#if !MOZ_GCC_VERSION_AT_LEAST(4, 4, 0) +# error "mfbt (and Gecko) require at least gcc 4.4 to build." +#endif +#endif + +#endif /* mozilla_Compiler_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Constants.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Constants.h new file mode 100644 index 0000000000..904b30145a --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Constants.h @@ -0,0 +1,15 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* mfbt math constants. */ + +#ifndef mozilla_Constants_h_ +#define mozilla_Constants_h_ + +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif + +#endif /* mozilla_Constants_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/DebugOnly.h b/scripting/javascript/spidermonkey-mac/include/mozilla/DebugOnly.h new file mode 100644 index 0000000000..1f78ed7989 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/DebugOnly.h @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Provides DebugOnly, a type for variables used only in debug builds (i.e. by + * assertions). + */ + +#ifndef mozilla_DebugOnly_h_ +#define mozilla_DebugOnly_h_ + +namespace mozilla { + +/** + * DebugOnly contains a value of type T, but only in debug builds. In release + * builds, it does not contain a value. This helper is intended to be used with + * MOZ_ASSERT()-style macros, allowing one to write: + * + * DebugOnly check = func(); + * MOZ_ASSERT(check); + * + * more concisely than declaring |check| conditional on #ifdef DEBUG, but also + * without allocating storage space for |check| in release builds. + * + * DebugOnly instances can only be coerced to T in debug builds. In release + * builds they don't have a value, so type coercion is not well defined. + */ +template +class DebugOnly +{ + public: +#ifdef DEBUG + T value; + + DebugOnly() { } + DebugOnly(const T& other) : value(other) { } + DebugOnly(const DebugOnly& other) : value(other.value) { } + DebugOnly& operator=(const T& rhs) { + value = rhs; + return *this; + } + void operator++(int) { + value++; + } + void operator--(int) { + value--; + } + + T* operator&() { return &value; } + + operator T&() { return value; } + operator const T&() const { return value; } + + T& operator->() { return value; } + +#else + DebugOnly() { } + DebugOnly(const T&) { } + DebugOnly(const DebugOnly&) { } + DebugOnly& operator=(const T&) { return *this; } + void operator++(int) { } + void operator--(int) { } +#endif + + /* + * DebugOnly must always have a destructor or else it will + * generate "unused variable" warnings, exactly what it's intended + * to avoid! + */ + ~DebugOnly() {} +}; + +} + +#endif /* mozilla_DebugOnly_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/EnumSet.h b/scripting/javascript/spidermonkey-mac/include/mozilla/EnumSet.h new file mode 100644 index 0000000000..b18b005669 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/EnumSet.h @@ -0,0 +1,175 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* A set abstraction for enumeration values. */ + +#ifndef mozilla_EnumSet_h +#define mozilla_EnumSet_h + +#include "mozilla/Assertions.h" +#include "mozilla/StandardInteger.h" + +namespace mozilla { + +/** + * EnumSet is a set of values defined by an enumeration. It is implemented + * using a 32 bit mask for each value so it will only work for enums with an int + * representation less than 32. It works both for enum and enum class types. + */ +template +class EnumSet +{ + public: + EnumSet() + : mBitField(0) + { } + + EnumSet(T aEnum) + : mBitField(aEnum) + { } + + EnumSet(T aEnum1, T aEnum2) + : mBitField(bitFor(aEnum1) | + bitFor(aEnum2)) + { } + + EnumSet(T aEnum1, T aEnum2, T aEnum3) + : mBitField(bitFor(aEnum1) | + bitFor(aEnum2) | + bitFor(aEnum3)) + { } + + EnumSet(T aEnum1, T aEnum2, T aEnum3, T aEnum4) + : mBitField(bitFor(aEnum1) | + bitFor(aEnum2) | + bitFor(aEnum3) | + bitFor(aEnum4)) + { } + + EnumSet(const EnumSet& aEnumSet) + : mBitField(aEnumSet.mBitField) + { } + + /** + * Add an element + */ + void operator+=(T aEnum) { + mBitField |= bitFor(aEnum); + } + + /** + * Add an element + */ + EnumSet operator+(T aEnum) const { + EnumSet result(*this); + result += aEnum; + return result; + } + + /** + * Union + */ + void operator+=(const EnumSet aEnumSet) { + mBitField |= aEnumSet.mBitField; + } + + /** + * Union + */ + EnumSet operator+(const EnumSet aEnumSet) const { + EnumSet result(*this); + result += aEnumSet; + return result; + } + + /** + * Remove an element + */ + void operator-=(T aEnum) { + mBitField &= ~(bitFor(aEnum)); + } + + /** + * Remove an element + */ + EnumSet operator-(T aEnum) const { + EnumSet result(*this); + result -= aEnum; + return result; + } + + /** + * Remove a set of elements + */ + void operator-=(const EnumSet aEnumSet) { + mBitField &= ~(aEnumSet.mBitField); + } + + /** + * Remove a set of elements + */ + EnumSet operator-(const EnumSet aEnumSet) const { + EnumSet result(*this); + result -= aEnumSet; + return result; + } + + /** + * Intersection + */ + void operator&=(const EnumSet aEnumSet) { + mBitField &= aEnumSet.mBitField; + } + + /** + * Intersection + */ + EnumSet operator&(const EnumSet aEnumSet) const { + EnumSet result(*this); + result &= aEnumSet; + return result; + } + + /** + * Equality + */ + + bool operator==(const EnumSet aEnumSet) const { + return mBitField == aEnumSet.mBitField; + } + + /** + * Test is an element is contained in the set + */ + bool contains(T aEnum) const { + return mBitField & bitFor(aEnum); + } + + /** + * Return the number of elements in the set + */ + + uint8_t size() { + uint8_t count = 0; + for (uint32_t bitField = mBitField; bitField; bitField >>= 1) { + if (bitField & 1) + count++; + } + return count; + } + + private: + static uint32_t bitFor(T aEnum) { + uint32_t bitNumber(aEnum); + MOZ_ASSERT(bitNumber < 32); + return 1U << bitNumber; + } + + uint32_t mBitField; +}; + +} // namespace mozilla + +#endif // mozilla_EnumSet_h_ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/FloatingPoint.h b/scripting/javascript/spidermonkey-mac/include/mozilla/FloatingPoint.h new file mode 100644 index 0000000000..cb1394e1a4 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/FloatingPoint.h @@ -0,0 +1,244 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Various predicates and operations on IEEE-754 floating point types. */ + +#ifndef mozilla_FloatingPoint_h_ +#define mozilla_FloatingPoint_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/StandardInteger.h" + +/* + * It's reasonable to ask why we have this header at all. Don't isnan, + * copysign, the built-in comparison operators, and the like solve these + * problems? Unfortunately, they don't. We've found that various compilers + * (MSVC, MSVC when compiling with PGO, and GCC on OS X, at least) miscompile + * the standard methods in various situations, so we can't use them. Some of + * these compilers even have problems compiling seemingly reasonable bitwise + * algorithms! But with some care we've found algorithms that seem to not + * trigger those compiler bugs. + * + * For the aforementioned reasons, be very wary of making changes to any of + * these algorithms. If you must make changes, keep a careful eye out for + * compiler bustage, particularly PGO-specific bustage. + * + * Some users require that this file be C-compatible. Unfortunately, this means + * no mozilla namespace to contain everything, no detail namespace clarifying + * MozDoublePun to be an internal data structure, and so on. + */ + +/* + * These implementations all assume |double| is a 64-bit double format number + * type, compatible with the IEEE-754 standard. C/C++ don't require this to be + * the case. But we required this in implementations of these algorithms that + * preceded this header, so we shouldn't break anything if we continue doing so. + */ +MOZ_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t), "double must be 64 bits"); + +/* + * Constant expressions in C can't refer to consts, unfortunately, so #define + * these rather than use |const uint64_t|. + */ +#define MOZ_DOUBLE_SIGN_BIT 0x8000000000000000ULL +#define MOZ_DOUBLE_EXPONENT_BITS 0x7ff0000000000000ULL +#define MOZ_DOUBLE_SIGNIFICAND_BITS 0x000fffffffffffffULL + +#define MOZ_DOUBLE_EXPONENT_BIAS 1023 +#define MOZ_DOUBLE_EXPONENT_SHIFT 52 + +MOZ_STATIC_ASSERT((MOZ_DOUBLE_SIGN_BIT & MOZ_DOUBLE_EXPONENT_BITS) == 0, + "sign bit doesn't overlap exponent bits"); +MOZ_STATIC_ASSERT((MOZ_DOUBLE_SIGN_BIT & MOZ_DOUBLE_SIGNIFICAND_BITS) == 0, + "sign bit doesn't overlap significand bits"); +MOZ_STATIC_ASSERT((MOZ_DOUBLE_EXPONENT_BITS & MOZ_DOUBLE_SIGNIFICAND_BITS) == 0, + "exponent bits don't overlap significand bits"); + +MOZ_STATIC_ASSERT((MOZ_DOUBLE_SIGN_BIT | MOZ_DOUBLE_EXPONENT_BITS | MOZ_DOUBLE_SIGNIFICAND_BITS) + == ~(uint64_t)0, + "all bits accounted for"); + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This union is NOT a public data structure, and it is not to be used outside + * this file! + */ +union MozDoublePun { + /* + * Every way to pun the bits of a double introduces an additional layer of + * complexity, across a multitude of platforms, architectures, and ABIs. + * Use *only* uint64_t to reduce complexity. Don't add new punning here + * without discussion! + */ + uint64_t u; + double d; +}; + +/** Determines whether a double is NaN. */ +static MOZ_ALWAYS_INLINE int +MOZ_DOUBLE_IS_NaN(double d) +{ + union MozDoublePun pun; + pun.d = d; + + /* + * A double is NaN if all exponent bits are 1 and the significand contains at + * least one non-zero bit. + */ + return (pun.u & MOZ_DOUBLE_EXPONENT_BITS) == MOZ_DOUBLE_EXPONENT_BITS && + (pun.u & MOZ_DOUBLE_SIGNIFICAND_BITS) != 0; +} + +/** Determines whether a double is +Infinity or -Infinity. */ +static MOZ_ALWAYS_INLINE int +MOZ_DOUBLE_IS_INFINITE(double d) +{ + union MozDoublePun pun; + pun.d = d; + + /* Infinities have all exponent bits set to 1 and an all-0 significand. */ + return (pun.u & ~MOZ_DOUBLE_SIGN_BIT) == MOZ_DOUBLE_EXPONENT_BITS; +} + +/** Determines whether a double is not NaN or infinite. */ +static MOZ_ALWAYS_INLINE int +MOZ_DOUBLE_IS_FINITE(double d) +{ + union MozDoublePun pun; + pun.d = d; + + /* + * NaN and Infinities are the only non-finite doubles, and both have all + * exponent bits set to 1. + */ + return (pun.u & MOZ_DOUBLE_EXPONENT_BITS) != MOZ_DOUBLE_EXPONENT_BITS; +} + +/** + * Determines whether a double is negative. It is an error to call this method + * on a double which is NaN. + */ +static MOZ_ALWAYS_INLINE int +MOZ_DOUBLE_IS_NEGATIVE(double d) +{ + union MozDoublePun pun; + pun.d = d; + + MOZ_ASSERT(!MOZ_DOUBLE_IS_NaN(d), "NaN does not have a sign"); + + /* The sign bit is set if the double is negative. */ + return (pun.u & MOZ_DOUBLE_SIGN_BIT) != 0; +} + +/** Determines whether a double represents -0. */ +static MOZ_ALWAYS_INLINE int +MOZ_DOUBLE_IS_NEGATIVE_ZERO(double d) +{ + union MozDoublePun pun; + pun.d = d; + + /* Only the sign bit is set if the double is -0. */ + return pun.u == MOZ_DOUBLE_SIGN_BIT; +} + +/** Returns the exponent portion of the double. */ +static MOZ_ALWAYS_INLINE int_fast16_t +MOZ_DOUBLE_EXPONENT(double d) +{ + union MozDoublePun pun; + pun.d = d; + + /* + * The exponent component of a double is an unsigned number, biased from its + * actual value. Subtract the bias to retrieve the actual exponent. + */ + return (int_fast16_t)((pun.u & MOZ_DOUBLE_EXPONENT_BITS) >> MOZ_DOUBLE_EXPONENT_SHIFT) - + MOZ_DOUBLE_EXPONENT_BIAS; +} + +/** Returns +Infinity. */ +static MOZ_ALWAYS_INLINE double +MOZ_DOUBLE_POSITIVE_INFINITY() +{ + union MozDoublePun pun; + + /* + * Positive infinity has all exponent bits set, sign bit set to 0, and no + * significand. + */ + pun.u = MOZ_DOUBLE_EXPONENT_BITS; + return pun.d; +} + +/** Returns -Infinity. */ +static MOZ_ALWAYS_INLINE double +MOZ_DOUBLE_NEGATIVE_INFINITY() +{ + union MozDoublePun pun; + + /* + * Negative infinity has all exponent bits set, sign bit set to 1, and no + * significand. + */ + pun.u = MOZ_DOUBLE_SIGN_BIT | MOZ_DOUBLE_EXPONENT_BITS; + return pun.d; +} + +/** Constructs a NaN value with the specified sign bit and significand bits. */ +static MOZ_ALWAYS_INLINE double +MOZ_DOUBLE_SPECIFIC_NaN(int signbit, uint64_t significand) +{ + union MozDoublePun pun; + + MOZ_ASSERT(signbit == 0 || signbit == 1); + MOZ_ASSERT((significand & ~MOZ_DOUBLE_SIGNIFICAND_BITS) == 0); + MOZ_ASSERT(significand & MOZ_DOUBLE_SIGNIFICAND_BITS); + + pun.u = (signbit ? MOZ_DOUBLE_SIGN_BIT : 0) | + MOZ_DOUBLE_EXPONENT_BITS | + significand; + MOZ_ASSERT(MOZ_DOUBLE_IS_NaN(pun.d)); + return pun.d; +} + +/** + * Computes a NaN value. Do not use this method if you depend upon a particular + * NaN value being returned. + */ +static MOZ_ALWAYS_INLINE double +MOZ_DOUBLE_NaN() +{ + return MOZ_DOUBLE_SPECIFIC_NaN(0, 0xfffffffffffffULL); +} + +/** Computes the smallest non-zero positive double value. */ +static MOZ_ALWAYS_INLINE double +MOZ_DOUBLE_MIN_VALUE() +{ + union MozDoublePun pun; + pun.u = 1; + return pun.d; +} + +static MOZ_ALWAYS_INLINE int +MOZ_DOUBLE_IS_INT32(double d, int32_t* i) +{ + /* + * XXX Casting a double that doesn't truncate to int32_t, to int32_t, induces + * undefined behavior. We should definitely fix this (bug 744965), but as + * apparently it "works" in practice, it's not a pressing concern now. + */ + return !MOZ_DOUBLE_IS_NEGATIVE_ZERO(d) && d == (*i = (int32_t)d); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* mozilla_FloatingPoint_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/GuardObjects.h b/scripting/javascript/spidermonkey-mac/include/mozilla/GuardObjects.h new file mode 100644 index 0000000000..6c2058938c --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/GuardObjects.h @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Implementation of macros to ensure correct use of RAII Auto* objects. */ + +#ifndef mozilla_GuardObjects_h +#define mozilla_GuardObjects_h + +#include "mozilla/Assertions.h" +#include "mozilla/Types.h" + +#ifdef __cplusplus + +#ifdef DEBUG + +namespace mozilla { +namespace detail { + +/* + * The following classes are designed to cause assertions to detect + * inadvertent use of guard objects as temporaries. In other words, + * when we have a guard object whose only purpose is its constructor and + * destructor (and is never otherwise referenced), the intended use + * might be: + * + * AutoRestore savePainting(mIsPainting); + * + * but is is easy to accidentally write: + * + * AutoRestore(mIsPainting); + * + * which compiles just fine, but runs the destructor well before the + * intended time. + * + * They work by adding (#ifdef DEBUG) an additional parameter to the + * guard object's constructor, with a default value, so that users of + * the guard object's API do not need to do anything. The default value + * of this parameter is a temporary object. C++ (ISO/IEC 14882:1998), + * section 12.2 [class.temporary], clauses 4 and 5 seem to assume a + * guarantee that temporaries are destroyed in the reverse of their + * construction order, but I actually can't find a statement that that + * is true in the general case (beyond the two specific cases mentioned + * there). However, it seems to be true. + * + * These classes are intended to be used only via the macros immediately + * below them: + * + * MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER declares (ifdef DEBUG) a member + * variable, and should be put where a declaration of a private + * member variable would be placed. + * MOZ_GUARD_OBJECT_NOTIFIER_PARAM should be placed at the end of the + * parameters to each constructor of the guard object; it declares + * (ifdef DEBUG) an additional parameter. (But use the *_ONLY_PARAM + * variant for constructors that take no other parameters.) + * MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL should likewise be used in + * the implementation of such constructors when they are not inline. + * MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT should be used in + * the implementation of such constructors to pass the parameter to + * a base class that also uses these macros + * MOZ_GUARD_OBJECT_NOTIFIER_INIT is a statement that belongs in each + * constructor. It uses the parameter declared by + * MOZ_GUARD_OBJECT_NOTIFIER_PARAM. + * + * For more details, and examples of using these macros, see + * https://developer.mozilla.org/en/Using_RAII_classes_in_Mozilla + */ +class MOZ_EXPORT GuardObjectNotifier +{ + private: + bool* statementDone; + + public: + GuardObjectNotifier() : statementDone(NULL) { } + + ~GuardObjectNotifier() { + *statementDone = true; + } + + void setStatementDone(bool* statementIsDone) { + statementDone = statementIsDone; + } +}; + +class MOZ_EXPORT GuardObjectNotificationReceiver +{ + private: + bool statementDone; + + public: + GuardObjectNotificationReceiver() : statementDone(false) { } + + ~GuardObjectNotificationReceiver() { + /* + * Assert that the guard object was not used as a temporary. (Note that + * this assert might also fire if init is not called because the guard + * object's implementation is not using the above macros correctly.) + */ + MOZ_ASSERT(statementDone); + } + + void init(const GuardObjectNotifier& constNotifier) { + /* + * constNotifier is passed as a const reference so that we can pass a + * temporary, but we really intend it as non-const. + */ + GuardObjectNotifier& notifier = const_cast(constNotifier); + notifier.setStatementDone(&statementDone); + } +}; + +} /* namespace detail */ +} /* namespace mozilla */ + +#endif /* DEBUG */ + +#ifdef DEBUG +# define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER \ + mozilla::detail::GuardObjectNotificationReceiver _mCheckNotUsedAsTemporary; +# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM \ + , const mozilla::detail::GuardObjectNotifier& _notifier = \ + mozilla::detail::GuardObjectNotifier() +# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM \ + const mozilla::detail::GuardObjectNotifier& _notifier = \ + mozilla::detail::GuardObjectNotifier() +# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL \ + , const mozilla::detail::GuardObjectNotifier& _notifier +# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL \ + const mozilla::detail::GuardObjectNotifier& _notifier +# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT \ + , _notifier +# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT \ + _notifier +# define MOZ_GUARD_OBJECT_NOTIFIER_INIT \ + do { _mCheckNotUsedAsTemporary.init(_notifier); } while (0) +#else +# define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER +# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM +# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM +# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL +# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL +# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT +# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT +# define MOZ_GUARD_OBJECT_NOTIFIER_INIT do { } while (0) +#endif + +#endif /* __cplusplus */ + +#endif /* mozilla_GuardObjects_h */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/HashFunctions.h b/scripting/javascript/spidermonkey-mac/include/mozilla/HashFunctions.h new file mode 100644 index 0000000000..96242b629a --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/HashFunctions.h @@ -0,0 +1,359 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Utilities for hashing. */ + +/* + * This file exports functions for hashing data down to a 32-bit value, + * including: + * + * - HashString Hash a char* or uint16_t/wchar_t* of known or unknown + * length. + * + * - HashBytes Hash a byte array of known length. + * + * - HashGeneric Hash one or more values. Currently, we support uint32_t, + * types which can be implicitly cast to uint32_t, data + * pointers, and function pointers. + * + * - AddToHash Add one or more values to the given hash. This supports the + * same list of types as HashGeneric. + * + * + * You can chain these functions together to hash complex objects. For example: + * + * class ComplexObject + * { + * char* str; + * uint32_t uint1, uint2; + * void (*callbackFn)(); + * + * public: + * uint32_t hash() { + * uint32_t hash = HashString(str); + * hash = AddToHash(hash, uint1, uint2); + * return AddToHash(hash, callbackFn); + * } + * }; + * + * If you want to hash an nsAString or nsACString, use the HashString functions + * in nsHashKey.h. + */ + +#ifndef mozilla_HashFunctions_h_ +#define mozilla_HashFunctions_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/StandardInteger.h" +#include "mozilla/Types.h" + +#ifdef __cplusplus +namespace mozilla { + +/** + * The golden ratio as a 32-bit fixed-point value. + */ +static const uint32_t GoldenRatioU32 = 0x9E3779B9U; + +inline uint32_t +RotateBitsLeft32(uint32_t value, uint8_t bits) +{ + MOZ_ASSERT(bits < 32); + return (value << bits) | (value >> (32 - bits)); +} + +namespace detail { + +inline uint32_t +AddU32ToHash(uint32_t hash, uint32_t value) +{ + /* + * This is the meat of all our hash routines. This hash function is not + * particularly sophisticated, but it seems to work well for our mostly + * plain-text inputs. Implementation notes follow. + * + * Our use of the golden ratio here is arbitrary; we could pick almost any + * number which: + * + * * is odd (because otherwise, all our hash values will be even) + * + * * has a reasonably-even mix of 1's and 0's (consider the extreme case + * where we multiply by 0x3 or 0xeffffff -- this will not produce good + * mixing across all bits of the hash). + * + * The rotation length of 5 is also arbitrary, although an odd number is again + * preferable so our hash explores the whole universe of possible rotations. + * + * Finally, we multiply by the golden ratio *after* xor'ing, not before. + * Otherwise, if |hash| is 0 (as it often is for the beginning of a message), + * the expression + * + * (GoldenRatioU32 * RotateBitsLeft(hash, 5)) |xor| value + * + * evaluates to |value|. + * + * (Number-theoretic aside: Because any odd number |m| is relatively prime to + * our modulus (2^32), the list + * + * [x * m (mod 2^32) for 0 <= x < 2^32] + * + * has no duplicate elements. This means that multiplying by |m| does not + * cause us to skip any possible hash values. + * + * It's also nice if |m| has large-ish order mod 2^32 -- that is, if the + * smallest k such that m^k == 1 (mod 2^32) is large -- so we can safely + * multiply our hash value by |m| a few times without negating the + * multiplicative effect. Our golden ratio constant has order 2^29, which is + * more than enough for our purposes.) + */ + return GoldenRatioU32 * (RotateBitsLeft32(hash, 5) ^ value); +} + +/** + * AddUintptrToHash takes sizeof(uintptr_t) as a template parameter. + */ +template +inline uint32_t +AddUintptrToHash(uint32_t hash, uintptr_t value); + +template<> +inline uint32_t +AddUintptrToHash<4>(uint32_t hash, uintptr_t value) +{ + return AddU32ToHash(hash, static_cast(value)); +} + +template<> +inline uint32_t +AddUintptrToHash<8>(uint32_t hash, uintptr_t value) +{ + /* + * The static cast to uint64_t below is necessary because this function + * sometimes gets compiled on 32-bit platforms (yes, even though it's a + * template and we never call this particular override in a 32-bit build). If + * we do value >> 32 on a 32-bit machine, we're shifting a 32-bit uintptr_t + * right 32 bits, and the compiler throws an error. + */ + uint32_t v1 = static_cast(value); + uint32_t v2 = static_cast(static_cast(value) >> 32); + return AddU32ToHash(AddU32ToHash(hash, v1), v2); +} + +} /* namespace detail */ + +/** + * AddToHash takes a hash and some values and returns a new hash based on the + * inputs. + * + * Currently, we support hashing uint32_t's, values which we can implicitly + * convert to uint32_t, data pointers, and function pointers. + */ +template +MOZ_WARN_UNUSED_RESULT +inline uint32_t +AddToHash(uint32_t hash, A a) +{ + /* + * Try to convert |A| to uint32_t implicitly. If this works, great. If not, + * we'll error out. + */ + return detail::AddU32ToHash(hash, a); +} + +template +MOZ_WARN_UNUSED_RESULT +inline uint32_t +AddToHash(uint32_t hash, A* a) +{ + /* + * You might think this function should just take a void*. But then we'd only + * catch data pointers and couldn't handle function pointers. + */ + + MOZ_STATIC_ASSERT(sizeof(a) == sizeof(uintptr_t), + "Strange pointer!"); + + return detail::AddUintptrToHash(hash, uintptr_t(a)); +} + +template<> +MOZ_WARN_UNUSED_RESULT +inline uint32_t +AddToHash(uint32_t hash, uintptr_t a) +{ + return detail::AddUintptrToHash(hash, a); +} + +template +MOZ_WARN_UNUSED_RESULT +uint32_t +AddToHash(uint32_t hash, A a, B b) +{ + return AddToHash(AddToHash(hash, a), b); +} + +template +MOZ_WARN_UNUSED_RESULT +uint32_t +AddToHash(uint32_t hash, A a, B b, C c) +{ + return AddToHash(AddToHash(hash, a, b), c); +} + +template +MOZ_WARN_UNUSED_RESULT +uint32_t +AddToHash(uint32_t hash, A a, B b, C c, D d) +{ + return AddToHash(AddToHash(hash, a, b, c), d); +} + +template +MOZ_WARN_UNUSED_RESULT +uint32_t +AddToHash(uint32_t hash, A a, B b, C c, D d, E e) +{ + return AddToHash(AddToHash(hash, a, b, c, d), e); +} + +/** + * The HashGeneric class of functions let you hash one or more values. + * + * If you want to hash together two values x and y, calling HashGeneric(x, y) is + * much better than calling AddToHash(x, y), because AddToHash(x, y) assumes + * that x has already been hashed. + */ +template +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashGeneric(A a) +{ + return AddToHash(0, a); +} + +template +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashGeneric(A a, B b) +{ + return AddToHash(0, a, b); +} + +template +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashGeneric(A a, B b, C c) +{ + return AddToHash(0, a, b, c); +} + +template +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashGeneric(A a, B b, C c, D d) +{ + return AddToHash(0, a, b, c, d); +} + +template +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashGeneric(A a, B b, C c, D d, E e) +{ + return AddToHash(0, a, b, c, d, e); +} + +namespace detail { + +template +uint32_t +HashUntilZero(const T* str) +{ + uint32_t hash = 0; + for (T c; (c = *str); str++) + hash = AddToHash(hash, c); + return hash; +} + +template +uint32_t +HashKnownLength(const T* str, size_t length) +{ + uint32_t hash = 0; + for (size_t i = 0; i < length; i++) + hash = AddToHash(hash, str[i]); + return hash; +} + +} /* namespace detail */ + +/** + * The HashString overloads below do just what you'd expect. + * + * If you have the string's length, you might as well call the overload which + * includes the length. It may be marginally faster. + */ +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashString(const char* str) +{ + return detail::HashUntilZero(str); +} + +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashString(const char* str, size_t length) +{ + return detail::HashKnownLength(str, length); +} + +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashString(const uint16_t* str) +{ + return detail::HashUntilZero(str); +} + +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashString(const uint16_t* str, size_t length) +{ + return detail::HashKnownLength(str, length); +} + +/* + * On Windows, wchar_t (PRUnichar) is not the same as uint16_t, even though it's + * the same width! + */ +#ifdef WIN32 +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashString(const wchar_t* str) +{ + return detail::HashUntilZero(str); +} + +MOZ_WARN_UNUSED_RESULT +inline uint32_t +HashString(const wchar_t* str, size_t length) +{ + return detail::HashKnownLength(str, length); +} +#endif + +/** + * Hash some number of bytes. + * + * This hash walks word-by-word, rather than byte-by-byte, so you won't get the + * same result out of HashBytes as you would out of HashString. + */ +MOZ_WARN_UNUSED_RESULT +extern MFBT_API uint32_t +HashBytes(const void* bytes, size_t length); + +} /* namespace mozilla */ +#endif /* __cplusplus */ +#endif /* mozilla_HashFunctions_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Likely.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Likely.h new file mode 100644 index 0000000000..6412b4943b --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Likely.h @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * MOZ_LIKELY and MOZ_UNLIKELY macros to hint to the compiler how a + * boolean predicate should be branch-predicted. + */ + +#ifndef mozilla_Likely_h_ +#define mozilla_Likely_h_ + +#if defined(__clang__) || defined(__GNUC__) +# define MOZ_LIKELY(x) (__builtin_expect(!!(x), 1)) +# define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0)) +#else +# define MOZ_LIKELY(x) (!!(x)) +# define MOZ_UNLIKELY(x) (!!(x)) +#endif + +#endif /* mozilla_Likely_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/LinkedList.h b/scripting/javascript/spidermonkey-mac/include/mozilla/LinkedList.h new file mode 100644 index 0000000000..5cfd60e4ac --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/LinkedList.h @@ -0,0 +1,429 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* A type-safe doubly-linked list class. */ + +/* + * The classes LinkedList and LinkedListElement together form a + * convenient, type-safe doubly-linked list implementation. + * + * The class T which will be inserted into the linked list must inherit from + * LinkedListElement. A given object may be in only one linked list at a + * time. + * + * A LinkedListElement automatically removes itself from the list upon + * destruction, and a LinkedList will fatally assert in debug builds if it's + * non-empty when it's destructed. + * + * For example, you might use LinkedList in a simple observer list class as + * follows. + * + * class Observer : public LinkedListElement + * { + * public: + * void observe(char* topic) { ... } + * }; + * + * class ObserverContainer + * { + * private: + * LinkedList list; + * + * public: + * void addObserver(Observer* observer) { + * // Will assert if |observer| is part of another list. + * list.insertBack(observer); + * } + * + * void removeObserver(Observer* observer) { + * // Will assert if |observer| is not part of some list. + * observer.remove(); + * // Or, will assert if |observer| is not part of |list| specifically. + * // observer.removeFrom(list); + * } + * + * void notifyObservers(char* topic) { + * for (Observer* o = list.getFirst(); o != NULL; o = o->getNext()) + * o->Observe(topic); + * } + * }; + * + */ + +#ifndef mozilla_LinkedList_h_ +#define mozilla_LinkedList_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" + +#ifdef __cplusplus + +namespace mozilla { + +template +class LinkedList; + +template +class LinkedListElement +{ + /* + * It's convenient that we return NULL when getNext() or getPrevious() hits + * the end of the list, but doing so costs an extra word of storage in each + * linked list node (to keep track of whether |this| is the sentinel node) + * and a branch on this value in getNext/getPrevious. + * + * We could get rid of the extra word of storage by shoving the "is + * sentinel" bit into one of the pointers, although this would, of course, + * have performance implications of its own. + * + * But the goal here isn't to win an award for the fastest or slimmest + * linked list; rather, we want a *convenient* linked list. So we won't + * waste time guessing which micro-optimization strategy is best. + * + * + * Speaking of unnecessary work, it's worth addressing here why we wrote + * mozilla::LinkedList in the first place, instead of using stl::list. + * + * The key difference between mozilla::LinkedList and stl::list is that + * mozilla::LinkedList stores the prev/next pointers in the object itself, + * while stl::list stores the prev/next pointers in a list element which + * itself points to the object being stored. + * + * mozilla::LinkedList's approach makes it harder to store an object in more + * than one list. But the upside is that you can call next() / prev() / + * remove() directly on the object. With stl::list, you'd need to store a + * pointer to its iterator in the object in order to accomplish this. Not + * only would this waste space, but you'd have to remember to update that + * pointer every time you added or removed the object from a list. + * + * In-place, constant-time removal is a killer feature of doubly-linked + * lists, and supporting this painlessly was a key design criterion. + */ + + private: + LinkedListElement* next; + LinkedListElement* prev; + const bool isSentinel; + + LinkedListElement* thisDuringConstruction() { return this; } + + public: + LinkedListElement() + : next(thisDuringConstruction()), + prev(thisDuringConstruction()), + isSentinel(false) + { } + + ~LinkedListElement() { + if (!isSentinel && isInList()) + remove(); + } + + /* + * Get the next element in the list, or NULL if this is the last element in + * the list. + */ + T* getNext() { + return next->asT(); + } + const T* getNext() const { + return next->asT(); + } + + /* + * Get the previous element in the list, or NULL if this is the first element + * in the list. + */ + T* getPrevious() { + return prev->asT(); + } + const T* getPrevious() const { + return prev->asT(); + } + + /* + * Insert elem after this element in the list. |this| must be part of a + * linked list when you call setNext(); otherwise, this method will assert. + */ + void setNext(T* elem) { + MOZ_ASSERT(isInList()); + setNextUnsafe(elem); + } + + /* + * Insert elem before this element in the list. |this| must be part of a + * linked list when you call setPrevious(); otherwise, this method will + * assert. + */ + void setPrevious(T* elem) { + MOZ_ASSERT(isInList()); + setPreviousUnsafe(elem); + } + + /* + * Remove this element from the list which contains it. If this element is + * not currently part of a linked list, this method asserts. + */ + void remove() { + MOZ_ASSERT(isInList()); + + prev->next = next; + next->prev = prev; + next = this; + prev = this; + } + + /* + * Identical to remove(), but also asserts in debug builds that this element + * is in list. + */ + void removeFrom(const LinkedList& list) { + list.assertContains(asT()); + remove(); + } + + /* + * Return true if |this| part is of a linked list, and false otherwise. + */ + bool isInList() const { + MOZ_ASSERT((next == this) == (prev == this)); + return next != this; + } + + private: + friend class LinkedList; + + enum NodeKind { + NODE_KIND_NORMAL, + NODE_KIND_SENTINEL + }; + + LinkedListElement(NodeKind nodeKind) + : next(thisDuringConstruction()), + prev(thisDuringConstruction()), + isSentinel(nodeKind == NODE_KIND_SENTINEL) + { } + + /* + * Return |this| cast to T* if we're a normal node, or return NULL if we're + * a sentinel node. + */ + T* asT() { + if (isSentinel) + return NULL; + + return static_cast(this); + } + const T* asT() const { + if (isSentinel) + return NULL; + + return static_cast(this); + } + + /* + * Insert elem after this element, but don't check that this element is in + * the list. This is called by LinkedList::insertFront(). + */ + void setNextUnsafe(T* elem) { + LinkedListElement *listElem = static_cast(elem); + MOZ_ASSERT(!listElem->isInList()); + + listElem->next = this->next; + listElem->prev = this; + this->next->prev = listElem; + this->next = listElem; + } + + /* + * Insert elem before this element, but don't check that this element is in + * the list. This is called by LinkedList::insertBack(). + */ + void setPreviousUnsafe(T* elem) { + LinkedListElement* listElem = static_cast*>(elem); + MOZ_ASSERT(!listElem->isInList()); + + listElem->next = this; + listElem->prev = this->prev; + this->prev->next = listElem; + this->prev = listElem; + } + + private: + LinkedListElement& operator=(const LinkedList& other) MOZ_DELETE; + LinkedListElement(const LinkedList& other) MOZ_DELETE; +}; + +template +class LinkedList +{ + private: + LinkedListElement sentinel; + + public: + LinkedList() : sentinel(LinkedListElement::NODE_KIND_SENTINEL) { } + + ~LinkedList() { + MOZ_ASSERT(isEmpty()); + } + + /* + * Add elem to the front of the list. + */ + void insertFront(T* elem) { + /* Bypass setNext()'s this->isInList() assertion. */ + sentinel.setNextUnsafe(elem); + } + + /* + * Add elem to the back of the list. + */ + void insertBack(T* elem) { + sentinel.setPreviousUnsafe(elem); + } + + /* + * Get the first element of the list, or NULL if the list is empty. + */ + T* getFirst() { + return sentinel.getNext(); + } + const T* getFirst() const { + return sentinel.getNext(); + } + + /* + * Get the last element of the list, or NULL if the list is empty. + */ + T* getLast() { + return sentinel.getPrevious(); + } + const T* getLast() const { + return sentinel.getPrevious(); + } + + /* + * Get and remove the first element of the list. If the list is empty, + * return NULL. + */ + T* popFirst() { + T* ret = sentinel.getNext(); + if (ret) + static_cast*>(ret)->remove(); + return ret; + } + + /* + * Get and remove the last element of the list. If the list is empty, + * return NULL. + */ + T* popLast() { + T* ret = sentinel.getPrevious(); + if (ret) + static_cast*>(ret)->remove(); + return ret; + } + + /* + * Return true if the list is empty, or false otherwise. + */ + bool isEmpty() const { + return !sentinel.isInList(); + } + + /* + * Remove all the elements from the list. + * + * This runs in time linear to the list's length, because we have to mark + * each element as not in the list. + */ + void clear() { + while (popFirst()) + continue; + } + + /* + * In a debug build, make sure that the list is sane (no cycles, consistent + * next/prev pointers, only one sentinel). Has no effect in release builds. + */ + void debugAssertIsSane() const { +#ifdef DEBUG + const LinkedListElement* slow; + const LinkedListElement* fast1; + const LinkedListElement* fast2; + + /* + * Check for cycles in the forward singly-linked list using the + * tortoise/hare algorithm. + */ + for (slow = sentinel.next, + fast1 = sentinel.next->next, + fast2 = sentinel.next->next->next; + slow != sentinel && fast1 != sentinel && fast2 != sentinel; + slow = slow->next, fast1 = fast2->next, fast2 = fast1->next) + { + MOZ_ASSERT(slow != fast1); + MOZ_ASSERT(slow != fast2); + } + + /* Check for cycles in the backward singly-linked list. */ + for (slow = sentinel.prev, + fast1 = sentinel.prev->prev, + fast2 = sentinel.prev->prev->prev; + slow != sentinel && fast1 != sentinel && fast2 != sentinel; + slow = slow->prev, fast1 = fast2->prev, fast2 = fast1->prev) + { + MOZ_ASSERT(slow != fast1); + MOZ_ASSERT(slow != fast2); + } + + /* + * Check that |sentinel| is the only node in the list with + * isSentinel == true. + */ + for (const LinkedListElement* elem = sentinel.next; + elem != sentinel; + elem = elem->next) + { + MOZ_ASSERT(!elem->isSentinel); + } + + /* Check that the next/prev pointers match up. */ + const LinkedListElement* prev = sentinel; + const LinkedListElement* cur = sentinel.next; + do { + MOZ_ASSERT(cur->prev == prev); + MOZ_ASSERT(prev->next == cur); + + prev = cur; + cur = cur->next; + } while (cur != sentinel); +#endif /* ifdef DEBUG */ + } + + private: + friend class LinkedListElement; + + void assertContains(const T* t) const { +#ifdef DEBUG + for (const T* elem = getFirst(); + elem; + elem = elem->getNext()) + { + if (elem == t) + return; + } + MOZ_NOT_REACHED("element wasn't found in this list!"); +#endif + } + + LinkedList& operator=(const LinkedList& other) MOZ_DELETE; + LinkedList(const LinkedList& other) MOZ_DELETE; +}; + +} /* namespace mozilla */ + +#endif /* ifdef __cplusplus */ +#endif /* ifdef mozilla_LinkedList_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/MSStdInt.h b/scripting/javascript/spidermonkey-mac/include/mozilla/MSStdInt.h new file mode 100644 index 0000000000..0447f2f11b --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/MSStdInt.h @@ -0,0 +1,247 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int32_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint32_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/MathAlgorithms.h b/scripting/javascript/spidermonkey-mac/include/mozilla/MathAlgorithms.h new file mode 100644 index 0000000000..0a47810553 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/MathAlgorithms.h @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* mfbt maths algorithms. */ + +#ifndef mozilla_MathAlgorithms_h_ +#define mozilla_MathAlgorithms_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/StandardInteger.h" +#include "mozilla/TypeTraits.h" + +#include +#include + +namespace mozilla { + +// Greatest Common Divisor +template +MOZ_ALWAYS_INLINE IntegerType +EuclidGCD(IntegerType a, IntegerType b) +{ + // Euclid's algorithm; O(N) in the worst case. (There are better + // ways, but we don't need them for the current use of this algo.) + MOZ_ASSERT(a > 0); + MOZ_ASSERT(b > 0); + + while (a != b) { + if (a > b) { + a = a - b; + } else { + b = b - a; + } + } + + return a; +} + +// Least Common Multiple +template +MOZ_ALWAYS_INLINE IntegerType +EuclidLCM(IntegerType a, IntegerType b) +{ + // Divide first to reduce overflow risk. + return (a / EuclidGCD(a, b)) * b; +} + +namespace detail { + +template +struct AllowDeprecatedAbsFixed : FalseType {}; + +template<> struct AllowDeprecatedAbsFixed : TrueType {}; +template<> struct AllowDeprecatedAbsFixed : TrueType {}; + +template +struct AllowDeprecatedAbs : AllowDeprecatedAbsFixed {}; + +template<> struct AllowDeprecatedAbs : TrueType {}; +template<> struct AllowDeprecatedAbs : TrueType {}; + +} // namespace detail + +// DO NOT USE DeprecatedAbs. It exists only until its callers can be converted +// to Abs below, and it will be removed when all callers have been changed. +template +inline typename mozilla::EnableIf::value, T>::Type +DeprecatedAbs(const T t) +{ + // The absolute value of the smallest possible value of a signed-integer type + // won't fit in that type (on twos-complement systems -- and we're blithely + // assuming we're on such systems, for the non- types listed above), + // so assert that the input isn't that value. + // + // This is the case if: the value is non-negative; or if adding one (giving a + // value in the range [-maxvalue, 0]), then negating (giving a value in the + // range [0, maxvalue]), doesn't produce maxvalue (because in twos-complement, + // (minvalue + 1) == -maxvalue). + MOZ_ASSERT(t >= 0 || + -(t + 1) != T((1ULL << (CHAR_BIT * sizeof(T) - 1)) - 1), + "You can't negate the smallest possible negative integer!"); + return t >= 0 ? t : -t; +} + +namespace detail { + +// For now mozilla::Abs only takes intN_T, the signed natural types, and +// float/double/long double. Feel free to add overloads for other standard, +// signed types if you need them. + +template +struct AbsReturnTypeFixed; + +template<> struct AbsReturnTypeFixed { typedef uint8_t Type; }; +template<> struct AbsReturnTypeFixed { typedef uint16_t Type; }; +template<> struct AbsReturnTypeFixed { typedef uint32_t Type; }; +template<> struct AbsReturnTypeFixed { typedef uint64_t Type; }; + +template +struct AbsReturnType : AbsReturnTypeFixed {}; + +template<> struct AbsReturnType : EnableIf {}; +template<> struct AbsReturnType { typedef unsigned char Type; }; +template<> struct AbsReturnType { typedef unsigned short Type; }; +template<> struct AbsReturnType { typedef unsigned int Type; }; +template<> struct AbsReturnType { typedef unsigned long Type; }; +template<> struct AbsReturnType { typedef unsigned long long Type; }; +template<> struct AbsReturnType { typedef float Type; }; +template<> struct AbsReturnType { typedef double Type; }; +template<> struct AbsReturnType { typedef long double Type; }; + +} // namespace detail + +template +inline typename detail::AbsReturnType::Type +Abs(const T t) +{ + typedef typename detail::AbsReturnType::Type ReturnType; + return t >= 0 ? ReturnType(t) : ~ReturnType(t) + 1; +} + +template<> +inline float +Abs(const float f) +{ + return std::fabs(f); +} + +template<> +inline double +Abs(const double d) +{ + return std::fabs(d); +} + +template<> +inline long double +Abs(const long double d) +{ + return std::fabs(d); +} + +} /* namespace mozilla */ + +#endif /* mozilla_MathAlgorithms_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/MemoryChecking.h b/scripting/javascript/spidermonkey-mac/include/mozilla/MemoryChecking.h new file mode 100644 index 0000000000..3287e57ba1 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/MemoryChecking.h @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Provides a common interface to the ASan (AddressSanitizer) and Valgrind + * functions used to mark memory in certain ways. In detail, the following + * three macros are provided: + * + * MOZ_MAKE_MEM_NOACCESS - Mark memory as unsafe to access (e.g. freed) + * MOZ_MAKE_MEM_UNDEFINED - Mark memory as accessible, with content undefined + * MOZ_MAKE_MEM_DEFINED - Mark memory as accessible, with content defined + * + * With Valgrind in use, these directly map to the three respective Valgrind + * macros. With ASan in use, the NOACCESS macro maps to poisoning the memory, + * while the UNDEFINED/DEFINED macros unpoison memory. + * + * With no memory checker available, all macros expand to the empty statement. + */ + +#ifndef mozilla_MemoryChecking_h_ +#define mozilla_MemoryChecking_h_ + +#if defined(MOZ_VALGRIND) +#include "valgrind/memcheck.h" +#endif + +#if defined(MOZ_ASAN) || defined(MOZ_VALGRIND) +#define MOZ_HAVE_MEM_CHECKS 1 +#endif + +#if defined(MOZ_ASAN) +#include + +extern "C" { + /* These definitions are usually provided through the + * sanitizer/asan_interface.h header installed by ASan. + */ + void __asan_poison_memory_region(void const volatile *addr, size_t size) + __attribute__((visibility("default"))); + void __asan_unpoison_memory_region(void const volatile *addr, size_t size) + __attribute__((visibility("default"))); + +#define MOZ_MAKE_MEM_NOACCESS(addr, size) \ + __asan_poison_memory_region((addr), (size)) + +#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \ + __asan_unpoison_memory_region((addr), (size)) + +#define MOZ_MAKE_MEM_DEFINED(addr, size) \ + __asan_unpoison_memory_region((addr), (size)) +} +#elif defined(MOZ_VALGRIND) +#define MOZ_MAKE_MEM_NOACCESS(addr, size) \ + VALGRIND_MAKE_MEM_NOACCESS((addr), (size)) + +#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \ + VALGRIND_MAKE_MEM_UNDEFINED((addr), (size)) + +#define MOZ_MAKE_MEM_DEFINED(addr, size) \ + VALGRIND_MAKE_MEM_DEFINED((addr), (size)) +#else + +#define MOZ_MAKE_MEM_NOACCESS(addr, size) do {} while(0) +#define MOZ_MAKE_MEM_UNDEFINED(addr, size) do {} while(0) +#define MOZ_MAKE_MEM_DEFINED(addr, size) do {} while(0) + +#endif + +#endif /* mozilla_MemoryChecking_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/NullPtr.h b/scripting/javascript/spidermonkey-mac/include/mozilla/NullPtr.h new file mode 100644 index 0000000000..7dcb03d734 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/NullPtr.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Implements a workaround for compilers which do not support the C++11 nullptr + * constant. + */ + +#ifndef mozilla_NullPtr_h_ +#define mozilla_NullPtr_h_ + +#include "mozilla/Compiler.h" + +#if defined(__clang__) +# ifndef __has_extension +# define __has_extension __has_feature +# endif +# if __has_extension(cxx_nullptr) +# define MOZ_HAVE_CXX11_NULLPTR +# endif +#elif defined(__GNUC__) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) +# define MOZ_HAVE_CXX11_NULLPTR +# endif +# endif +#elif _MSC_VER >= 1600 +# define MOZ_HAVE_CXX11_NULLPTR +#endif + +/** + * Use C++11 nullptr if available; otherwise use __null for gcc, or a 0 literal + * with the correct size to match the size of a pointer on a given platform. + */ + +#ifndef MOZ_HAVE_CXX11_NULLPTR +# if defined(__GNUC__) +# define nullptr __null +# elif defined(_WIN64) +# define nullptr 0LL +# else +# define nullptr 0L +# endif +#endif + +#endif /* mozilla_NullPtr_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Range.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Range.h new file mode 100644 index 0000000000..e14594d09d --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Range.h @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=78: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_Range_h_ +#define mozilla_Range_h_ + +#include "mozilla/NullPtr.h" +#include "mozilla/RangedPtr.h" + +#include + +namespace mozilla { + +// Range is a tuple containing a pointer and a length. +template +class Range +{ + RangedPtr mStart; + RangedPtr mEnd; + + typedef void (Range::* ConvertibleToBool)(); + void nonNull() {} + + public: + Range() : mStart(nullptr, 0), mEnd(nullptr, 0) {} + Range(T* p, size_t len) + : mStart(p, p, p + len), + mEnd(p + len, p, p + len) + {} + + RangedPtr start() const { return mStart; } + RangedPtr end() const { return mEnd; } + size_t length() const { return mEnd - mStart; } + + T& operator[](size_t offset) { + return mStart[offset]; + } + + operator ConvertibleToBool() const { return mStart ? &Range::nonNull : 0; } +}; + +} // namespace mozilla + +#endif // mozilla_Range_h_ + diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/RangedPtr.h b/scripting/javascript/spidermonkey-mac/include/mozilla/RangedPtr.h new file mode 100644 index 0000000000..7ce19d071f --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/RangedPtr.h @@ -0,0 +1,254 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Implements a smart pointer asserted to remain within a range specified at + * construction. + */ + +#ifndef mozilla_RangedPtr_h_ +#define mozilla_RangedPtr_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/Util.h" + +namespace mozilla { + +/* + * RangedPtr is a smart pointer restricted to an address range specified at + * creation. The pointer (and any smart pointers derived from it) must remain + * within the range [start, end] (inclusive of end to facilitate use as + * sentinels). Dereferencing or indexing into the pointer (or pointers derived + * from it) must remain within the range [start, end). All the standard pointer + * operators are defined on it; in debug builds these operations assert that the + * range specified at construction is respected. + * + * In theory passing a smart pointer instance as an argument can be slightly + * slower than passing a T* (due to ABI requirements for passing structs versus + * passing pointers), if the method being called isn't inlined. If you are in + * extremely performance-critical code, you may want to be careful using this + * smart pointer as an argument type. + * + * RangedPtr intentionally does not implicitly convert to T*. Use get() to + * explicitly convert to T*. Keep in mind that the raw pointer of course won't + * implement bounds checking in debug builds. + */ +template +class RangedPtr +{ + T* ptr; + +#ifdef DEBUG + T* const rangeStart; + T* const rangeEnd; +#endif + + typedef void (RangedPtr::* ConvertibleToBool)(); + void nonNull() {} + + void checkSanity() { + MOZ_ASSERT(rangeStart <= ptr); + MOZ_ASSERT(ptr <= rangeEnd); + } + + /* Creates a new pointer for |p|, restricted to this pointer's range. */ + RangedPtr create(T *p) const { +#ifdef DEBUG + return RangedPtr(p, rangeStart, rangeEnd); +#else + return RangedPtr(p, NULL, size_t(0)); +#endif + } + + uintptr_t asUintptr() const { return uintptr_t(ptr); } + + public: + RangedPtr(T* p, T* start, T* end) + : ptr(p) +#ifdef DEBUG + , rangeStart(start), rangeEnd(end) +#endif + { + MOZ_ASSERT(rangeStart <= rangeEnd); + checkSanity(); + } + RangedPtr(T* p, T* start, size_t length) + : ptr(p) +#ifdef DEBUG + , rangeStart(start), rangeEnd(start + length) +#endif + { + MOZ_ASSERT(length <= size_t(-1) / sizeof(T)); + MOZ_ASSERT(uintptr_t(rangeStart) + length * sizeof(T) >= uintptr_t(rangeStart)); + checkSanity(); + } + + /* Equivalent to RangedPtr(p, p, length). */ + RangedPtr(T* p, size_t length) + : ptr(p) +#ifdef DEBUG + , rangeStart(p), rangeEnd(p + length) +#endif + { + MOZ_ASSERT(length <= size_t(-1) / sizeof(T)); + MOZ_ASSERT(uintptr_t(rangeStart) + length * sizeof(T) >= uintptr_t(rangeStart)); + checkSanity(); + } + + /* Equivalent to RangedPtr(arr, arr, N). */ + template + RangedPtr(T (&arr)[N]) + : ptr(arr) +#ifdef DEBUG + , rangeStart(arr), rangeEnd(arr + N) +#endif + { + checkSanity(); + } + + T* get() const { + return ptr; + } + + operator ConvertibleToBool() const { return ptr ? &RangedPtr::nonNull : 0; } + + /* + * You can only assign one RangedPtr into another if the two pointers have + * the same valid range: + * + * char arr1[] = "hi"; + * char arr2[] = "bye"; + * RangedPtr p1(arr1, 2); + * p1 = RangedPtr(arr1 + 1, arr1, arr1 + 2); // works + * p1 = RangedPtr(arr2, 3); // asserts + */ + RangedPtr& operator=(const RangedPtr& other) { + MOZ_ASSERT(rangeStart == other.rangeStart); + MOZ_ASSERT(rangeEnd == other.rangeEnd); + ptr = other.ptr; + checkSanity(); + return *this; + } + + RangedPtr operator+(size_t inc) { + MOZ_ASSERT(inc <= size_t(-1) / sizeof(T)); + MOZ_ASSERT(asUintptr() + inc * sizeof(T) >= asUintptr()); + return create(ptr + inc); + } + + RangedPtr operator-(size_t dec) { + MOZ_ASSERT(dec <= size_t(-1) / sizeof(T)); + MOZ_ASSERT(asUintptr() - dec * sizeof(T) <= asUintptr()); + return create(ptr - dec); + } + + /* + * You can assign a raw pointer into a RangedPtr if the raw pointer is + * within the range specified at creation. + */ + template + RangedPtr& operator=(U* p) { + *this = create(p); + return *this; + } + + template + RangedPtr& operator=(const RangedPtr& p) { + MOZ_ASSERT(rangeStart <= p.ptr); + MOZ_ASSERT(p.ptr <= rangeEnd); + ptr = p.ptr; + checkSanity(); + return *this; + } + + RangedPtr& operator++() { + return (*this += 1); + } + + RangedPtr operator++(int) { + RangedPtr rcp = *this; + ++*this; + return rcp; + } + + RangedPtr& operator--() { + return (*this -= 1); + } + + RangedPtr operator--(int) { + RangedPtr rcp = *this; + --*this; + return rcp; + } + + RangedPtr& operator+=(size_t inc) { + *this = *this + inc; + return *this; + } + + RangedPtr& operator-=(size_t dec) { + *this = *this - dec; + return *this; + } + + T& operator[](int index) const { + MOZ_ASSERT(size_t(index > 0 ? index : -index) <= size_t(-1) / sizeof(T)); + return *create(ptr + index); + } + + T& operator*() const { + return *ptr; + } + + template + bool operator==(const RangedPtr& other) const { + return ptr == other.ptr; + } + template + bool operator!=(const RangedPtr& other) const { + return !(*this == other); + } + + template + bool operator==(const U* u) const { + return ptr == u; + } + template + bool operator!=(const U* u) const { + return !(*this == u); + } + + template + bool operator<(const RangedPtr& other) const { + return ptr < other.ptr; + } + template + bool operator<=(const RangedPtr& other) const { + return ptr <= other.ptr; + } + + template + bool operator>(const RangedPtr& other) const { + return ptr > other.ptr; + } + template + bool operator>=(const RangedPtr& other) const { + return ptr >= other.ptr; + } + + size_t operator-(const RangedPtr& other) const { + MOZ_ASSERT(ptr >= other.ptr); + return PointerRangeSize(other.ptr, ptr); + } + + private: + RangedPtr() MOZ_DELETE; + T* operator&() MOZ_DELETE; +}; + +} /* namespace mozilla */ + +#endif /* mozilla_RangedPtr_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/RefPtr.h b/scripting/javascript/spidermonkey-mac/include/mozilla/RefPtr.h new file mode 100644 index 0000000000..a298706e71 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/RefPtr.h @@ -0,0 +1,413 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Helpers for defining and using refcounted objects. */ + +#ifndef mozilla_RefPtr_h_ +#define mozilla_RefPtr_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" + +namespace mozilla { + +template class RefCounted; +template class RefPtr; +template class TemporaryRef; +template class OutParamRef; +template OutParamRef byRef(RefPtr&); + +/** + * RefCounted is a sort of a "mixin" for a class T. RefCounted + * manages, well, refcounting for T, and because RefCounted is + * parameterized on T, RefCounted can call T's destructor directly. + * This means T doesn't need to have a virtual dtor and so doesn't + * need a vtable. + * + * RefCounted is created with refcount == 0. Newly-allocated + * RefCounted must immediately be assigned to a RefPtr to make the + * refcount > 0. It's an error to allocate and free a bare + * RefCounted, i.e. outside of the RefPtr machinery. Attempts to + * do so will abort DEBUG builds. + * + * Live RefCounted have refcount > 0. The lifetime (refcounts) of + * live RefCounted are controlled by RefPtr and + * RefPtr. Upon a transition from refcounted==1 + * to 0, the RefCounted "dies" and is destroyed. The "destroyed" + * state is represented in DEBUG builds by refcount==0xffffdead. This + * state distinguishes use-before-ref (refcount==0) from + * use-after-destroy (refcount==0xffffdead). + */ +#ifdef DEBUG +namespace detail { +static const int DEAD = 0xffffdead; +} +#endif + +template +class RefCounted +{ + friend class RefPtr; + + protected: + RefCounted() : refCnt(0) { } + ~RefCounted() { MOZ_ASSERT(refCnt == detail::DEAD); } + + public: + // Compatibility with nsRefPtr. + void AddRef() { + MOZ_ASSERT(refCnt >= 0); + ++refCnt; + } + + void Release() { + MOZ_ASSERT(refCnt > 0); + if (0 == --refCnt) { +#ifdef DEBUG + refCnt = detail::DEAD; +#endif + delete static_cast(this); + } + } + + // Compatibility with wtf::RefPtr. + void ref() { AddRef(); } + void deref() { Release(); } + int refCount() const { return refCnt; } + bool hasOneRef() const { + MOZ_ASSERT(refCnt > 0); + return refCnt == 1; + } + + private: + int refCnt; +}; + +/** + * RefPtr points to a refcounted thing that has AddRef and Release + * methods to increase/decrease the refcount, respectively. After a + * RefPtr is assigned a T*, the T* can be used through the RefPtr + * as if it were a T*. + * + * A RefPtr can forget its underlying T*, which results in the T* + * being wrapped in a temporary object until the T* is either + * re-adopted from or released by the temporary. + */ +template +class RefPtr +{ + // To allow them to use unref() + friend class TemporaryRef; + friend class OutParamRef; + + struct DontRef {}; + + public: + RefPtr() : ptr(0) { } + RefPtr(const RefPtr& o) : ptr(ref(o.ptr)) {} + RefPtr(const TemporaryRef& o) : ptr(o.drop()) {} + RefPtr(T* t) : ptr(ref(t)) {} + + template + RefPtr(const RefPtr& o) : ptr(ref(o.get())) {} + + ~RefPtr() { unref(ptr); } + + RefPtr& operator=(const RefPtr& o) { + assign(ref(o.ptr)); + return *this; + } + RefPtr& operator=(const TemporaryRef& o) { + assign(o.drop()); + return *this; + } + RefPtr& operator=(T* t) { + assign(ref(t)); + return *this; + } + + template + RefPtr& operator=(const RefPtr& o) { + assign(ref(o.get())); + return *this; + } + + TemporaryRef forget() { + T* tmp = ptr; + ptr = 0; + return TemporaryRef(tmp, DontRef()); + } + + T* get() const { return ptr; } + operator T*() const { return ptr; } + T* operator->() const { return ptr; } + T& operator*() const { return *ptr; } + template + operator TemporaryRef() { return TemporaryRef(ptr); } + + private: + void assign(T* t) { + unref(ptr); + ptr = t; + } + + T* ptr; + + static MOZ_ALWAYS_INLINE T* ref(T* t) { + if (t) + t->AddRef(); + return t; + } + + static MOZ_ALWAYS_INLINE void unref(T* t) { + if (t) + t->Release(); + } +}; + +/** + * TemporaryRef represents an object that holds a temporary + * reference to a T. TemporaryRef objects can't be manually ref'd or + * unref'd (being temporaries, not lvalues), so can only relinquish + * references to other objects, or unref on destruction. + */ +template +class TemporaryRef +{ + // To allow it to construct TemporaryRef from a bare T* + friend class RefPtr; + + typedef typename RefPtr::DontRef DontRef; + + public: + TemporaryRef(T* t) : ptr(RefPtr::ref(t)) {} + TemporaryRef(const TemporaryRef& o) : ptr(o.drop()) {} + + template + TemporaryRef(const TemporaryRef& o) : ptr(o.drop()) {} + + ~TemporaryRef() { RefPtr::unref(ptr); } + + T* drop() const { + T* tmp = ptr; + ptr = 0; + return tmp; + } + + private: + TemporaryRef(T* t, const DontRef&) : ptr(t) {} + + mutable T* ptr; + + TemporaryRef() MOZ_DELETE; + void operator=(const TemporaryRef&) MOZ_DELETE; +}; + +/** + * OutParamRef is a wrapper that tracks a refcounted pointer passed as + * an outparam argument to a function. OutParamRef implements COM T** + * outparam semantics: this requires the callee to AddRef() the T* + * returned through the T** outparam on behalf of the caller. This + * means the caller (through OutParamRef) must Release() the old + * object contained in the tracked RefPtr. It's OK if the callee + * returns the same T* passed to it through the T** outparam, as long + * as the callee obeys the COM discipline. + * + * Prefer returning TemporaryRef from functions over creating T** + * outparams and passing OutParamRef to T**. Prefer RefPtr* + * outparams over T** outparams. + */ +template +class OutParamRef +{ + friend OutParamRef byRef(RefPtr&); + + public: + ~OutParamRef() { + RefPtr::unref(refPtr.ptr); + refPtr.ptr = tmp; + } + + operator T**() { return &tmp; } + + private: + OutParamRef(RefPtr& p) : refPtr(p), tmp(p.get()) {} + + RefPtr& refPtr; + T* tmp; + + OutParamRef() MOZ_DELETE; + OutParamRef& operator=(const OutParamRef&) MOZ_DELETE; +}; + +/** + * byRef cooperates with OutParamRef to implement COM outparam semantics. + */ +template +OutParamRef +byRef(RefPtr& ptr) +{ + return OutParamRef(ptr); +} + +} // namespace mozilla + +#endif // mozilla_RefPtr_h_ + + +#if 0 + +// Command line that builds these tests +// +// cp RefPtr.h test.cc && g++ -g -Wall -pedantic -DDEBUG -o test test.cc && ./test + +using namespace mozilla; + +struct Foo : public RefCounted +{ + Foo() : dead(false) { } + ~Foo() { + MOZ_ASSERT(!dead); + dead = true; + numDestroyed++; + } + + bool dead; + static int numDestroyed; +}; +int Foo::numDestroyed; + +struct Bar : public Foo { }; + +TemporaryRef +NewFoo() +{ + return RefPtr(new Foo()); +} + +TemporaryRef +NewBar() +{ + return new Bar(); +} + +void +GetNewFoo(Foo** f) +{ + *f = new Bar(); + // Kids, don't try this at home + (*f)->AddRef(); +} + +void +GetPassedFoo(Foo** f) +{ + // Kids, don't try this at home + (*f)->AddRef(); +} + +void +GetNewFoo(RefPtr* f) +{ + *f = new Bar(); +} + +void +GetPassedFoo(RefPtr* f) +{} + +TemporaryRef +GetNullFoo() +{ + return 0; +} + +int +main(int argc, char** argv) +{ + // This should blow up +// Foo* f = new Foo(); delete f; + + MOZ_ASSERT(0 == Foo::numDestroyed); + { + RefPtr f = new Foo(); + MOZ_ASSERT(f->refCount() == 1); + } + MOZ_ASSERT(1 == Foo::numDestroyed); + + { + RefPtr f1 = NewFoo(); + RefPtr f2(NewFoo()); + MOZ_ASSERT(1 == Foo::numDestroyed); + } + MOZ_ASSERT(3 == Foo::numDestroyed); + + { + RefPtr b = NewBar(); + MOZ_ASSERT(3 == Foo::numDestroyed); + } + MOZ_ASSERT(4 == Foo::numDestroyed); + + { + RefPtr f1; + { + f1 = new Foo(); + RefPtr f2(f1); + RefPtr f3 = f2; + MOZ_ASSERT(4 == Foo::numDestroyed); + } + MOZ_ASSERT(4 == Foo::numDestroyed); + } + MOZ_ASSERT(5 == Foo::numDestroyed); + + { + RefPtr f = new Foo(); + f.forget(); + MOZ_ASSERT(6 == Foo::numDestroyed); + } + + { + RefPtr f = new Foo(); + GetNewFoo(byRef(f)); + MOZ_ASSERT(7 == Foo::numDestroyed); + } + MOZ_ASSERT(8 == Foo::numDestroyed); + + { + RefPtr f = new Foo(); + GetPassedFoo(byRef(f)); + MOZ_ASSERT(8 == Foo::numDestroyed); + } + MOZ_ASSERT(9 == Foo::numDestroyed); + + { + RefPtr f = new Foo(); + GetNewFoo(&f); + MOZ_ASSERT(10 == Foo::numDestroyed); + } + MOZ_ASSERT(11 == Foo::numDestroyed); + + { + RefPtr f = new Foo(); + GetPassedFoo(&f); + MOZ_ASSERT(11 == Foo::numDestroyed); + } + MOZ_ASSERT(12 == Foo::numDestroyed); + + { + RefPtr f1 = new Bar(); + } + MOZ_ASSERT(13 == Foo::numDestroyed); + + { + RefPtr f = GetNullFoo(); + MOZ_ASSERT(13 == Foo::numDestroyed); + } + MOZ_ASSERT(13 == Foo::numDestroyed); + + return 0; +} + +#endif diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/SHA1.h b/scripting/javascript/spidermonkey-mac/include/mozilla/SHA1.h new file mode 100644 index 0000000000..a6604e699f --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/SHA1.h @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Simple class for computing SHA1. */ + +#ifndef mozilla_SHA1_h_ +#define mozilla_SHA1_h_ + +#include "mozilla/StandardInteger.h" +#include "mozilla/Types.h" + +#include + +namespace mozilla { + +/** + * This class computes the SHA1 hash of a byte sequence, or of the concatenation + * of multiple sequences. For example, computing the SHA1 of two sequences of + * bytes could be done as follows: + * + * void SHA1(const uint8_t* buf1, uint32_t size1, + * const uint8_t* buf2, uint32_t size2, + * SHA1Sum::Hash& hash) + * { + * SHA1Sum s; + * s.update(buf1, size1); + * s.update(buf2, size2); + * s.finish(hash); + * } + * + * The finish method may only be called once and cannot be followed by calls + * to update. + */ +class SHA1Sum +{ + union { + uint32_t w[16]; /* input buffer */ + uint8_t b[64]; + } u; + uint64_t size; /* count of hashed bytes. */ + unsigned H[22]; /* 5 state variables, 16 tmp values, 1 extra */ + bool mDone; + + public: + MFBT_API SHA1Sum(); + + static const size_t HashSize = 20; + typedef uint8_t Hash[HashSize]; + + /* Add len bytes of dataIn to the data sequence being hashed. */ + MFBT_API void update(const void* dataIn, uint32_t len); + + /* Compute the final hash of all data into hashOut. */ + MFBT_API void finish(SHA1Sum::Hash& hashOut); +}; + +} /* namespace mozilla */ + +#endif /* mozilla_SHA1_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Scoped.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Scoped.h new file mode 100644 index 0000000000..677a1a3797 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Scoped.h @@ -0,0 +1,271 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* A number of structures to simplify scope-based RAII management. */ + +#ifndef mozilla_Scoped_h_ +#define mozilla_Scoped_h_ + +/* + * Resource Acquisition Is Initialization is a programming idiom used + * to write robust code that is able to deallocate resources properly, + * even in presence of execution errors or exceptions that need to be + * propagated. The Scoped* classes defined in this header perform the + * deallocation of the resource they hold once program execution + * reaches the end of the scope for which they have been defined. + * + * This header provides the following RAII classes: + * + * - |ScopedFreePtr| - a container for a pointer, that automatically calls + * |free()| at the end of the scope; + * - |ScopedDeletePtr| - a container for a pointer, that automatically calls + * |delete| at the end of the scope; + * - |ScopedDeleteArray| - a container for a pointer to an array, that + * automatically calls |delete[]| at the end of the scope. + * + * The general scenario for each of the RAII classes is the following: + * + * ScopedClass foo(create_value()); + * // ... In this scope, |foo| is defined. Use |foo.get()| or |foo.rwget()| + * to access the value. + * // ... In case of |return| or |throw|, |foo| is deallocated automatically. + * // ... If |foo| needs to be returned or stored, use |foo.forget()| + * + * Note that the RAII classes defined in this header do _not_ perform any form + * of reference-counting or garbage-collection. These classes have exactly two + * behaviors: + * + * - if |forget()| has not been called, the resource is always deallocated at + * the end of the scope; + * - if |forget()| has been called, any control on the resource is unbound + * and the resource is not deallocated by the class. + * + * Extension: + * + * In addition, this header provides class |Scoped| and macros |SCOPED_TEMPLATE| + * and |MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE| to simplify the definition + * of RAII classes for other scenarios. These macros have been used to + * automatically close file descriptors/file handles when reaching the end of + * the scope, graphics contexts, etc. + */ + +#include "mozilla/Attributes.h" +#include "mozilla/GuardObjects.h" + +namespace mozilla { + +/* + * Scoped is a helper to create RAII wrappers + * Type argument |Traits| is expected to have the following structure: + * + * struct Traits { + * // Define the type of the value stored in the wrapper + * typedef value_type type; + * // Returns the value corresponding to the uninitialized or freed state + * const static type empty(); + * // Release resources corresponding to the wrapped value + * // This function is responsible for not releasing an |empty| value + * const static void release(type); + * } + */ +template +class Scoped +{ + public: + typedef typename Traits::type Resource; + + explicit Scoped(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) + : value(Traits::empty()) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + explicit Scoped(const Resource& v + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : value(v) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + ~Scoped() { + Traits::release(value); + } + + // Constant getter + operator const Resource&() const { return value; } + const Resource& operator->() const { return value; } + const Resource& get() const { return value; } + // Non-constant getter. + Resource& rwget() { return value; } + + /* + * Forget the resource. + * + * Once |forget| has been called, the |Scoped| is neutralized, i.e. it will + * have no effect at destruction (unless it is reset to another resource by + * |operator=|). + * + * @return The original resource. + */ + Resource forget() { + Resource tmp = value; + value = Traits::empty(); + return tmp; + } + + /* + * Perform immediate clean-up of this |Scoped|. + * + * If this |Scoped| is currently empty, this method has no effect. + */ + void dispose() { + Traits::release(value); + value = Traits::empty(); + } + + bool operator==(const Resource& other) const { + return value == other; + } + + /* + * Replace the resource with another resource. + * + * Calling |operator=| has the side-effect of triggering clean-up. If you do + * not want to trigger clean-up, you should first invoke |forget|. + * + * @return this + */ + Scoped& operator=(const Resource& other) { + return reset(other); + } + Scoped& reset(const Resource& other) { + Traits::release(value); + value = other; + return *this; + } + + private: + explicit Scoped(const Scoped& value) MOZ_DELETE; + Scoped& operator=(const Scoped& value) MOZ_DELETE; + + private: + Resource value; + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER +}; + +/* + * SCOPED_TEMPLATE defines a templated class derived from Scoped + * This allows to implement templates such as ScopedFreePtr. + * + * @param name The name of the class to define. + * @param Traits A struct implementing clean-up. See the implementations + * for more details. + */ +#define SCOPED_TEMPLATE(name, Traits) \ +template \ +struct name : public mozilla::Scoped > \ +{ \ + typedef mozilla::Scoped > Super; \ + typedef typename Super::Resource Resource; \ + name& operator=(Resource ptr) { \ + Super::operator=(ptr); \ + return *this; \ + } \ + explicit name(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) \ + : Super(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT) \ + {} \ + explicit name(Resource ptr \ + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) \ + : Super(ptr MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) \ + {} \ + private: \ + explicit name(name& source) MOZ_DELETE; \ + name& operator=(name& source) MOZ_DELETE; \ +}; + +/* + * ScopedFreePtr is a RAII wrapper for pointers that need to be free()d. + * + * struct S { ... }; + * ScopedFreePtr foo = malloc(sizeof(S)); + * ScopedFreePtr bar = strdup(str); + */ +template +struct ScopedFreePtrTraits +{ + typedef T* type; + static T* empty() { return NULL; } + static void release(T* ptr) { free(ptr); } +}; +SCOPED_TEMPLATE(ScopedFreePtr, ScopedFreePtrTraits) + +/* + * ScopedDeletePtr is a RAII wrapper for pointers that need to be deleted. + * + * struct S { ... }; + * ScopedDeletePtr foo = new S(); + */ +template +struct ScopedDeletePtrTraits : public ScopedFreePtrTraits +{ + static void release(T* ptr) { delete ptr; } +}; +SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits) + +/* + * ScopedDeleteArray is a RAII wrapper for pointers that need to be delete[]ed. + * + * struct S { ... }; + * ScopedDeleteArray foo = new S[42]; + */ +template +struct ScopedDeleteArrayTraits : public ScopedFreePtrTraits +{ + static void release(T* ptr) { delete [] ptr; } +}; +SCOPED_TEMPLATE(ScopedDeleteArray, ScopedDeleteArrayTraits) + +/* + * MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE makes it easy to create scoped + * pointers for types with custom deleters; just overload + * TypeSpecificDelete(T*) in the same namespace as T to call the deleter for + * type T. + * + * @param name The name of the class to define. + * @param Type A struct implementing clean-up. See the implementations + * for more details. + * *param Deleter The function that is used to delete/destroy/free a + * non-null value of Type*. + * + * Example: + * + * MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc, \ + * PR_Close) + * ... + * { + * ScopedPRFileDesc file(PR_OpenFile(...)); + * ... + * } // file is closed with PR_Close here + */ +#define MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(name, Type, Deleter) \ +template <> inline void TypeSpecificDelete(Type * value) { Deleter(value); } \ +typedef ::mozilla::TypeSpecificScopedPointer name; + +template void TypeSpecificDelete(T * value); + +template +struct TypeSpecificScopedPointerTraits +{ + typedef T* type; + const static type empty() { return NULL; } + const static void release(type value) + { + if (value) + TypeSpecificDelete(value); + } +}; + +SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits) + +} /* namespace mozilla */ + +#endif // mozilla_Scoped_h_ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/SplayTree.h b/scripting/javascript/spidermonkey-mac/include/mozilla/SplayTree.h new file mode 100644 index 0000000000..f9a10d36dd --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/SplayTree.h @@ -0,0 +1,285 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99 ft=cpp: + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * A sorted tree with optimal access times, where recently-accessed elements + * are faster to access again. + */ + +#ifndef mozilla_SplayTree_h_ +#define mozilla_SplayTree_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/NullPtr.h" + +namespace mozilla { + +template +class SplayTree; + +template +class SplayTreeNode +{ + public: + template + friend class SplayTree; + + SplayTreeNode() + : left(nullptr), right(nullptr), parent(nullptr) + {} + + private: + T* left; + T* right; + T* parent; +}; + + +/** + * Class which represents a splay tree. + * Splay trees are balanced binary search trees for which search, insert and + * remove are all amortized O(log n), but where accessing a node makes it + * faster to access that node in the future. + * + * T indicates the type of tree elements, Comparator must have a static + * compare(const T&, const T&) method ordering the elements. The compare + * method must be free from side effects. + */ +template +class SplayTree +{ + T* root; + T* freeList; + + public: + SplayTree() + : root(nullptr), freeList(nullptr) + {} + + bool empty() const { + return !root; + } + + bool contains(const T& v) + { + if (empty()) + return false; + + T* last = lookup(v); + splay(last); + checkCoherency(root, nullptr); + return Comparator::compare(v, *last) == 0; + } + + bool insert(T* v) + { + MOZ_ASSERT(!contains(*v), "Duplicate elements are not allowed."); + + if (!root) { + root = v; + return true; + } + T* last = lookup(*v); + int cmp = Comparator::compare(*v, *last); + + T** parentPointer = (cmp < 0) ? &last->left : &last->right; + MOZ_ASSERT(!*parentPointer); + *parentPointer = v; + v->parent = last; + + splay(v); + checkCoherency(root, nullptr); + return true; + } + + T* remove(const T& v) + { + T* last = lookup(v); + MOZ_ASSERT(last, "This tree must contain the element being removed."); + MOZ_ASSERT(Comparator::compare(v, *last) == 0); + + // Splay the tree so that the item to remove is the root. + splay(last); + MOZ_ASSERT(last == root); + + // Find another node which can be swapped in for the root: either the + // rightmost child of the root's left, or the leftmost child of the + // root's right. + T* swap; + T* swapChild; + if (root->left) { + swap = root->left; + while (swap->right) + swap = swap->right; + swapChild = swap->left; + } else if (root->right) { + swap = root->right; + while (swap->left) + swap = swap->left; + swapChild = swap->right; + } else { + T* result = root; + root = nullptr; + return result; + } + + // The selected node has at most one child, in swapChild. Detach it + // from the subtree by replacing it with that child. + if (swap == swap->parent->left) + swap->parent->left = swapChild; + else + swap->parent->right = swapChild; + if (swapChild) + swapChild->parent = swap->parent; + + // Make the selected node the new root. + root = swap; + root->parent = nullptr; + root->left = last->left; + root->right = last->right; + if (root->left) { + root->left->parent = root; + } + if (root->right) { + root->right->parent = root; + } + + checkCoherency(root, nullptr); + return last; + } + + T* removeMin() + { + MOZ_ASSERT(root, "No min to remove!"); + + T* min = root; + while (min->left) + min = min->left; + return remove(*min); + } + + private: + /** + * Returns the node in this comparing equal to |v|, or a node just greater or + * just less than |v| if there is no such node. + */ + T* lookup(const T& v) + { + MOZ_ASSERT(!empty()); + + T* node = root; + T* parent; + do { + parent = node; + int c = Comparator::compare(v, *node); + if (c == 0) + return node; + else if (c < 0) + node = node->left; + else + node = node->right; + } while (node); + return parent; + } + + /** + * Rotate the tree until |node| is at the root of the tree. Performing + * the rotations in this fashion preserves the amortized balancing of + * the tree. + */ + void splay(T* node) + { + MOZ_ASSERT(node); + + while (node != root) { + T* parent = node->parent; + if (parent == root) { + // Zig rotation. + rotate(node); + MOZ_ASSERT(node == root); + return; + } + T* grandparent = parent->parent; + if ((parent->left == node) == (grandparent->left == parent)) { + // Zig-zig rotation. + rotate(parent); + rotate(node); + } else { + // Zig-zag rotation. + rotate(node); + rotate(node); + } + } + } + + void rotate(T* node) + { + // Rearrange nodes so that node becomes the parent of its current + // parent, while preserving the sortedness of the tree. + T* parent = node->parent; + if (parent->left == node) { + // x y + // y c ==> a x + // a b b c + parent->left = node->right; + if (node->right) + node->right->parent = parent; + node->right = parent; + } else { + MOZ_ASSERT(parent->right == node); + // x y + // a y ==> x c + // b c a b + parent->right = node->left; + if (node->left) + node->left->parent = parent; + node->left = parent; + } + node->parent = parent->parent; + parent->parent = node; + if (T* grandparent = node->parent) { + if (grandparent->left == parent) + grandparent->left = node; + else + grandparent->right = node; + } else { + root = node; + } + } + + T* checkCoherency(T* node, T* minimum) + { +#ifdef DEBUG + MOZ_ASSERT_IF(root, !root->parent); + if (!node) { + MOZ_ASSERT(!root); + return nullptr; + } + MOZ_ASSERT_IF(!node->parent, node == root); + MOZ_ASSERT_IF(minimum, Comparator::compare(*minimum, *node) < 0); + if (node->left) { + MOZ_ASSERT(node->left->parent == node); + T* leftMaximum = checkCoherency(node->left, minimum); + MOZ_ASSERT(Comparator::compare(*leftMaximum, *node) < 0); + } + if (node->right) { + MOZ_ASSERT(node->right->parent == node); + return checkCoherency(node->right, node); + } + return node; +#else + return nullptr; +#endif + } + + SplayTree(const SplayTree&) MOZ_DELETE; + void operator=(const SplayTree&) MOZ_DELETE; +}; + +} /* namespace mozilla */ + +#endif /* mozilla_SplayTree_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/StandardInteger.h b/scripting/javascript/spidermonkey-mac/include/mozilla/StandardInteger.h new file mode 100644 index 0000000000..8e4c8578f1 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/StandardInteger.h @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Implements the C99 interface for C and C++ code. */ + +#ifndef mozilla_StandardInteger_h_ +#define mozilla_StandardInteger_h_ + +/* + * The C99 standard header exposes typedefs for common fixed-width + * integer types. It would be feasible to simply #include , but + * MSVC++ versions prior to 2010 don't provide . We could solve this + * by reimplementing for MSVC++ 2008 and earlier. But then we reach + * a second problem: our custom might conflict with a + * defined by an embedder already looking to work around the MSVC++ + * absence. + * + * We address these issues in this manner: + * + * 1. If the preprocessor macro MOZ_CUSTOM_STDINT_H is defined to a path to a + * custom implementation, we will #include it. Embedders using + * a custom must define this macro to an implementation that + * will work with their embedding. + * 2. Otherwise, if we are compiling with a an MSVC++ version without + * , #include our custom reimplementation. + * 3. Otherwise, #include the standard provided by the compiler. + * + * Note that we can't call this file "stdint.h" or something case-insensitively + * equal to "stdint.h" because then MSVC (and other compilers on + * case-insensitive file systems) will include this file, rather than the system + * stdint.h, when we ask for below. + */ +#if defined(MOZ_CUSTOM_STDINT_H) +# include MOZ_CUSTOM_STDINT_H +#elif defined(_MSC_VER) && _MSC_VER < 1600 +# include "mozilla/MSStdInt.h" +#else +# include +#endif + +#endif /* mozilla_StandardInteger_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/ThreadLocal.h b/scripting/javascript/spidermonkey-mac/include/mozilla/ThreadLocal.h new file mode 100644 index 0000000000..2b4eb30207 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/ThreadLocal.h @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Cross-platform lightweight thread local data wrappers. */ + +#ifndef mozilla_ThreadLocal_h_ +#define mozilla_ThreadLocal_h_ + +#if defined(XP_WIN) +// This file will get included in any file that wants to add a profiler mark. +// In order to not bring together we could include windef.h and +// winbase.h which are sufficient to get the prototypes for the Tls* functions. +// # include +// # include +// Unfortunately, even including these headers causes us to add a bunch of ugly +// stuff to our namespace e.g #define CreateEvent CreateEventW +extern "C" { +__declspec(dllimport) void* __stdcall TlsGetValue(unsigned long); +__declspec(dllimport) int __stdcall TlsSetValue(unsigned long, void*); +__declspec(dllimport) unsigned long __stdcall TlsAlloc(); +} +#else +# include +# include +#endif + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" + +namespace mozilla { + +// sig_safe_t denotes an atomic type which can be read or stored in a single +// instruction. This means that data of this type is safe to be manipulated +// from a signal handler, or other similar asynchronous execution contexts. +#if defined(XP_WIN) +typedef unsigned long sig_safe_t; +#else +typedef sig_atomic_t sig_safe_t; +#endif + +/* + * Thread Local Storage helpers. + * + * Usage: + * + * Only static-storage-duration (e.g. global variables, or static class members) + * objects of this class should be instantiated. This class relies on + * zero-initialization, which is implicit for static-storage-duration objects. + * It doesn't have a custom default constructor, to avoid static initializers. + * + * API usage: + * + * // Create a TLS item + * mozilla::ThreadLocal tlsKey; + * if (!tlsKey.init()) { + * // deal with the error + * } + * + * // Set the TLS value + * tlsKey.set(123); + * + * // Get the TLS value + * int value = tlsKey.get(); + */ +template +class ThreadLocal +{ +#if defined(XP_WIN) + typedef unsigned long key_t; +#else + typedef pthread_key_t key_t; +#endif + + union Helper { + void* ptr; + T value; + }; + + public: + MOZ_WARN_UNUSED_RESULT inline bool init(); + + inline T get() const; + + inline void set(const T value); + + bool initialized() const { + return inited; + } + + private: + key_t key; + bool inited; +}; + +template +inline bool +ThreadLocal::init() +{ + MOZ_STATIC_ASSERT(sizeof(T) <= sizeof(void*), + "mozilla::ThreadLocal can't be used for types larger than " + "a pointer"); + MOZ_ASSERT(!initialized()); +#ifdef XP_WIN + key = TlsAlloc(); + inited = key != 0xFFFFFFFFUL; // TLS_OUT_OF_INDEXES +#else + inited = !pthread_key_create(&key, NULL); +#endif + return inited; +} + +template +inline T +ThreadLocal::get() const +{ + MOZ_ASSERT(initialized()); + Helper h; +#ifdef XP_WIN + h.ptr = TlsGetValue(key); +#else + h.ptr = pthread_getspecific(key); +#endif + return h.value; +} + +template +inline void +ThreadLocal::set(const T value) +{ + MOZ_ASSERT(initialized()); + Helper h; + h.value = value; + bool succeeded; +#ifdef XP_WIN + succeeded = TlsSetValue(key, h.ptr); +#else + succeeded = !pthread_setspecific(key, h.ptr); +#endif + if (!succeeded) + MOZ_CRASH(); +} + +} // namespace mozilla + +#endif // mozilla_ThreadLocal_h_ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/TypeTraits.h b/scripting/javascript/spidermonkey-mac/include/mozilla/TypeTraits.h new file mode 100644 index 0000000000..661912e116 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/TypeTraits.h @@ -0,0 +1,288 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Template-based metaprogramming and type-testing facilities. */ + +#ifndef mozilla_TypeTraits_h_ +#define mozilla_TypeTraits_h_ + +/* + * These traits are approximate copies of the traits and semantics from C++11's + * header. Don't add traits not in that header! When all + * platforms provide that header, we can convert all users and remove this one. + */ + +#include + +namespace mozilla { + +/* 20.9.3 Helper classes [meta.help] */ + +/** + * Helper class used as a base for various type traits, exposed publicly + * because exposes it as well. + */ +template +struct IntegralConstant +{ + static const T value = Value; + typedef T ValueType; + typedef IntegralConstant Type; +}; + +/** Convenient aliases. */ +typedef IntegralConstant TrueType; +typedef IntegralConstant FalseType; + +/* 20.9.4 Unary type traits [meta.unary] */ + +/* 20.9.4.1 Primary type categories [meta.unary.cat] */ + +/** + * IsPointer determines whether a type is a pointer type (but not a pointer-to- + * member type). + * + * mozilla::IsPointer::value is true; + * mozilla::IsPointer::value is true; + * mozilla::IsPointer::value is true; + * mozilla::IsPointer::value is false; + * mozilla::IsPointer::value is false. + */ +template +struct IsPointer : FalseType {}; + +template +struct IsPointer : TrueType {}; + +/* 20.9.4.2 Composite type traits [meta.unary.comp] */ + +/* 20.9.4.3 Type properties [meta.unary.prop] */ + +/** + * Traits class for identifying POD types. Until C++11 there's no automatic + * way to detect PODs, so for the moment this is done manually. Users may + * define specializations of this class that inherit from mozilla::TrueType and + * mozilla::FalseType (or equivalently mozilla::IntegralConstant, or conveniently from mozilla::IsPod for composite types) as needed to + * ensure correct IsPod behavior. + */ +template +struct IsPod : public FalseType {}; + +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; +template struct IsPod : TrueType {}; + +/* 20.9.5 Type property queries [meta.unary.prop.query] */ + +/* 20.9.6 Relationships between types [meta.rel] */ + +/** + * IsSame tests whether two types are the same type. + * + * mozilla::IsSame::value is true; + * mozilla::IsSame::value is true; + * mozilla::IsSame::value is false; + * mozilla::IsSame::value is true; + * mozilla::IsSame::value is false; + * mozilla::IsSame::value is true. + */ +template +struct IsSame : FalseType {}; + +template +struct IsSame : TrueType {}; + +namespace detail { + +// The trickery used to implement IsBaseOf here makes it possible to use it for +// the cases of private and multiple inheritance. This code was inspired by the +// sample code here: +// +// http://stackoverflow.com/questions/2910979/how-is-base-of-works +template +struct BaseOfHelper +{ + public: + operator Base*() const; + operator Derived*(); +}; + +template +struct BaseOfTester +{ + private: + template + static char test(Derived*, T); + static int test(Base*, int); + + public: + static const bool value = + sizeof(test(BaseOfHelper(), int())) == sizeof(char); +}; + +template +struct BaseOfTester +{ + private: + template + static char test(Derived*, T); + static int test(Base*, int); + + public: + static const bool value = + sizeof(test(BaseOfHelper(), int())) == sizeof(char); +}; + +template +struct BaseOfTester : FalseType {}; + +template +struct BaseOfTester : TrueType {}; + +template +struct BaseOfTester : TrueType {}; + +} /* namespace detail */ + +/* + * IsBaseOf allows to know whether a given class is derived from another. + * + * Consider the following class definitions: + * + * class A {}; + * class B : public A {}; + * class C {}; + * + * mozilla::IsBaseOf::value is true; + * mozilla::IsBaseOf::value is false; + */ +template +struct IsBaseOf + : IntegralConstant::value> +{}; + +namespace detail { + +template +struct ConvertibleTester +{ + private: + static From create(); + + template + static char test(To to); + + template + static int test(...); + + public: + static const bool value = + sizeof(test(create())) == sizeof(char); +}; + +} // namespace detail + +/** + * IsConvertible determines whether a value of type From will implicitly convert + * to a value of type To. For example: + * + * struct A {}; + * struct B : public A {}; + * struct C {}; + * + * mozilla::IsConvertible::value is true; + * mozilla::IsConvertible::value is true; + * mozilla::IsConvertible::value is true; + * mozilla::IsConvertible::value is true; + * mozilla::IsConvertible::value is false; + * mozilla::IsConvertible::value is false; + * mozilla::IsConvertible::value is false; + * mozilla::IsConvertible::value is false. + * + * For obscure reasons, you can't use IsConvertible when the types being tested + * are related through private inheritance, and you'll get a compile error if + * you try. Just don't do it! + */ +template +struct IsConvertible + : IntegralConstant::value> +{}; + +/* 20.9.7 Transformations between types [meta.trans] */ + +/* 20.9.7.1 Const-volatile modifications [meta.trans.cv] */ + +/* 20.9.7.2 Reference modifications [meta.trans.ref] */ + +/* 20.9.7.3 Sign modifications [meta.trans.sign] */ + +/* 20.9.7.4 Array modifications [meta.trans.arr] */ + +/* 20.9.7.5 Pointer modifications [meta.trans.ptr] */ + +/* 20.9.7.6 Other transformations [meta.trans.other] */ + +/** + * EnableIf is a struct containing a typedef of T if and only if B is true. + * + * mozilla::EnableIf::Type is int; + * mozilla::EnableIf::Type is a compile-time error. + * + * Use this template to implement SFINAE-style (Substitution Failure Is not An + * Error) requirements. For example, you might use it to impose a restriction + * on a template parameter: + * + * template + * class PodVector // vector optimized to store POD (memcpy-able) types + * { + * EnableIf::value, T>::Type* vector; + * size_t length; + * ... + * }; + */ +template +struct EnableIf +{}; + +template +struct EnableIf +{ + typedef T Type; +}; + +/** + * Conditional selects a class between two, depending on a given boolean value. + * + * mozilla::Conditional::Type is A; + * mozilla::Conditional::Type is B; + */ +template +struct Conditional +{ + typedef A Type; +}; + +template +struct Conditional +{ + typedef B Type; +}; + +} /* namespace mozilla */ + +#endif /* mozilla_TypeTraits_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/TypedEnum.h b/scripting/javascript/spidermonkey-mac/include/mozilla/TypedEnum.h new file mode 100644 index 0000000000..889960a32d --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/TypedEnum.h @@ -0,0 +1,213 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Macros to emulate C++11 typed enums and enum classes. */ + +#ifndef mozilla_TypedEnum_h_ +#define mozilla_TypedEnum_h_ + +#include "mozilla/Attributes.h" + +#if defined(__cplusplus) + +#if defined(__clang__) + /* + * Per Clang documentation, "Note that marketing version numbers should not + * be used to check for language features, as different vendors use different + * numbering schemes. Instead, use the feature checking macros." + */ +# ifndef __has_extension +# define __has_extension __has_feature /* compatibility, for older versions of clang */ +# endif +# if __has_extension(cxx_strong_enums) +# define MOZ_HAVE_CXX11_ENUM_TYPE +# define MOZ_HAVE_CXX11_STRONG_ENUMS +# endif +#elif defined(__GNUC__) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# if MOZ_GCC_VERSION_AT_LEAST(4, 5, 1) +# define MOZ_HAVE_CXX11_ENUM_TYPE +# define MOZ_HAVE_CXX11_STRONG_ENUMS +# endif +# endif +#elif defined(_MSC_VER) +# if _MSC_VER >= 1400 +# define MOZ_HAVE_CXX11_ENUM_TYPE +# endif +# if _MSC_VER >= 1700 +# define MOZ_HAVE_CXX11_STRONG_ENUMS +# endif +#endif + +/** + * MOZ_ENUM_TYPE specifies the underlying numeric type for an enum. It's + * specified by placing MOZ_ENUM_TYPE(type) immediately after the enum name in + * its declaration, and before the opening curly brace, like + * + * enum MyEnum MOZ_ENUM_TYPE(uint16_t) + * { + * A, + * B = 7, + * C + * }; + * + * In supporting compilers, the macro will expand to ": uint16_t". The + * compiler will allocate exactly two bytes for MyEnum and will require all + * enumerators to have values between 0 and 65535. (Thus specifying "B = + * 100000" instead of "B = 7" would fail to compile.) In old compilers the + * macro expands to the empty string, and the underlying type is generally + * undefined. + */ +#ifdef MOZ_HAVE_CXX11_ENUM_TYPE +# define MOZ_ENUM_TYPE(type) : type +#else +# define MOZ_ENUM_TYPE(type) /* no support */ +#endif + +/** + * MOZ_BEGIN_ENUM_CLASS and MOZ_END_ENUM_CLASS provide access to the + * strongly-typed enumeration feature of C++11 ("enum class"). If supported + * by the compiler, an enum defined using these macros will not be implicitly + * converted to any other type, and its enumerators will be scoped using the + * enumeration name. Place MOZ_BEGIN_ENUM_CLASS(EnumName, type) in place of + * "enum EnumName {", and MOZ_END_ENUM_CLASS(EnumName) in place of the closing + * "};". For example, + * + * MOZ_BEGIN_ENUM_CLASS(Enum, int32_t) + * A, + * B = 6 + * MOZ_END_ENUM_CLASS(Enum) + * + * This will make "Enum::A" and "Enum::B" appear in the global scope, but "A" + * and "B" will not. In compilers that support C++11 strongly-typed + * enumerations, implicit conversions of Enum values to numeric types will + * fail. In other compilers, Enum itself will actually be defined as a class, + * and some implicit conversions will fail while others will succeed. + * + * The type argument specifies the underlying type for the enum where + * supported, as with MOZ_ENUM_TYPE(). For simplicity, it is currently + * mandatory. As with MOZ_ENUM_TYPE(), it will do nothing on compilers that do + * not support it. + * + * Note that the workaround implemented here is not compatible with enums + * nested inside a class. + */ +#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS) + /* + * All compilers that support strong enums also support an explicit + * underlying type, so no extra check is needed. + */ +# define MOZ_BEGIN_ENUM_CLASS(Name, type) enum class Name : type { +# define MOZ_END_ENUM_CLASS(Name) }; +#else + /** + * We need Name to both name a type, and scope the provided enumerator + * names. Namespaces and classes both provide scoping, but namespaces + * aren't types, so we need to use a class that wraps the enum values. We + * have an implicit conversion from the inner enum type to the class, so + * statements like + * + * Enum x = Enum::A; + * + * will still work. We need to define an implicit conversion from the class + * to the inner enum as well, so that (for instance) switch statements will + * work. This means that the class can be implicitly converted to a numeric + * value as well via the enum type, since C++ allows an implicit + * user-defined conversion followed by a standard conversion to still be + * implicit. + * + * We have an explicit constructor from int defined, so that casts like + * (Enum)7 will still work. We also have a zero-argument constructor with + * no arguments, so declaration without initialization (like "Enum foo;") + * will work. + * + * Additionally, we'll delete as many operators as possible for the inner + * enum type, so statements like this will still fail: + * + * f(5 + Enum::B); // deleted operator+ + * + * But we can't prevent things like this, because C++ doesn't allow + * overriding conversions or assignment operators for enums: + * + * int x = Enum::A; + * int f() + * { + * return Enum::A; + * } + */ +# define MOZ_BEGIN_ENUM_CLASS(Name, type) \ + class Name \ + { \ + public: \ + enum Enum MOZ_ENUM_TYPE(type) \ + { +# define MOZ_END_ENUM_CLASS(Name) \ + }; \ + Name() {} \ + Name(Enum aEnum) : mEnum(aEnum) {} \ + explicit Name(int num) : mEnum((Enum)num) {} \ + operator Enum() const { return mEnum; } \ + private: \ + Enum mEnum; \ + }; \ + inline int operator+(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator+(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator-(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator-(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator*(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator*(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator/(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator/(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator%(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator%(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator+(const Name::Enum&) MOZ_DELETE; \ + inline int operator-(const Name::Enum&) MOZ_DELETE; \ + inline int& operator++(Name::Enum&) MOZ_DELETE; \ + inline int operator++(Name::Enum&, int) MOZ_DELETE; \ + inline int& operator--(Name::Enum&) MOZ_DELETE; \ + inline int operator--(Name::Enum&, int) MOZ_DELETE; \ + inline bool operator==(const int&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator==(const Name::Enum&, const int&) MOZ_DELETE; \ + inline bool operator!=(const int&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator!=(const Name::Enum&, const int&) MOZ_DELETE; \ + inline bool operator>(const int&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator>(const Name::Enum&, const int&) MOZ_DELETE; \ + inline bool operator<(const int&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator<(const Name::Enum&, const int&) MOZ_DELETE; \ + inline bool operator>=(const int&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator>=(const Name::Enum&, const int&) MOZ_DELETE; \ + inline bool operator<=(const int&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator<=(const Name::Enum&, const int&) MOZ_DELETE; \ + inline bool operator!(const Name::Enum&) MOZ_DELETE; \ + inline bool operator&&(const bool&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator&&(const Name::Enum&, const bool&) MOZ_DELETE; \ + inline bool operator||(const bool&, const Name::Enum&) MOZ_DELETE; \ + inline bool operator||(const Name::Enum&, const bool&) MOZ_DELETE; \ + inline int operator~(const Name::Enum&) MOZ_DELETE; \ + inline int operator&(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator&(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator|(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator|(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator^(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator^(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator<<(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator<<(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int operator>>(const int&, const Name::Enum&) MOZ_DELETE; \ + inline int operator>>(const Name::Enum&, const int&) MOZ_DELETE; \ + inline int& operator+=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator-=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator*=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator/=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator%=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator&=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator|=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator^=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator<<=(int&, const Name::Enum&) MOZ_DELETE; \ + inline int& operator>>=(int&, const Name::Enum&) MOZ_DELETE; +#endif + +#endif /* __cplusplus */ + +#endif /* mozilla_TypedEnum_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Types.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Types.h new file mode 100644 index 0000000000..56e5cb82fb --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Types.h @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* mfbt foundational types and macros. */ + +#ifndef mozilla_Types_h_ +#define mozilla_Types_h_ + +/* + * This header must be valid C and C++, includable by code embedding either + * SpiderMonkey or Gecko. + */ + +/* + * Expose all the integer types defined in C99's (and the integer + * limit and constant macros, if compiling C code or if compiling C++ code and + * the right __STDC_*_MACRO has been defined for each). These are all usable + * throughout mfbt code, and throughout Mozilla code more generally. + */ +#include "mozilla/StandardInteger.h" + +/* Also expose size_t. */ +#include + +/* Implement compiler and linker macros needed for APIs. */ + +/* + * MOZ_EXPORT is used to declare and define a symbol or type which is externally + * visible to users of the current library. It encapsulates various decorations + * needed to properly export the method's symbol. + * + * api.h: + * extern MOZ_EXPORT int MeaningOfLife(void); + * extern MOZ_EXPORT int LuggageCombination; + * + * api.c: + * int MeaningOfLife(void) { return 42; } + * int LuggageCombination = 12345; + * + * If you are merely sharing a method across files, just use plain |extern|. + * These macros are designed for use by library interfaces -- not for normal + * methods or data used cross-file. + */ +#if defined(WIN32) || defined(XP_OS2) +# define MOZ_EXPORT __declspec(dllexport) +#else /* Unix */ +# ifdef HAVE_VISIBILITY_ATTRIBUTE +# define MOZ_EXPORT __attribute__((visibility("default"))) +# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# define MOZ_EXPORT __global +# else +# define MOZ_EXPORT /* nothing */ +# endif +#endif + + +/* + * Whereas implementers use MOZ_EXPORT to declare and define library symbols, + * users use MOZ_IMPORT_API and MOZ_IMPORT_DATA to access them. Most often the + * implementer of the library will expose an API macro which expands to either + * the export or import version of the macro, depending upon the compilation + * mode. + */ +#ifdef _WIN32 +# if defined(__MWERKS__) +# define MOZ_IMPORT_API /* nothing */ +# else +# define MOZ_IMPORT_API __declspec(dllimport) +# endif +#elif defined(XP_OS2) +# define MOZ_IMPORT_API __declspec(dllimport) +#else +# define MOZ_IMPORT_API MOZ_EXPORT +#endif + +#if defined(_WIN32) && !defined(__MWERKS__) +# define MOZ_IMPORT_DATA __declspec(dllimport) +#elif defined(XP_OS2) +# define MOZ_IMPORT_DATA __declspec(dllimport) +#else +# define MOZ_IMPORT_DATA MOZ_EXPORT +#endif + +/* + * Consistent with the above comment, the MFBT_API and MFBT_DATA macros expose + * export mfbt declarations when building mfbt, and they expose import mfbt + * declarations when using mfbt. + */ +#if defined(IMPL_MFBT) +# define MFBT_API MOZ_EXPORT +# define MFBT_DATA MOZ_EXPORT +#else + /* + * On linux mozglue is linked in the program and we link libxul.so with + * -z,defs. Normally that causes the linker to reject undefined references in + * libxul.so, but as a loophole it allows undefined references to weak + * symbols. We add the weak attribute to the import version of the MFBT API + * macros to exploit this. + */ +# if defined(MOZ_GLUE_IN_PROGRAM) +# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API +# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA +# else +# define MFBT_API MOZ_IMPORT_API +# define MFBT_DATA MOZ_IMPORT_DATA +# endif +#endif + +/* + * C symbols in C++ code must be declared immediately within |extern "C"| + * blocks. However, in C code, they need not be declared specially. This + * difference is abstracted behind the MOZ_BEGIN_EXTERN_C and MOZ_END_EXTERN_C + * macros, so that the user need not know whether he is being used in C or C++ + * code. + * + * MOZ_BEGIN_EXTERN_C + * + * extern MOZ_EXPORT int MostRandomNumber(void); + * ...other declarations... + * + * MOZ_END_EXTERN_C + * + * This said, it is preferable to just use |extern "C"| in C++ header files for + * its greater clarity. + */ +#ifdef __cplusplus +# define MOZ_BEGIN_EXTERN_C extern "C" { +# define MOZ_END_EXTERN_C } +#else +# define MOZ_BEGIN_EXTERN_C +# define MOZ_END_EXTERN_C +#endif + +#endif /* mozilla_Types_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/Util.h b/scripting/javascript/spidermonkey-mac/include/mozilla/Util.h new file mode 100644 index 0000000000..097c5478eb --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/Util.h @@ -0,0 +1,283 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Miscellaneous uncategorized functionality. Please add new functionality to + * new headers, or to other appropriate existing headers, not here. + */ + +#ifndef mozilla_Util_h_ +#define mozilla_Util_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/Types.h" + +#ifdef __cplusplus + +namespace mozilla { + +/* + * This class, and the corresponding macro MOZ_ALIGNOF, figure out how many + * bytes of alignment a given type needs. + */ +template +class AlignmentFinder +{ + struct Aligner + { + char c; + T t; + }; + + public: + static const size_t alignment = sizeof(Aligner) - sizeof(T); +}; + +#define MOZ_ALIGNOF(T) mozilla::AlignmentFinder::alignment + +/* + * Declare the MOZ_ALIGNED_DECL macro for declaring aligned types. + * + * For instance, + * + * MOZ_ALIGNED_DECL(char arr[2], 8); + * + * will declare a two-character array |arr| aligned to 8 bytes. + */ + +#if defined(__GNUC__) +# define MOZ_ALIGNED_DECL(_type, _align) \ + _type __attribute__((aligned(_align))) +#elif defined(_MSC_VER) +# define MOZ_ALIGNED_DECL(_type, _align) \ + __declspec(align(_align)) _type +#else +# warning "We don't know how to align variables on this compiler." +# define MOZ_ALIGNED_DECL(_type, _align) _type +#endif + +/* + * AlignedElem is a structure whose alignment is guaranteed to be at least N + * bytes. + * + * We support 1, 2, 4, 8, and 16-bit alignment. + */ +template +struct AlignedElem; + +/* + * We have to specialize this template because GCC doesn't like __attribute__((aligned(foo))) where + * foo is a template parameter. + */ + +template<> +struct AlignedElem<1> +{ + MOZ_ALIGNED_DECL(uint8_t elem, 1); +}; + +template<> +struct AlignedElem<2> +{ + MOZ_ALIGNED_DECL(uint8_t elem, 2); +}; + +template<> +struct AlignedElem<4> +{ + MOZ_ALIGNED_DECL(uint8_t elem, 4); +}; + +template<> +struct AlignedElem<8> +{ + MOZ_ALIGNED_DECL(uint8_t elem, 8); +}; + +template<> +struct AlignedElem<16> +{ + MOZ_ALIGNED_DECL(uint8_t elem, 16); +}; + +/* + * This utility pales in comparison to Boost's aligned_storage. The utility + * simply assumes that uint64_t is enough alignment for anyone. This may need + * to be extended one day... + * + * As an important side effect, pulling the storage into this template is + * enough obfuscation to confuse gcc's strict-aliasing analysis into not giving + * false negatives when we cast from the char buffer to whatever type we've + * constructed using the bytes. + */ +template +struct AlignedStorage +{ + union U { + char bytes[nbytes]; + uint64_t _; + } u; + + const void* addr() const { return u.bytes; } + void* addr() { return u.bytes; } +}; + +template +struct AlignedStorage2 +{ + union U { + char bytes[sizeof(T)]; + uint64_t _; + } u; + + const T* addr() const { return reinterpret_cast(u.bytes); } + T* addr() { return static_cast(static_cast(u.bytes)); } +}; + +/* + * Small utility for lazily constructing objects without using dynamic storage. + * When a Maybe is constructed, it is |empty()|, i.e., no value of T has + * been constructed and no T destructor will be called when the Maybe is + * destroyed. Upon calling |construct|, a T object will be constructed with the + * given arguments and that object will be destroyed when the owning Maybe + * is destroyed. + * + * N.B. GCC seems to miss some optimizations with Maybe and may generate extra + * branches/loads/stores. Use with caution on hot paths. + */ +template +class Maybe +{ + AlignedStorage2 storage; + bool constructed; + + T& asT() { return *storage.addr(); } + + public: + Maybe() { constructed = false; } + ~Maybe() { if (constructed) asT().~T(); } + + bool empty() const { return !constructed; } + + void construct() { + MOZ_ASSERT(!constructed); + ::new (storage.addr()) T(); + constructed = true; + } + + template + void construct(const T1& t1) { + MOZ_ASSERT(!constructed); + ::new (storage.addr()) T(t1); + constructed = true; + } + + template + void construct(const T1& t1, const T2& t2) { + MOZ_ASSERT(!constructed); + ::new (storage.addr()) T(t1, t2); + constructed = true; + } + + template + void construct(const T1& t1, const T2& t2, const T3& t3) { + MOZ_ASSERT(!constructed); + ::new (storage.addr()) T(t1, t2, t3); + constructed = true; + } + + template + void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4) { + MOZ_ASSERT(!constructed); + ::new (storage.addr()) T(t1, t2, t3, t4); + constructed = true; + } + + T* addr() { + MOZ_ASSERT(constructed); + return &asT(); + } + + T& ref() { + MOZ_ASSERT(constructed); + return asT(); + } + + const T& ref() const { + MOZ_ASSERT(constructed); + return const_cast(this)->asT(); + } + + void destroy() { + ref().~T(); + constructed = false; + } + + void destroyIfConstructed() { + if (!empty()) + destroy(); + } + + private: + Maybe(const Maybe& other) MOZ_DELETE; + const Maybe& operator=(const Maybe& other) MOZ_DELETE; +}; + +/* + * Safely subtract two pointers when it is known that end >= begin. This avoids + * the common compiler bug that if (size_t(end) - size_t(begin)) has the MSB + * set, the unsigned subtraction followed by right shift will produce -1, or + * size_t(-1), instead of the real difference. + */ +template +MOZ_ALWAYS_INLINE size_t +PointerRangeSize(T* begin, T* end) +{ + MOZ_ASSERT(end >= begin); + return (size_t(end) - size_t(begin)) / sizeof(T); +} + +/* + * Compute the length of an array with constant length. (Use of this method + * with a non-array pointer will not compile.) + * + * Beware of the implicit trailing '\0' when using this with string constants. + */ +template +MOZ_CONSTEXPR size_t +ArrayLength(T (&arr)[N]) +{ + return N; +} + +/* + * Compute the address one past the last element of a constant-length array. + * + * Beware of the implicit trailing '\0' when using this with string constants. + */ +template +MOZ_CONSTEXPR T* +ArrayEnd(T (&arr)[N]) +{ + return arr + ArrayLength(arr); +} + +} /* namespace mozilla */ + +#endif /* __cplusplus */ + +/* + * MOZ_ARRAY_LENGTH() is an alternative to mozilla::ArrayLength() for C files + * that can't use C++ template functions and for MOZ_STATIC_ASSERT() calls that + * can't call ArrayLength() when it is not a C++11 constexpr function. + */ +#ifdef MOZ_HAVE_CXX11_CONSTEXPR +# define MOZ_ARRAY_LENGTH(array) mozilla::ArrayLength(array) +#else +# define MOZ_ARRAY_LENGTH(array) (sizeof(array)/sizeof((array)[0])) +#endif + +#endif /* mozilla_Util_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/include/mozilla/WeakPtr.h b/scripting/javascript/spidermonkey-mac/include/mozilla/WeakPtr.h new file mode 100644 index 0000000000..b8437f5bcf --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/include/mozilla/WeakPtr.h @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Weak pointer functionality, implemented as a mixin for use with any class. */ + +/** + * SupportsWeakPtr lets you have a pointer to an object 'Foo' without affecting + * its lifetime. It works by creating a single shared reference counted object + * (WeakReference) that each WeakPtr will access 'Foo' through. This lets 'Foo' + * clear the pointer in the WeakReference without having to know about all of + * the WeakPtrs to it and allows the WeakReference to live beyond the lifetime + * of 'Foo'. + * + * The overhead of WeakPtr is that accesses to 'Foo' becomes an additional + * dereference, and an additional heap allocated pointer sized object shared + * between all of the WeakPtrs. + * + * Example of usage: + * + * // To have a class C support weak pointers, inherit from SupportsWeakPtr. + * class C : public SupportsWeakPtr + * { + * public: + * int num; + * void act(); + * }; + * + * C* ptr = new C(); + * + * // Get weak pointers to ptr. The first time asWeakPtr is called + * // a reference counted WeakReference object is created that + * // can live beyond the lifetime of 'ptr'. The WeakReference + * // object will be notified of 'ptr's destruction. + * WeakPtr weak = ptr->asWeakPtr(); + * WeakPtr other = ptr->asWeakPtr(); + * + * // Test a weak pointer for validity before using it. + * if (weak) { + * weak->num = 17; + * weak->act(); + * } + * + * // Destroying the underlying object clears weak pointers to it. + * delete ptr; + * + * MOZ_ASSERT(!weak, "Deleting |ptr| clears weak pointers to it."); + * MOZ_ASSERT(!other, "Deleting |ptr| clears all weak pointers to it."); + * + * WeakPtr is typesafe and may be used with any class. It is not required that + * the class be reference-counted or allocated in any particular way. + * + * The API was loosely inspired by Chromium's weak_ptr.h: + * http://src.chromium.org/svn/trunk/src/base/memory/weak_ptr.h + */ + +#ifndef mozilla_WeakPtr_h_ +#define mozilla_WeakPtr_h_ + +#include "mozilla/Assertions.h" +#include "mozilla/NullPtr.h" +#include "mozilla/RefPtr.h" +#include "mozilla/TypeTraits.h" + +namespace mozilla { + +template class WeakPtr; + +template +class SupportsWeakPtr +{ + public: + WeakPtr asWeakPtr() { + if (!weakRef) + weakRef = new WeakReference(static_cast(this)); + return WeakPtr(weakRef); + } + + protected: + ~SupportsWeakPtr() { + MOZ_STATIC_ASSERT((IsBaseOf, T>::value), "T must derive from SupportsWeakPtr"); + if (weakRef) + weakRef->detach(); + } + + private: + friend class WeakPtr; + + // This can live beyond the lifetime of the class derived from SupportsWeakPtr. + class WeakReference : public RefCounted + { + public: + explicit WeakReference(T* p) : ptr(p) {} + T* get() const { + return ptr; + } + + private: + friend class WeakPtr; + friend class SupportsWeakPtr; + void detach() { + ptr = nullptr; + } + T* ptr; + }; + + RefPtr weakRef; +}; + +template +class WeakPtr +{ + public: + WeakPtr(const WeakPtr& o) : ref(o.ref) {} + // Ensure that ref is dereferenceable in the uninitialized state + WeakPtr() : ref(new typename SupportsWeakPtr::WeakReference(nullptr)) {} + + operator T*() const { + return ref->get(); + } + T& operator*() const { + return *ref->get(); + } + + T* operator->() const { + return ref->get(); + } + + T* get() const { + return ref->get(); + } + + private: + friend class SupportsWeakPtr; + + explicit WeakPtr(const RefPtr::WeakReference> &o) : ref(o) {} + + RefPtr::WeakReference> ref; +}; + +} // namespace mozilla + +#endif /* ifdef mozilla_WeakPtr_h_ */ diff --git a/scripting/javascript/spidermonkey-mac/lib/libjs_static.a.REMOVED.git-id b/scripting/javascript/spidermonkey-mac/lib/libjs_static.a.REMOVED.git-id new file mode 100644 index 0000000000..3ba4c5faf2 --- /dev/null +++ b/scripting/javascript/spidermonkey-mac/lib/libjs_static.a.REMOVED.git-id @@ -0,0 +1 @@ +0c79530f86751f9f84bd310d65e2cb505451e973 \ No newline at end of file diff --git a/tools/project-creator/create_project.py b/tools/project-creator/create_project.py index bd8a052d8b..5492cbeb2c 100755 --- a/tools/project-creator/create_project.py +++ b/tools/project-creator/create_project.py @@ -5,16 +5,7 @@ # Author: WangZhe # define global variables -context = { -"language" : "undefined", -"src_project_name" : "undefined", -"src_package_name" : "undefined", -"dst_project_name" : "undeifned", -"dst_package_name" : "undefined", -"src_project_path" : "undefined", -"dst_project_path" : "undefined", -"script_dir" : "undefined", -} +context = {}.fromkeys(("language", "src_project_name", "src_package_name", "dst_project_name", "dst_package_name", "src_project_path", "dst_project_path", "script_dir")); platforms_list = [] # begin @@ -23,52 +14,42 @@ import os, os.path import json import shutil -def dumpUsage(): - print "Usage: create_project.py -project PROJECT_NAME -package PACKAGE_NAME -language PROGRAMING_LANGUAGE" - print "Options:" - print " -project PROJECT_NAME Project name, for example: MyGame" - print " -package PACKAGE_NAME Package name, for example: com.MyCompany.MyAwesomeGame" - print " -language PROGRAMING_LANGUAGE Major programing lanauge you want to used, should be [cpp | lua | javascript]" - print "" - print "Sample : ./create_project.py -project MyGame -package com.MyCompany.AwesomeGame -language javascript" - print "" - def checkParams(context): + from optparse import OptionParser + + # set the parser to parse input params + # the correspond variable name of "-x, --xxx" is parser.xxx + parser = OptionParser(usage="Usage: ./%prog -p -k -l \nSample: ./%prog -p MyGame -k com.MyCompany.AwesomeGame -l javascript") + parser.add_option("-p", "--project", metavar="PROJECT_NAME", help="Set a project name") + parser.add_option("-k", "--package", metavar="PACKAGE_NAME", help="Set a package name for project") + parser.add_option("-l", "--language", + metavar="PROGRAMMING_NAME", + type="choice", + choices=["cpp", "lua", "javascript"], + help="Major programing lanauge you want to used, should be [cpp | lua | javascript]") + + #parse the params + (opts, args) = parser.parse_args() + # generate our internal params context["script_dir"] = os.getcwd() + "/" global platforms_list - # invalid invoke, tell users how to input params - if len(sys.argv) < 7: - dumpUsage() - sys.exit() - - # find our params - for i in range(1, len(sys.argv)): - if "-project" == sys.argv[i]: - # read the next param as project_name - context["dst_project_name"] = sys.argv[i+1] - context["dst_project_path"] = os.getcwd() + "/../../projects/" + context["dst_project_name"] - elif "-package" == sys.argv[i]: - # read the next param as g_PackageName - context["dst_package_name"] = sys.argv[i+1] - elif "-language" == sys.argv[i]: - # choose a scripting language - context["language"] = sys.argv[i+1] - - # pinrt error log our required paramters are not ready - raise_error = False - if context["dst_project_name"] == "undefined": - print "Invalid -project parameter" - raise_error = True - if context["dst_package_name"] == "undefined": - print "Invalid -package parameter" - raise_error = True - if context["language"] == "undefined": - print "Invalid -language parameter" - raise_error = True - if raise_error != False: - sys.exit() + if opts.project: + context["dst_project_name"] = opts.project + context["dst_project_path"] = os.getcwd() + "/../../projects/" + context["dst_project_name"] + else: + parser.error("-p or --project is not specified") + + if opts.package: + context["dst_package_name"] = opts.package + else: + parser.error("-k or --package is not specified") + + if opts.language: + context["language"] = opts.language + else: + parser.error("-l or --language is not specified") # fill in src_project_name and src_package_name according to "language" if ("cpp" == context["language"]): diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 8654839dc8..14ec24745a 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -44,7 +44,7 @@ skip = Node::[convertToWindowSpace ^setPosition$ getGrid setGLServerState descri LayerColor::[getBlendFunc setBlendFunc], ParticleSystem::[getBlendFunc setBlendFunc], DrawNode::[getBlendFunc setBlendFunc drawPolygon], - Director::[getAccelerometer getKeypadDispatcher getTouchDispatcher setWatcherCallbackFun getOpenGLView getProjection getClassTypeInfo], + Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo], Layer.*::[didAccelerate (g|s)etBlendFunc], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], MenuItem.*::[create setCallback initWithCallback],